T Masga

+ Follow
since Jun 25, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by T Masga


I'm looking into resolving a problem I'm facing with streams, bytes, byte arrays. I would like to hear your opinion on the best practice to implement what I want.

So the story follows.

I've created a series of classes, with property accessors, and some internal behavior.

What I intend to reach is a class that developers can instantiate, define some parameters through specific setter methods, and then put some data to be processed (passed in as byte[]). All that will be wrapped in this nice little class, and then I'll have a major process that picks that class, and do some processing. Based on the data stored and properties defined by setter methods, the processing will end up returning a byte array (byte[]).

Nice. I can now save it to disk ... nice.

Then I have the opposite process ... a parser that receives an InputStream and just flies through it, and at the end returns a properly instantiated class, so application code can use it accordingly. I'm thinking InputStream, because that way I could just feed the processing with almost any sort of source ... file, byte array in memory, socket received stream data ...

All was going well until I found this small problem ... byte is signed in java ... which means that if I pick "11011111" binary, convert into 223 decimal, and then store it into a byte, it will end up being -33.

Well, I can correct this behavior with some arithmetic logic, in the form of:

int _decimal = _byte & 0x80;
_decimal += _byte & 0x7F;

That would do the trick, but that just don't gives me comfort about the way I'm doing this, and would require this step of conversion after receiving the byte array. There are some bytes that are created bit-by-bit, so I can get any byte from 0-255 interval.

What would be a good way to do this? Should I work with byte[] data for storing data, retrieving, and so on, as I'm doing now?

Should I just work with Strings?

Should I go with int[] and store decimal representations?

The byte array seemed to me more low level, and so with more performance and better versatility ... as for instance even the String has a constructor that receives a byte[], and System.arraycopy could be used for some special work over the processed data.

Any opinions appreciated.

10 years ago

I'm starting a new JEE project from scratch, and I'm having some troubles I where it should be quite easy.

I'm using Eclipse Galileo 3.5.1, and Maven2Plugin.

So I have the following project structure:


All projects were created inside Eclipse, with default maven structures (except test-project), then the pom's were added accordingly.

The most important error I'm getting right now is in the ejb project, when exporting/deploying ... the project uses one jbpm jar, and in the Eclipse IDE it shows no errors, since maven plugin resolves all dependencies.

Now the problem is that, when I export, the ejb manifest has no classpath attributes entries ... the jar is located in the ear root, but it isn't specified in the manifest file, so I have a ClassNotFoundException because I'm using a class from the jar.

That's ok, so I went to eclipse, project ejb -> "Java EE Module Dependencies", it doesn't show the jars of the classpath ... so I cannot select them into the manifest file.

If I add it manually to the manifest file, the project goes ok, but no jars are present. Since all is maintained by the maven plugin, I only have the possibility to choose a "Maven Dependencies" entry, that doesn't add anything to the manifest.

I'm testing with just one jar, but the project will have lot's of jars, so including them by hand is a pain, and future maintenance will became chaotic.

Shouldn't the manifest be automatically maintained by eclipse?

I know maven build will create one, but I intended to have this also managed in eclipse, so I could add a server and auto-deploy inside eclipse for development and testing.


I'm a java developer, and I'm used to developing web applications.

Recently I've took a closer look at JAAS, and since some time ago when I last looked into it, I still have many questions around it.

This is one subject that, no matter how many tutorials I read, there is something about it that does not compute in my head.

You know that feeling that there is just some -click- that must happen before everything clears up in the brain? I think I need something like that.

The thing is: JAAS is around for quite some time. The way I see it, when I configure the roles and authentication mechanisms in a Web Application Server, I'm using JAAS behind, even without knowing how it glues stuff together.

I can define the authentication type in application server, then I define the roles in my web application, and then on deployment, I can map them together, or I can have a specific deployment file for a specific application server that helps automating the task.

I normally define a Form Based Login, then create a custom form with j_security_check ...

But then again, the JAAS defines some config files like:

Does the application server does it behind?

Recently I've came across a software that I can install on an application server, Bonita Open Solution. Somewhere in the installation manual, I find something like:


- Copy the bonita.ear file into your JEE server deployment directory (e.g., jboss/server/default/deploy)

- Add BonitaAuth and BonitaStore login modules to the JAAS configuration for your JEE server:

o org.ow2.bonita.identity.auth.BonitaIdentityLoginModule

o org.ow2.bonita.identity.auth.BonitaRemoteLoginModule (must be stacked with your JEE JAAS propagation login module)

o edit jboss/server/default/conf/login-config.xml to add:

<application-policy name="BonitaAuth">
<login-module code="org.ow2.bonita.identity.auth.BonitaIdentityLoginModule" flag="required"/>
<application-policy name="BonitaStore">
<login-module code="org.ow2.bonita.identity.auth.BonitaRemoteLoginModule" flag="required"/>
<login-module code="org.jboss.security.ClientLoginModule" flag="required">
<module-option name="password-stacking">useFirstPass</module-option>

- Start the server.

What confusion is this?

Shouldn't this be simpler?

Can anyone throw me a light on this stuff? Because being a java developer, I'm starting to feel really bad for not knowing what starts feel like a basic subject ...


I'm trying to better understand EJB3, and I need some info to sort some basic thoughts on my head.

I'm constructing a simple Statefull EJB with JSF as user interface.

It's a simple CalculatorBean that has a value property and some methods:
- operation (like add)
- getValue (returns the value property)

So On my jsf managed bean I'm accessing it remotely, like:

Still I need some knowledge glue to sort my thoughts out and continue working on this example:

1# If I'm accessing an EJB bean that is on the same machine, I should use the local interface right? So I would just inject "private CalculatorRemote calculator;" right?

2# Also, how does it work in JSF? I mean, first time I access the managed bean, it will instantiate the ejb instance and inject it, so I can use it safely ... but then the response is sent back to the user ... if the user fills a text field with a value to add, then clicks an add button, it will go to the managed bean again ... but won't it create a new instance and inject it again, loosing the previous state?

3# Another question, should I use my beans through local interface, if they (webapp and ejb) are packed in the same ear? Then, if one day I install the ejb package on a remote server, I have to re-engineer my app code to instance remote interfaces, am I right? If this is true, then what should be the best practice, to use remote calls from the start?


I'm using Struts 1.3.8 and I'm having a problem creating a localized link.

I'm using LookupDispatchAction as follows:

Then in my code I have the following:

My config:

My Properties:

Now everything works ok in english, because the link will be created with parameter "step=Search" and it will match the localized value retrieved in "getKeyMethodMap" method of the action.

Now if I change language to ES, I have a problem ... the link will still be generated as "step=Search" (it's hardcoded) but the "getKeyMethodMap" method of the action will retrieve "Busca", and so when I click, I receive an error 500:

Error 500: Action[/ScreenSearch] missing resource in key method map

So my question is, how can I use html:param with a value retrieved from localized resource properties of struts?

I mean, something like:

<html:param name="step" value="<bean:message key='jsp.screen_search.submit' />" />

So that it generates:

At this time, language ES will generate html like:

And I need something like:

11 years ago

I'm new to JMS and I'm trying to implement a JMS producer/consumer in Websphere 6.

My objective is to use standard J2EE specs, and end with a simple example, with no MDB around, just plain java objects.

So I created a a servlet that posts a message, then I have a timertask that queries the queue for any messages to process.

The process is simple, and it works fine, but I have a small issue:

I'm retrieving an instance of ConnectionFactory and Queue using the following code:

Although this works like a charm, I get the following warning on the console:

That also happened with datasources when I used the jndi name "jdbc/my-dbcon". I then started using "java:comp/env/jdbc/my-dbcon" and those datasource warnings vanished, but if I use "java:comp/env/jms/my-connection" I receive an error and it stops working. Something like "Error 500: Name comp/env/jdbc not found in context "java:".".

In my web.xml, I have the following data:

If I remove the resource-ref of "jms/my-connection", the JMS still works, as long as I don't prefix the jndi with "java:comp/env/". So it raises another question: do I really need the resource-ref definition there, if it still works without it?

(JMS works without ""java:comp/env/" prefixing, so I assume the JMS is configured properly on Websphere server.)

Any help on successfull JMS referencing using jndi "java:comp/env/" prefix would be great.