title: Java: Commons-codec and base64 decoding not working on server
body: <p>I sit with a weird problem. I use Apache's commons-codec (ver 1.4).  The following code snippet work correctly on my PC (java version 1.6, Glassfish ver 2.1) in a standalone app and in an EJB, but on my server in an EJB it doesn't work correctly (but in a standalone app it works correctly)</p>
  
  <pre><code>...
  org.apache.commons.codec.binary.Base64 b64 = new org.apache.commons.codec.binary.Base64();
  byte[] bytes = b64.decode(makeSignedBytes(strB64.getBytes("UTF-8")));
  ...
  private byte[] makeSignedBytes(byte[] ubytes)
  {
      byte[] sbytes = new byte[ubytes.length];
      for (int i = 0; i &lt; ubytes.length; i++)
      {
          sbytes[i] = (byte)(0x000000FF &amp; ((int) ubytes[i]));
      }
      return sbytes;
  }
  </code></pre>
  
  <p>The input string is: </p>
  
  <pre><code>4-sDHXi_2Tu2a8k8NPs1FBT3t7UvN7CksUV6gfSE_Ks0aiCPbdeGM8qLdC58b2_hFH7lEp8m9cyPYQOTo4E0t66ZYP8n8tRhT87c8iD34pCd80qvP9vIXsNsodRaGzK5
  </code></pre>
  
  <p>The output byte array should look like this (I've hex printed it):</p>
  
  <pre><code>|E3|EB|03|1D|78|BF|D9|3B|B6|6B|C9|3C|34|FB|35|14|14|F7|B7|B5|2F|37|B0|A4|B1|45|7A|81|F4|84|FC|AB|34|6A|20|8F|6D|D7|86|33|CA|8B|74|2E|7C|6F|6F|E1|14|7E|E5|12|9F|26|F5|CC|8F|61|03|93|A3|81|34|B7|AE|99|60|FF|27|F2|D4|61|4F|CE|DC|F2|20|F7|E2|90|9D|F3|4A|AF|3F|DB|C8|5E|C3|6C|A1|D4|5A|1B|32|B9|
  </code></pre>
  
  <p>96 bytes long, when the server get's it wrong it's only 93 bytes and looks like this:</p>
  
  <pre><code>|E2|C0|C7|5E|2D|93|BB|66|BC|93|C3|4F|B3|51|41|4F|7B|7B|52|F3|7B|0A|4B|14|57|A8|1F|48|42|AC|D1|A8|82|3D|B7|5E|18|CF|2A|2D|D0|B9|F1|BD|A1|14|7E|E5|12|9F|26|F5|CC|8F|61|03|93|A3|81|34|B7|AE|99|60|FF|27|F2|D4|61|4F|CE|DC|F2|20|F7|E2|90|9D|F3|4A|AF|3F|DB|C8|5E|C3|6C|A1|D4|5A|1B|32|B9|
  </code></pre>
  
  <p>I have no idea why it works on my pc and not on the server :(</p>