Announcement Announcement Module
Collapse
No announcement yet.
problem with <jee:local-slsb> & <jee:remote-slsb> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem with <jee:local-slsb> & <jee:remote-slsb>

    I wrote a test EJb3 ear project to run on Jboss 6.
    I can't understand why <jee:xxxxxx-slsb> not work, could someone tell my how to resolve this problem?
    My application-context.xml is
    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
        ...>
        <jee:local-slsb id="storeLocal" jndi-name="StoreBean/local" business-interface="ejb3.bean.StoreLocal" resource-ref="false" 
            lookup-home-on-startup="true"/>
        <jee:remote-slsb id="sotreRemote" jndi-name="StoreBean/remote" business-interface="ejb3.bean.StoreRemote" resource-ref="false" 
            lookup-home-on-startup="true">
            <jee:environment>
                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                java.naming.provider.url=jnp://localhost:1399
            </jee:environment>
        </jee:remote-slsb>
    and it's my controller code
    Code:
    @Controller
    public class StoreController implements InitializingBean {
        private static Logger logger = LoggerFactory.getLogger(StoreController.class);
        @Autowired(required = false)
        @Qualifier("storeLocal")
        private StoreLocal storeLocal;
        @Autowired(required = false)
        @Qualifier("sotreRemote")
        private StoreRemote storeRemote;
    
        public void afterPropertiesSet() throws IllegalArgumentException, NamingException {
            logger.info("********************Autowired Local:{}:", storeLocal);
            if (storeLocal == null) {
                LocalStatelessSessionProxyFactoryBean lslsb = new LocalStatelessSessionProxyFactoryBean();
                lslsb.setBusinessInterface(StoreLocal.class);
                lslsb.setJndiName("StoreBean/local");
                lslsb.setResourceRef(false);
                lslsb.setLookupHomeOnStartup(true);
                lslsb.afterPropertiesSet();
                storeLocal = (StoreLocal) lslsb.getObject();
                logger.info("********************setupLocal:{}:", storeLocal);
            }
            logger.info("********************Autowired Remote:{}:", storeRemote);
            if (storeRemote == null) {
                SimpleRemoteStatelessSessionProxyFactoryBean sslsb = new SimpleRemoteStatelessSessionProxyFactoryBean();
                sslsb.setBusinessInterface(StoreRemote.class);
                sslsb.setJndiName("StoreBean/remote");
                sslsb.setLookupHomeOnStartup(true);
                sslsb.setResourceRef(false);
                Properties jndienv = new Properties();
                jndienv.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
                jndienv.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
                jndienv.put("java.naming.provider.url", "jnp://localhost:1099");
                sslsb.setJndiEnvironment(jndienv);
                sslsb.afterPropertiesSet();
                storeRemote = (StoreRemote) sslsb.getObject();
                logger.info("********************setup Remote:{}:", storeRemote);
            }
            logger.info("************************************");
        }
        ...
    }
    and output is
    Code:
    17:13:42,486 INFO  [STDOUT] 2012-06-13 17:13:42,486 [HDScanner] INFO  e.c.StoreController.afterPropertiesSet[38] - *****
    ***************Autowired Local:null:
    17:13:42,517 INFO  [STDOUT]
    17:13:42,548 INFO  [STDOUT] 2012-06-13 17:13:42,548 [HDScanner] INFO  e.c.StoreController.afterPropertiesSet[47] - *****
    ***************setup Local:Proxy to jboss.j2ee:jar=Ejb3-ejb-1.0-SNAPSHOT.jar,name=StoreBean,service=EJB3 implementing [in
    terface ejb3.bean.StoreLocal]:
    17:13:42,564 INFO  [STDOUT]
    17:13:42,580 INFO  [STDOUT] 2012-06-13 17:13:42,580 [HDScanner] INFO  e.c.StoreController.afterPropertiesSet[49] - *****
    ***************Autowired Remote:null:
    17:13:42,595 INFO  [STDOUT]
    17:13:42,736 INFO  [STDOUT] 2012-06-13 17:13:42,736 [HDScanner] INFO  e.c.StoreController.afterPropertiesSet[63] - *****
    ***************setup Remote:Proxy to jboss.j2ee:jar=Ejb3-ejb-1.0-SNAPSHOT.jar,name=StoreBean,service=EJB3 implementing [i
    nterface ejb3.bean.StoreRemote]:
    17:13:42,751 INFO  [STDOUT]
    17:13:42,767 INFO  [STDOUT] 2012-06-13 17:13:42,767 [HDScanner] INFO  e.c.StoreController.afterPropertiesSet[65] - *****
    *******************************
    Thnak you.

  • #2
    Enable debug logging and figure out why the beans aren't there. Make sure your EJBs are deployed also make sure that your xml file is loaded (I would have expected an exception if the lookup fails).

    Comment


    • #3
      Spring MVC, Problems try to call an EJB3

      Hi,
      I am new to EJB and Spring MVC development. My project configuration is:
      - an EJB 3 server application, deployed on JBoss (7.1.1 Final). This EJB project (called Distributed_Project_EJB.jar) is included into an EAR (called Distributed_Sys.ear).
      - a spring MVC web app client, deployed on Tomcat (7.0.37). This web app is NOT included into the Distributed_Sys.ear.

      Jboss and tomcat are on the same machine, and they listen on different ports. Finally, I use Eclipse Juno.
      When I start the JBoss server, it's all ok. In fact I see the following stack trace:

      JNDI bindings for session bean named SearchBean in deployment unit subdeployment "Distributed_Project_EJB.jar" of deployment "Distributed_Sys.ear" are as follows:

      Code:
       java:global/Distributed_Sys/Distributed_Project_EJB/SearchBean!sys_dist.SearchEngine.business.SearchInterface
          java:app/Distributed_Project_EJB/SearchBean!sys_dist.SearchEngine.business.SearchInterface
          java:module/SearchBean!sys_dist.SearchEngine.business.SearchInterface
          java:jboss/exported/Distributed_Sys/Distributed_Project_EJB/SearchBean!sys_dist.SearchEngine.business.SearchInterface
          java:global/Distributed_Sys/Distributed_Project_EJB/SearchBean
          java:app/Distributed_Project_EJB/SearchBean
          java:module/SearchBean

      Client side, I have a dynamic project with spring mvc. In order to call the EJB called SearchBean,
      I added to a springmvc-servlet.xml these lines:

      <jee:remote-slsb id="SearchInterface" jndi-name="ejbistributed_Sys/Distributed_Project_EJB/SearchBean"
      business-interface="sys_dist.SearchEngine.business.SearchIn terface">
      </jee:remote-slsb>

      Also I have a file called jboss-ejb-client.properties
      remote.connectionprovider.create.options.org.xnio. Options.SSL_ENABLED=false
      remote.connections=default
      remote.connection.default.host=localhost
      remote.connection.default.port = 4447
      remote.connection.default.connect.options.org.xnio .Options.SASL_POLICY_NOANONYMOUS=false

      but when I deploy it on Tomcat, I have this problem:
      Code:
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SearchInterface': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [ejb:Distributed_Sys/Distributed_Project_EJB/SearchBean] is not bound in this Context. Unable to find [ejb:Distributed_Sys].
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
      
      
      Caused by: javax.naming.NameNotFoundException: Name [ejb:Distributed_Sys/Distributed_Project_EJB/SearchBean] is not bound in this Context. Unable to find [ejb:Distributed_Sys].
          at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
          at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
          at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
          at javax.naming.InitialContext.lookup(Unknown Source)
          at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
          at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
          at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
          at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
          at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
          at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
          at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.lookup(AbstractRemoteSlsbInvokerInterceptor.java:100)
      Any suggestion?

      Thanks in advance
      Ele

      Comment

      Working...
      X