3 Replies Latest reply on Jan 4, 2007 10:35 PM by Daniel Young

    Service Beans in Embeddable EJB 3.0?

    jantzen Newbie

      I am trying to use the Embeddable EJB 3.0 server for running unit tests. I've gotten MDB, Entity, and Stateless beans to load and become accessible via JNDI. However, I cannot locate my Service beans via JNDI, and I'm inclined to believe they aren't being started. The documentation suggests Service beans will work:

      http://docs.jboss.org/ejb3/embedded/embedded.html

      But I see an exception when I try to look one up:

      local not bound
      javax.naming.NameNotFoundException: local not bound


      Anyone know of a workaround?

      Thanks,
      Jantzen

        • 1. Re: Service Beans in Embeddable EJB 3.0?
          Daniel Young Novice

          Hi there,

          If your EJBs are being started you will see it in your logs, something similar to what I've got here:

          DEBUG 03-01 15:00:33,895 (Ejb3AnnotationHandler.java:getContainers:158) -found EJB3: ejbName=LookupActionBean, class=LookupActionBean, type=STATELESS
          DEBUG 03-01 15:00:33,906 (ProxyDeployer.java:initializeRemoteBindingMetadata:131) -no declared remote bindings for : LookupActionBean
          DEBUG 03-01 15:00:33,925 (Ejb3DescriptorHandler.java:addClassAnnotation:1686) -adding class annotation org.jboss.annotation.internal.DefaultInterceptorMarker to LookupServiceBean org.jboss.annotation.internal.DefaultInterceptorMarkerImpl@2d95b3
          DEBUG 03-01 15:00:33,926 (Ejb3DescriptorHandler.java:addClassAnnotation:1688) -adding class annotation org.jboss.annotation.internal.DefaultInterceptorMarker to LookupServiceBean org.jboss.annotation.internal.DefaultInterceptorMarkerImpl@2d95b3
          DEBUG 03-01 15:00:33,928 (Ejb3DescriptorHandler.java:addClassAnnotation:1686) -adding class annotation javax.annotation.security.DeclareRoles to LookupServiceBean org.jboss.ejb.DeclareRolesImpl@bf5555
          DEBUG 03-01 15:00:33,928 (Ejb3DescriptorHandler.java:addClassAnnotation:1688) -adding class annotation javax.annotation.security.DeclareRoles to LookupServiceBean org.jboss.ejb.DeclareRolesImpl@bf5555
          


          When I have the above bean, I can look it up from a unit test as:
          bean = (LookupAction) ctx.lookup("LookupActionBean/local");
          


          Check that your unit tests run with the following jndi.properties in the classpath, or specified when you get your initial context:
          java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
          java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
          



          • 2. Re: Service Beans in Embeddable EJB 3.0?
            jantzen Newbie

            HI Jazir,

            I've got the naming properties you describe in place, and I'm looking up stateless beans with the kind of JNDI name you're describing. I'm not sure where EJB Embedded writes its logs though. Which logfile are you looking at?

            Thanks

            • 3. Re: Service Beans in Embeddable EJB 3.0?
              Daniel Young Novice

              Hi again,

              Mine is going to System.out, as configured in the log4j.xml in my ejb3-embedded/conf directory (which is in my classpath when I run the tests).

              <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
               <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
               <param name="Target" value="System.out"/>
               <param name="Threshold" value="ALL"/>
              
               <layout class="org.apache.log4j.PatternLayout">
               <!-- The default pattern: Date Priority [Category] Messagen -->
               <!--
               <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
               -->
               <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>
               </layout>
              </appender>
              
               <root>
               <appender-ref ref="CONSOLE"/>
               </root>