1 2 3 Previous Next 38 Replies Latest reply on Jun 2, 2004 6:12 AM by 807581

    JNDI failed to find ejb home

    807581
      Hi,

      I used jdbc-simple sample source code and mannually built the ejb jar file and web war file from command line. If I assemble the .jar and .war file into an ear file and deploy the ear file, it runs OK. However if I deploy the smae ejb jar file as a ejb module and the same war file as a web module separately, JNDI lookup will fail to find the ejb home.

      Does anyone know why?
      ===============
      [02/Jan/2003:21:48:31] INFO ( 780): CORE3282: stdout: GreeterDBServlet is executing...
      [02/Jan/2003:21:48:31] INFO ( 780): CORE3282: stdout: Retrieving JNDI initial context...
      [02/Jan/2003:21:48:31] SEVERE ( 780): StandardWrapperValve[GreeterDBServlet]: Servlet.service() for servlet GreeterDBServlet threw exception
      javax.servlet.ServletException: Servlet execution threw an exception
           at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:742)
           at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
           at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
           at java.security.AccessController.doPrivileged(Native Method)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
           at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
           at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
      ----- Root Cause -----
      java.lang.NoClassDefFoundError: samples.jdbc.simple.ejb.GreeterDBHome
           at samples.jdbc.simple.servlet.GreeterDBServlet.class$(GreeterDBServlet.java:57)
           at samples.jdbc.simple.servlet.GreeterDBServlet.doGet(GreeterDBServlet.java:56)
           at samples.jdbc.simple.servlet.GreeterDBServlet.doPost(GreeterDBServlet.java:153)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
           at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
           at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
           at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
           at java.security.AccessController.doPrivileged(Native Method)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
           at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
           at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
        • 1. Re: JNDI failed to find ejb home
          807581
          J2EE specs does not allow a war module to access a jar module directly. You can do the same by putting the client.jar in the classpath of server.xml. The location of client.jar is as follows for jdbc sample in my case. /var/opt/SUNWappserver7/domains/domain1/server1/applications/j2ee-modules/jdbc-simpleEjb_1/jdbc-simpleEjbClient.jar
          • 2. Re: JNDI failed to find ejb home
            807581
            Hi, Parsuram
            Thanks for the reply. That explained why. I found the client.jar, but I don't know which tag I should use to place the classpath in server.xml. Could you give an example?

            Thanks in advance.

            Sha
            • 3. Re: JNDI failed to find ejb home
              807581
              Sha,
              You need to modify the java-config tag.

              Here is an example.

              <java-config java-home="/opt/developerplatform/jdk/j2sdk1.4.0_02" server-classpath="/opt/developerplatform/ApplicationServer/lib/appserv-rt.jar:${java.home}/lib/tools.jar:/opt/developerplatform/ApplicationServer/lib/appserv-ext.jar:/opt/developerplatform/ApplicationServer/lib/appserv-cmp.jar:/usr/share/lib/mail.jar:/opt/developerplatform/ApplicationServer/lib/appserv-ideplugin.jar:/usr/share/lib/imq/imq.jar:/usr/share/lib/imq/jaxm-api.jar:/usr/share/lib/imq/imqadmin.jar:/usr/share/lib/imq/imqutil.jar:/opt/developerplatform/ApplicationServer/lib/appserv-admin.jar:/usr/share/lib/jaxrpc-impl.jar:/usr/share/lib/jaxrpc-api.jar:/usr/share/lib/jaxr-impl.jar:/usr/share/lib/jaxr-api.jar:/usr/share/lib/activation.jar:/usr/share/lib/saaj-api.jar:/usr/share/lib/saaj-impl.jar:/usr/share/lib/commons-logging.jar:/ur/share/lib/imq/fscontext.jar: /usr/share/lib/imq/providerutil.jar:/opt/developerplatfor /ApplicationServer/lib/appserv-jstl.jar" classpath-suffix="/opt/developerplatform/ApplicationServer/pointbase/client_tools/lib/pbclient42RE.jar" env-classpath-ignored="true" debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" debug-enabled="false" javac-options="-g" rmic-options="-iiop -poa -alwaysgenerate -keepgenerated -g">

              Add the path of client.jar in server-classpath. It will work.
              Thanks,
              -Parsu
              • 4. Re: JNDI failed to find ejb home
                807581
                Hi, Parsu,

                It works. Thanks a Lot for your help!

                Sha
                • 5. Re: JNDI failed to find ejb home
                  807581
                  Hi, Parsu,

                  In which chapter of J2EE Spec can I find the part that specifies war module or standalone client cannot access jar modules directly? I try to understand the reason for that.

                  Thanks.
                  Sha
                  • 6. Re: JNDI failed to find ejb home
                    807581
                    hi there ,
                    i had same problem - ive solved it with classpath change also but after that jndi returns some object and when i tried to cast it to destination by remote object narrow method it again fails - now on class cast exception

                    thanks for any response
                    • 7. Re: JNDI failed to find ejb home
                      807581
                      Will you give the expection stack trace and your code which causes the exception.

                      Thanks,
                      -Parsu
                      • 8. Re: JNDI failed to find ejb home
                        807581
                        hi there,

                        ok - ive added C:\labserver\labdomain\labinstance\applications\j2ee-modules\stateless-simpleEjb_1\stateless-simpleEjbClient.jar into the server class path.
                        (this ejb is part of so7 samples - samples/ejb/stateless/simple/ it has been packaged into jar and deployed only as ejb module not as enter. aplication module)


                        now im trying to access this ejb module from the servlet from web aplication module

                        1) from the jndi retreiving this object reference:
                        objref = com.sun.jndi.cosnaming.CNCtx@6a4a67

                        2)after that im trying to call narrow method
                        myGreeterHome = (GreeterHome)PortableRemoteObject.narrow(objref, GreeterHome.class);

                        and got this exceptions trace:

                        INFO: CORE3282: stdout: Retrieving JNDI initial context
                        INFO: CORE3282: stdout: Looking up greeter bean home interface
                        INFO: CORE3282: stdout: Looking up: java:comp/env/ejb/greeter
                        INFO: CORE3282: stdout: objref = com.sun.jndi.cosnaming.CNCtx@136c55
                        WARNING: CORE3283: stderr: java.lang.ClassCastException
                        WARNING: CORE3283: stderr: at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.
                        java:293)
                        WARNING: CORE3283: stderr: at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
                        WARNING: CORE3283: stderr: at com.cleverlance.j2me.labserver.TestServlet.doGet(TestServlet.java:45)
                        WARNING: CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
                        WARNING: CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                        WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperVal
                        ve.java:720)
                        WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:11
                        8)
                        WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
                        WARNING: CORE3283: stderr: at java.security.AccessController.doPrivileged(Native Method)
                        WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
                        WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                        WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
                        WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                        WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
                        WARNING: CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                        WARNING: CORE3283: stderr: at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
                        WARNING: CORE3283: stderr: at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)

                        if i do this in the deployed ear module its working properly

                        thanks u much for your behalf

                        YF


                        • 9. Re: JNDI failed to find ejb home
                          807581
                          Hi,

                          I am also getting same problem after including client.jar in server classpath. What did you do in ear file to solve the problem?

                          Thanks
                          • 10. Re: JNDI failed to find ejb home
                            807581
                            Other way is, instead of putting jdbc-simpleEjbClient.jar file in the server.xml you should copy it in to lib directory of web module.
                            It will work fine. Putting client jar file in server.xml may not be a correct way.

                            Thanks,
                            Deepak
                            • 11. Re: JNDI failed to find ejb home
                              807581
                              You may still have a copy of client interfaces in your web module classes.
                              Please follow these steps it should work fine..
                              1. Deploy jar module..
                              2. Remove all classes of ejb-interface if you have in web module. Copy stateless-simpleEjbClient.jar file into lib directory of your web module.
                              3. deploy war module.
                              It should work fine..

                              HTH
                              Deepak
                              • 12. Re: JNDI failed to find ejb home
                                807581
                                Hi Deepak,

                                Problem solved after removing ejb class files from war module

                                Thanks
                                • 13. Re: JNDI failed to find ejb home
                                  807581
                                  Great enjooooy SunONE.....
                                  • 14. Re: JNDI failed to find ejb home
                                    807581
                                    hi deepak,

                                    i have a similar problem. I am getting java.lang.classCastexception.

                                    i am using an Stateless SB. i have local & local home interfaces.i followed instructions given in previous message. i removed all classpaths pointing to the ejb's from server.xml. & other classpaths. I just have the ejbjar in the WEB-INF folder of the war.

                                    i still get the same classcast exception.

                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr: java.lang.ClassCastException: com.sun.jndi.cosnaming.CNCtx
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at com.iflex.kmt.Action.ActionEvaluateOnlineTest.perform(Unknown Source)
                                    [06/Mar/2003:01:13:00] INFO ( 1148): CORE3282: stdout: Looking up: java:comp/env/ejb/EvaluateAnswers
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1787)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at java.security.AccessController.doPrivileged(Native Method)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
                                    [06/Mar/2003:01:13:00] WARNING ( 1148): CORE3283: stderr:      at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
                                    [06/Mar/2003:01:13:00] FINE ( 1148): jsp: init
                                    1 2 3 Previous Next