[Logo]
Forums Register Login
calling EJB in app server from servlet in webserver
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
 

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):
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
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.
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
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.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Dec 14, 2017 10:19:56.