File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Possible JNDI issue with JBoss and TIBCO EMS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Possible JNDI issue with JBoss and TIBCO EMS" Watch "Possible JNDI issue with JBoss and TIBCO EMS" New topic
Author

Possible JNDI issue with JBoss and TIBCO EMS

Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 160

Hi Folks

I haven't posted on JavaRanch in quite a while, but I'm struggling with an issue that has me stumped.

My team is in the process of migrating an application from WebLogic to JBoss 6. The bulk of the work is done, but JMS is still giving us some pains. We have code that looks up a TIBCO EMS connection factory via JNDI. The factory is set up as per the specifications in section 1 of this page. In some places, we try to access queues and in other places we try to access topics. Unfortunately, I cannot post the actual code, since it is sitting on my machine at the office. Nonetheless, I figured that I'd try my luck posting here.

We look up the TIBCO connection factory via JNDI, and cast it to the appropriate type (QueueConnectionFactory or TopicConnectionFactory). This lookup always succeeds, regardless of what we cast the resulting object to (my understanding is that the factory should implement both the QueueConnectionFactory and TopicConnectionFactory interfaces). We then create a QueueConnection/TopicConnection and the relevant type of session using the factory. Then, we send/publish a message to the relevant queue or topic. The code is very similar to the below (my apologies, but like I said, I don't have the actual code available right now).



The (very odd) issue that the method that is called first always seems to work (regardless of whether it uses a queue or a topic), whereas the second method always fails. If the order of the method is switched around, whichever one is called first still works, while the second one then fails. The cause of this, based on the JBoss logs, seems to be that JBoss gives us a factory for the first lookup and then keeps the type of the factory when the second lookup is done. So, even though the factory that we look up should provide both a queue connection factory and a topic connection factory, the session that is returns is only valid for whichever is created first. It throws an exception (just like the code, I don't have the full stack trace handy right now, but I think it's an InvalidDestinationException or an IllegalArgumentException) with either "topic session" or "queue session" as the message. The method calls are made from a session bean that is invoked from a servlet. The issue occurs when the session beans calls both methodA() and methodB() from the method called by the servlet (i.e. in the same container transaction). Please correct me if anything I'm saying comes across as nonsense.

Any thoughts on why this would happen? My JNDI knowledge isn't perfect, so I'm not sure if it is JNDI related. Are objects cached when you look them up via JNDI? I want to try and see if I can use the TIBCO specific context to look up the individual queue and topic connection factories directly. In the meantime, I was hoping that someone will be able to shed some light on the issue.

Cheers,
Riaan


"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw
Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 160

I should also point out the the application is deployed as an EAR file. The EAR contains, among other things, the JAR with the session bean in it and a WAR containing the servlet. If I copy and paste both of these methods into a servlet and execute them from there, it works perfectly - I can only see the issue happening in a session bean.
Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 160

Solved; you can find the solution here.
 
jQuery in Action, 2nd edition
 
subject: Possible JNDI issue with JBoss and TIBCO EMS