4 Replies Latest reply on Oct 29, 2009 11:04 PM by zhodges

    JNDI lookup problem in weblogic 10.3 with EJB3

    hsiung

      I get an exception when the Seam calls my session bean


      I use Seam 2.1.1, Weblogic 10.3 and EJB3.



      javax.naming.NameNotFoundException:
      While trying to lookup 'wsRepository-ear.ServiceRegistrationBean/local'
      didn't find subcontext 'wsRepository-ear'.
      Resolved '';
      remaining name 'wsRepository-ear/ServiceRegistrationBean/local' at
      weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)



      components.xml:


         <core:init debug="true" jndi-pattern="@jndiPattern@"/>
      
         <core:manager concurrent-request-timeout="500"
                       conversation-timeout="120000"
                       conversation-id-parameter="cid"
                       parent-conversation-id-parameter="pid"/>
      
         <web:hot-deploy-filter url-pattern="*.seam"/>
         
         <persistence:managed-persistence-context name="entityManager"
         auto-create="true"
         entity-manager-factory="#{wsRepositoryEntityManagerFactory}"/>
      
         <persistence:entity-manager-factory name="wsRepositoryEntityManagerFactory"
         persistence-unit-name="wsRepository"/>
      



      components.properties:


      jndiPattern=wsRepository-ear/\#{ejbName}/local
      embeddedEjb=false
      




      any ideas?

        • 1. Re: JNDI lookup problem in weblogic 10.3 with EJB3
          gonorrhea

          components.properties:


          jndiPattern \#{ejbName}/local



          This is the default setting.  Why aren't you using this?

          • 2. Re: JNDI lookup problem in weblogic 10.3 with EJB3
            hsiung

            thanks, I tried components.properties:


            jndiPattern=\#{ejbName}/local
            embeddedEjb=false
            



            But I still get an exception.


            javax.naming.NameNotFoundException:
            While trying to lookup 'ServiceRegistrationBean.local'
            didn't find subcontext 'ServiceRegistrationBean'.
            Resolved ''; remaining name 'ServiceRegistrationBean/local'
            



            The original components.properties (generated during the creation of the Seam project) was:


            jndiPattern=wsRepository-ear/\#{ejbName}/local
            



            But you're right, in the samples, the jndiPattern is like you mentioned.


            Anyway, both options are not working in Weblogic 10.3.


            I also tried to delete the components.properties and the entry in components.xml


               <!-- core:init debug="true" jndi-pattern="@jndiPattern@"/-->
            



            Hoping that some defaults are working,
            but I got an exception:


            java.lang.IllegalArgumentException: You must specify org.jboss.seam.core.init.jndiPattern or use @JndiName: serviceRegistration
            



            So I have to specify a jndi-pattern, but which one???


            Any good idea?



            • 3. Re: JNDI lookup problem in weblogic 10.3 with EJB3
              cedneve.cedric.neve.oniryx.be

              Hello,


              Late answer but I just stumbled upon this problem myself so I can maybe help you out for further reference:
              You need to add a reference to your EJBs in your web.xml, as explained here: http://seamframework.org/Community/JNDIForSessionBeansInWeblogic103


              However, once this is done, it helps resolving those EJBs from the pages but it does not help when an internal reference is made between EJBs (for example @In private MyOtherEJB).


              I am still trying to find a solution for those...

              • 4. Re: JNDI lookup problem in weblogic 10.3 with EJB3
                zhodges

                Even later answer, but hopefully this will help someone...


                To use Seam injection for EJBs in Weblogic 10.3 use the @EJB annotation at the class level like so (use @EJBs for multiple):


                @EJB(name="ejb/MyServiceBean/local", beanName="MyServiceBean", beanInterface=MyService.class)
                public class MyOtherServiceBean.... {
                
                    @In(create=true)
                    private MyService myService;
                }
                



                Where ejb/MyServiceBean/local is the JNDI path you're binding to.
                For example the above will be available at:
                java:comp/env/ejb/MyServiceBean/local



                Note: this can really be anything, but this is a decent convention.



                This creates a name in the current EJB's namespace to reference the EJB with the bean name of MyServiceBean.  The beanInterface says which interface to use, local or remote...


                The same effect can be achieved using the ejb-jar.xml and weblogic-ejb-jar.xml, but this is simpler.


                Also, set in your component.xml:


                <core:init jndi-pattern="java:comp/env/ejb/#{ejbName}/local"/>
                



                Hope that helps.