5 Replies Latest reply on Mar 23, 2006 11:37 PM by eielk

    configuring spring to wire in ejb3 stateless session bean

    eielk

      since i can't use @ejb yet, and i don't want to litter the initial context throughout my code (old school), i figured i'd use spring to wire my ejb3 stateless session bean to my action but i just get the following error:

      23:46:21,310 ERROR [[action]] Servlet.service() for servlet action threw exception
      java.lang.reflect.UndeclaredThrowableException
       at $Proxy79.addTest(Unknown Source)
       at com.gwig.struts.action.TestAction.execute(TestAction.java:60)
      


      ...where .addTest is my stateless session bean method.

      here is my spring config-pretty basic:

       <bean id="testStatelessService" class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiName" value="gwig/TestSLSBLocal"/>
       <property name="resourceRef" value="true"/>
       <property name="proxyInterface" value="com.gwig.ejb.TestSLSBIF"/>
       <property name="lookupOnStartup" value="false"/>
       </bean>
      


      this SLSB lookup works fine using the traditional initial context lookup stuff.
      does the injection work with spring for ejb3's on jboss? has anyone done this? i'm using 4.0.4rc1...



        • 1. Re: configuring spring to wire in ejb3 stateless session bea
          asack

          Have you tried to use the JBoss Spring deployer that allows you to inject EJB's via the @Spring notation?

          • 2. Re: configuring spring to wire in ejb3 stateless session bea
            bill.burke

            What is the cause exception please.

            • 3. Re: configuring spring to wire in ejb3 stateless session bea
              eielk

              looks i didn't look down into the root exception: NameNotFoundException, do i need to prefix this if using spring, here is a snippet of the global jndi listing also...

              thanks.

              21:12:35,456 WARN [RequestProcessor] Unhandled Exception thrown: class java.lang.reflect.Undec
              laredThrowableException
              21:12:35,456 ERROR [[action]] Servlet.service() for servlet action threw exception
              java.lang.reflect.UndeclaredThrowableException
               at $Proxy79.addTest(Unknown Source)
               at com.gwig.struts.action.TestAction.execute(TestAction.java:60)
               at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.j
              ava:106)
              
              ...
              
              Caused by: javax.naming.NameNotFoundException: gwig not bound
               at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
               at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
               at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
               at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
               at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:716)
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
               at javax.naming.InitialContext.lookup(InitialContext.java:351)
               at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:123)
               at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
               at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:121)
               at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:146)
               at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:86)
               at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:104)
               at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.jav
              a:121)
               at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:
              150)
               ... 28 more
              


              +- gwig (class: org.jnp.interfaces.NamingContext)
               | +- TestSLSBLocal (proxy: $Proxy77 implements No ClassLoaders found for: com.gwig.ejb.TestSLSBIF (no security manager: RMI class loader disabled))
               | +- TestSFSBLocalStatefulProxyFactory (class: org.jboss.ejb3.stateful.StatefulLocalProxyFactory)
               | +- TestSFSBLocal (class: java.lang.Object)
              


              • 4. Re: configuring spring to wire in ejb3 stateless session bea
                eielk

                asack, thanks for the hint for the spring deployer...i'll check it out, will it work with struts action injection using the plugin in struts-config.xml?

                <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
                <set-property property="contextConfigLocation" value="properties/applicationContext.xml"/>
                 </plug-in>
                


                • 5. Re: configuring spring to wire in ejb3 stateless session bea
                  eielk

                  figured it out... i simply removed the 'resourceRef' property from the JNDIObjectFactory bean config!!!

                  according to the spec about resource ref: it adds the java:comp crap at the beginning of the jndi lookup, no wonder it couldn't find the beans.

                  resourceRef - if the lookup occurs in a J2EE container, i.e. if the prefix "java:comp/env/" needs to be added if the JNDI name doesn't already contain it.