File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Tomcat JNDI lookup on Weblogic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat JNDI lookup on Weblogic" Watch "Tomcat JNDI lookup on Weblogic" New topic
Author

Tomcat JNDI lookup on Weblogic

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9629
    
    2

Guys,

I have an EJB app running on Weblogic and I have a web application deployed in Tomcat. How can I configure Tomcat webapp to do a remote lookup to the EJB's in Weblogic. I get always a NamingException when I try to access my EJB's.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16308
    
  22

First of all, the EJBs have to include the remote interface. That used to be a given, but these days, it's worth mentioning! If you don't have the remote interface, there's no place for the Tomcat system to make its RMI EJB calls to.

Secondly, the Tomcat app has to address WebLogic's JNDI port in order to locate the EJB(s). More precisely, the conneciton has to be made to WebLogic's JNDI server, at the specified host and port locations. WebLogic doesn't use the default port ID for JNDI, so you have to specify it explicitly, just like Tomcat doesn't by default use http's default port (80) so you have to supply one explicitly (8080).

That's really about all there is to it. It's pretty well covered in the WebLogic documentation. The fact that the client is inside of Tomcat isn't any different than it would be for a stand-alone application except for maybe the need to set up a Properties object to hold JDNI config information since the normal command-line options aren't available.


Customer surveys are for companies who didn't pay proper attention to begin with.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9629
    
    2

Of course I meant the Remote Interface of my EJB's. In my startup.bat, I have the following configured:



and in my resources directory of my web app, I have the following in the jndi.properties:



What else do I need? When I tried to access my application, I got a NamingException as below:

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16308
    
  22

Well, everything looks good to me except for 2 possibilities. One is your JNDI properties. You've got it listed in file format, but you're going to need it as an actual properties object supplied explicitly when you do the JNDI lookup. Otherwise Tomcat's own internal JNDI is likely to override it.

If you've got that handled, the other possibility is that your resource name isn't correct. I believe the WebLogic console will display the actual JNDI name that the EJB's published under.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9629
    
    2

Tim Holloway wrote:Well, everything looks good to me except for 2 possibilities. One is your JNDI properties. You've got it listed in file format, but you're going to need it as an actual properties object supplied explicitly when you do the JNDI lookup. Otherwise Tomcat's own internal JNDI is likely to override it.

If you've got that handled, the other possibility is that your resource name isn't correct. I believe the WebLogic console will display the actual JNDI name that the EJB's published under.


The second possibility (resource name isn't correct) cannot be the case. Can you please throw some light on the first possibility? How can I get it as the Properties object explicitly in Tomcat?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16308
    
  22



You can also load properties using the Properties.load method, but that's not as useful in a webapp for short lists that aren't likely to change.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9629
    
    2

But where does this piece of code go?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10290
    
168

Joe Harry wrote:But where does this piece of code go?


Perhaps, com.web.user.client.service.impl.CustomerServiceClient.getCustomerFacade. I guess that's where you are using the InitialContext to do the lookup.

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat JNDI lookup on Weblogic