• 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

ctx.lookup of Session Bean from Messaging Bean

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
My environment: wsad 5.1.1 J2EE 1.3
I'm trying to run this scenario for test purpose:
Servlet -> Messaging Bean -> EJB Session bean
The servlet starts the the Messaging Bean using a Connection factory and queue.
In the web-deployment descriptor I have declared them as refererences.
This works fine.
I get the messaging bean to start, but then I get an exception in messaging bean
doing lockup for the Session Bean.
In the EJB deployment the 2 EJB beans are declared.
I'm confused over how I should do a lockup to the session bean from the messaging bean
1. Should I create a new InitialContext ?
Context ctx = new InitialContext();
2. I have tested with this:
Context ctx = new InitialContext();
String name = "ejb/jmstest/ValidationBeanLocalHome";
Object objref = ctx.lookup(name);

and this:
Context ctx = new InitialContext();
String name = "java:comp/env/ejb/jmstest/ValidationBeanLocalHome";
Object objref = ctx.lookup(name);

Help regarding this deeply appreciated.
..Per
======================= EJB Deployment ========================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar id="ejb-jar_ID">
<display-name>JMSTestEJB</display-name>
<enterprise-beans>
<session id="TestFacade">
<ejb-name>TestFacade</ejb-name>
<home>jmstest.TestFacadeHome</home>
<remote>jmstest.TestFacade</remote>
<local-home>jmstest.TestFacadeLocalHome</local-home>
<local>jmstest.TestFacadeLocal</local>
<ejb-class>jmstest.TestFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref id="ResourceRef_1080135215816">
<description></description>
<res-ref-name>jms/myQueueConnectionFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-env-ref id="ResourceEnvRef_1080132922692">
<description></description>
<resource-env-ref-name>jms/myQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
</session>
<message-driven id="TestMDB">
<ejb-name>TestMDB</ejb-name>
<ejb-class>jmstest.TestMDBBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
</message-driven>
<session id="ValidationBean">
<ejb-name>ValidationBean</ejb-name>
<local-home>jmstest.ValidationBeanLocalHome</local-home>
<local>jmstest.ValidationBeanLocal</local>
<ejb-class>jmstest.ValidationBeanBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
Web deployment descriptor ======================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="WebApp">
<display-name>JMSTestWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<resource-ref id="ResourceRef_1081168157808">
<res-ref-name>jms/MyConnectionFactoryRef</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref id="ResourceRef_1081168223965">
<res-ref-name>jms/MyQueueRef</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<ejb-local-ref id="EJBLocalRef_1080132757050">
<ejb-ref-name>ejb/myFacade</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>jmstest.TestFacadeLocalHome</local-home>
<local>jmstest.TestFacadeLocal</local>
<ejb-link>JMSTestEJB.jar#TestFacade</ejb-link>
</ejb-local-ref>
<ejb-local-ref id="EJBLocalRef_1081237979566">
<ejb-ref-name>ejb/myValidation</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>jmstest.ValidationBeanLocalHome</local-home>
<local>jmstest.ValidationBeanLocal</local>
<ejb-link>JMSTestEJB.jar#ValidationBean</ejb-link>
</ejb-local-ref>
</web-app>
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic