• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling EJB in app server from servlet in webserver

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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):
 
clifford dias
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
clifford dias
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic