Skip to content

Ramblings

Musings of Matt Williams
  • Blog
  • About
  • Chibi
  • Ruby Blender
  • Archives
  • Log in
 
Less
More
Trim
Untrim
« Older
Home
Loading
Newer »
Tag Archive for 'gotchas'
29Jul09 JBoss port confusion
gotchas jboss
0 Comments

We ran into a case where JBoss was unable to come up; it gave the following (partial) exception:

java.rmi.server.ExportException: Port already in use: 1098; nested exception is:
java.net.BindException: Cannot assign requested address

After poking around with netstat and lsof, we couldn’t find anything that was binding to the port.  I’d made the assumption that it was bound, totally missing the next line.  As it turns out, we were attempting to bind to a vip which, although it existed in DNS, was not defined on the host on which the error occurred.  The “cannot assign requested address” was the clue.

Enhanced by Zemanta
11Nov08 YUI Datasources
gotchas
0 Comments

Been a while since I’ve written.  I’ve been sick and working on a side project.  That said, I’ll be writing more……

Today’s note/reminder is a gotcha about YUI datasources.  If you have JSON feeding the datasource and you’re getting back more fields in the results than you’re expecting, the datasource will not behave properly.  For example, if you’ve declared that you’re getting back

  • name
  • id

But in reality you get

  • name
  • id
  • address
  • email

it will just sit there. Very frustrating. Very fun trying to debug, too!

25Sep08 JBoss run.sh may be harmful
gotchas jboss
0 Comments

A coworker and I discovered an issue with jboss’ run.sh (which starts the app server).  The problem lies in different flavours of unix (or unix-like) shells returning different values for wait.

The relevant code is:

      # Wait until the background process exits
      WAIT_STATUS=0
      while [ "$WAIT_STATUS" -ne 127 ]; do
         JBOSS_STATUS=$WAIT_STATUS
         wait $JBOSS_PID 2>/dev/null
         WAIT_STATUS=$?
      done

This is all well and good in linux — redhat uses /bin/bash and ubuntu uses /bin/dash for /bin/sh — both of which return 127 when waiting for a process which does not exist. However, Solaris’ /bin/sh returns 0 (/bin/ksh returns 127).

So, the run.sh goes into an infinite loop, thrashing, badly. CPU gets pegged and all that fun stuff.

How to fix? Well in order to make it OS/shell dependant, we'll determine the value which is returned by wait when a process does not exist. We're guaranteed that there is one process id which won't be used in unix -- 0. So, we wait on PID 0, and use the return value, $? to determine how the environment handles the wait. The "fixed" code looks like:

      wait 0 2>/dev/null
      NO_SUCH_PID=$?
      # Wait until the background process exits
      WAIT_STATUS=0
      while [ "$WAIT_STATUS" -ne $NO_SUCH_PID ]; do
         JBOSS_STATUS=$WAIT_STATUS
         wait $JBOSS_PID 2>/dev/null
         WAIT_STATUS=$?
      done

EDIT:
This was fixed in 4.2.3 GA with the following code:

# Wait until the background process exits
      WAIT_STATUS=128
      while [ "$WAIT_STATUS" -ge 128 ]; do
         wait $JBOSS_PID 2>/dev/null
         WAIT_STATUS=$?
         if [ "${WAIT_STATUS}" -gt 128 ]; then
            SIGNAL=`expr ${WAIT_STATUS} - 128`
            SIGNAL_NAME=`kill -l ${SIGNAL}`
            echo "*** JBossAS process (${JBOSS_PID}) received ${SIGNAL_NAME} signal. ***" >&2
         fi
      done
      if [ "${WAIT_STATUS}" -lt 127 ]; then
         JBOSS_STATUS=$WAIT_STATUS
      else
         JBOSS_STATUS=0
      fi
12Sep08 Class is Class, and Instance, Instance, and never the twain shall meet
eating crow gotchas programming ruby Uncategorized
2 Comments

More about methods, it’s inspired/spurred by a comment on methods, public_methods, and private_methods by Pit Captain. It also corrects some misconceptions I had (and may have (wrongly) given others).

I’ve added a new category, “eating crow” for this and any other postings where I step back and re-evaluate my posts. This is to keep me honest, and, if y’all would, please feel free to tell me when it’s time to “eat crow”.
Continue reading ‘Class is Class, and Instance, Instance, and never the twain shall meet’

29Aug08 CSS tooltips using CSS Sprites
css gotchas Uncategorized web design
2 Comments
Thought Bubbles!

Thought Bubbles!

For a project I’m currently working on I wanted to make some “bubble” tooltips.  In order to cut down on the size/number of images, I’m using css sprites.  A quick google reveals that nobody else has (at least on the first page) put together tooltips using sprites.  The technique will work with any sort of image, so you needn’t use the “bubbles”.  So, here’s how I did it, with the caveats/gotchas. Continue reading ‘CSS tooltips using CSS Sprites’

28Aug08 CSS “width” gotcha
css gotchas web web design
0 Comments

I found out something interesting today.  Per the W3C, the total “width” that a block element uses is:

If ‘left’ or ‘right’ are given as ‘auto’, their computed value is 0. The following constraints must hold between the other properties:

‘margin-left’ + ‘border-left-width’ + ‘padding-left’ + ‘width’ + ‘padding-right’ + ‘border-right-width’ + ‘margin-right’ = width of containing block

This made life interesting while working on a css sprite (more on that next).  I kept wondering why it bled into the next sprite….

I had thought it was the total width of the element.  Foolish me.  Now I know and……

26Aug08 Why my code is broken….. (break my code redux)
gotchas programming ruby
0 Comments

Yesterday, I posted an article entitled Break my code, please, wherein I posted a very fragile piece of code, with the challenge to find ways in which to break it.

What follows is a discussion of the code and why it is bad/fragile/easily broken…..

Continue reading ‘Why my code is broken….. (break my code redux)’

19Aug08 rspec, restful_authentication, and login_required
rails tips
6 Comments

This is partly for myself, and partly for anyone after me…..

I have a controller generated via rspec_scaffold — yes, I know, it might not be what all the cool kids are doing, but it works.  I also have restful_authentication set up to use rspec.  So, when I go to add before_filter :login_required, autotest frowns at me.  After much trial and error, and googling (with false hits and things that didn’t work), I finally achieved a smiley face with the following added to my controller’s spec:

  before :each do
   @current_user = mock_model(User, :id => 1)
   controller.stub!(:current_user).and_return(@current_user)
   controller.stub!(:login_required).and_return(:true)
  end
  fixtures :users
19Aug08 autotest reminder (or why did it go boom?)
gotchas rails ruby tips
0 Comments

autotest / zentest are really useful tools.  However, it’s important to remember to run migrations for the test database — otherwise your tests will fail (miserably!)

I’ve found the following to be helpful for using autotest:

  • Getting started with Autotest – Continuous Testing
  • Autotest RSpec Notifications for Ubuntu « My Pragmatig life
13Aug08 The trouble with injection
gotchas tips
2 Comments

Ruby’s injection is very useful, but if you don’t remember one key fact, you’ll shoot yourself in the foot.

Continue reading ‘The trouble with injection’

 
Browse Archives »
  • administrivia (6)
  • books (1)
  • Computers (2)
  • css (3)
  • eating crow (1)
  • games (1)
  • glassfish (1)
  • gotchas (18)
  • howto (2)
  • idiocy (3)
  • javascript (4)
  • jboss (6)
  • jruby (7)
  • Just Enough Programming (7)
  • life hacking (2)
  • mini sagas (1)
  • miscellany (1)
  • monitoring (1)
  • mysql (1)
  • philosophy (4)
  • php (1)
  • programming (17)
  • rails (7)
  • rants (2)
  • refactoring (1)
  • ruby (14)
  • tips (9)
  • tools (2)
  • torquebox (1)
  • Uncategorized (9)
  • UNIX (1)
  • utilities (3)
  • web (5)
  • web design (3)
 

Latest

  • JBoss Client Jars for Messaging
  • rsh hates nohup
  • Torquebox and Cygwin: Take I
  • Rails & JRuby in a Jar
  • Fractal Terrain Generation
  • Quick thought on programming and distractions
  • Using jnp as a JBoss heartbeat
  • z-index and events
  • JBoss port confusion
  • SSL Joys

Flickr

layout_newm3headerTerrain Testa

Blogroll

  • Development Blog
  • Documentation
  • Plugins
  • Suggest Ideas
  • Support Forum
  • Themes
  • WordPress Planet

Search

Browse by Category

  • administrivia (6)
  • books (1)
  • Computers (2)
  • css (3)
  • eating crow (1)
  • games (1)
  • glassfish (1)
  • gotchas (18)
  • howto (2)
  • idiocy (3)
  • javascript (4)
  • jboss (6)
  • jruby (7)
  • Just Enough Programming (7)
  • life hacking (2)
  • mini sagas (1)
  • miscellany (1)
  • monitoring (1)
  • mysql (1)
  • philosophy (4)
  • php (1)
  • programming (17)
  • rails (7)
  • rants (2)
  • refactoring (1)
  • ruby (14)
  • tips (9)
  • tools (2)
  • torquebox (1)
  • Uncategorized (9)
  • UNIX (1)
  • utilities (3)
  • web (5)
  • web design (3)

Browse by Tag

  • 1.2.6
  • 2.1
  • administrivia
  • autotest
  • books
  • controller
  • css
  • feed-normalizer
  • feeds
  • gotchas
  • idiocy
  • irb
  • Java
  • javascript
  • jboss
  • jruby
  • just enough programming
  • mini sagas
  • open-uri
  • philosophy
  • php
  • pragmatism
  • programming
  • quotations
  • rails
  • rants
  • reading
  • restful_authentication
  • rspec
  • rss
  • ruby
  • rubygems
  • scriptaculous
  • setup
  • simplicity
  • sprites
  • statemachine
  • tips
  • treetop
  • utilities
  • web
  • web design
  • websense
  • yaml
  • zentest

Browse by Month

  • November 2010 (1)
  • August 2010 (1)
  • June 2010 (1)
  • March 2010 (1)
  • September 2009 (1)
  • August 2009 (2)
  • July 2009 (2)
  • May 2009 (1)
  • April 2009 (1)
  • February 2009 (4)
  • January 2009 (2)
  • December 2008 (2)
  • November 2008 (5)
  • October 2008 (3)
  • September 2008 (12)
  • August 2008 (28)
 
 
  • Blog
  • About
  • Chibi
  • Ruby Blender
  • Archives
  • Log in
 


Theme Design by Jay Kwong | Powered by WordPress and K2

 

Home Top Archives Entries FeedComments Feed