aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes calling EJB in app server from servlet in webserver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "calling EJB in app server from servlet in webserver" Watch "calling EJB in app server from servlet in webserver" New topic
Author

calling EJB in app server from servlet in webserver

clifford dias
Greenhorn

Joined: Apr 21, 2005
Posts: 4
Hi,
I've got a Servlet deployed in a Sun One 6.1 webserver. I've also got an EJB deployed in a Weblogic 7 server.

The servlet has the weblogic.jar in the WEB-INF lib folder. The EJB home interface is also in the WEB-INF lib folder.

When I call the servlet, I get the error EJBObject not found.

Does any one know if this is the right way to call the Bean ?

regards,
Cliff
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704

The servlet has the weblogic.jar in the WEB-INF lib folder.

Because your servlet is deployed on Sun One it makes no sense to include any weblogic specific deployment descriptors.

The EJB home interface is also in the WEB-INF lib folder.

Correct. Bean's home and remote interfaces must be there.

Does any one know if this is the right way to call the Bean ?

Within your servlet you must use a similar code as you�ll use calling the bean from a standalone client (ideally wrap this up using a service locator):


I think, therefore I exist -- Rene Descartes
clifford dias
Greenhorn

Joined: Apr 21, 2005
Posts: 4
Hi Valentin,
Thanks for your reply.

If I do not include the weblogic.jar, where will my servlet find the required ejb jars like EJBHome etc ?

regards,
Clifford
Sushil Deshpande
Greenhorn

Joined: Apr 21, 2005
Posts: 9
If you are not going to include the weblogic.jar in your app. lib you will get error while locating the Home interface through JNDI in code

Properties pNamingData=new Properties();
pNamingData.setProperty("java.naming.factory.initial","weblogic.jndi.WLInitialContextFactory" );
pNamingData.setProperty("java.naming.provider.url","t3://localhost:7001");

make sure that weblogic servershould run on port 7001 or edit the last line according to it.
After deployoing the EJb you must test it using the ADMIN Console.


Thanks and Regards, <br />Sushil Deshpande<br />E-Mail: dsushil2000@yahoo.com<br />"If you don�t know the destination, then it�s just useless to read the roadmap"
clifford dias
Greenhorn

Joined: Apr 21, 2005
Posts: 4
Hi Guys,
Thanks for your replies. I am lookin for an answer which will tell me if its possible to have a servlet deployed in Sun One webserver call an EJB in weblogic.

If it is possible, please can I have a description of how this should be done ?

I have used EJBs and I know that my EJB works fine, when called from a stand-alone client.

regards,
Clifford
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Clifford,


The servlet has the weblogic.jar in the WEB-INF lib folder. The EJB home interface is also in the WEB-INF lib folder.

I do apologies it looks like I read your message wrongly. I�ve confused weblogic.jar with weblogic.xml; and you right you need that library. I could also make you a suggestion: use wlclient.jar library, which will reduce the size of your war considerably. You might also consider adding this library to your server classpath since it might be used by many other applications. It's up to you.

I have used EJBs and I know that my EJB works fine, when called from a stand-alone client.

Then use absolutely the same code within your servlet. It must work.
And there is one more thing I�d like to add. Your initial error:

When I call the servlet, I get the error EJBObject not found.

Says that somehow your weblogic.jar library is not loaded (your code that looks up the bean might be correct though). However because you�ve installed it in WEB-INF/lib this should not happened and I�m very surprise to see that it doesn�t work. All I can suggest is to check your war again, eventually remove all temporary server files and redeploy it.
Regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling EJB in app server from servlet in webserver