0 Replies Latest reply on Apr 16, 2009 12:25 PM by anx

    NameAlreadyBoundException: TransactionSynchronizationRegistr

      There is error during deploy of my ear into JBOSS 5.0.1 on 4.2.2 works fine:

      00:06:11,937 INFO [JBossASKernel] Created KernelDeployment for: ws-1.0.jar
      00:06:11,953 INFO [JBossASKernel] installing bean: jboss.j2ee:ear=app-1.0.ear,jar=ws-1.0.jar,name=MyWsImpl,service=EJB3
      00:06:11,953 INFO [JBossASKernel] with dependencies:
      00:06:11,953 INFO [JBossASKernel] and demands:
      00:06:11,953 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
      00:06:11,953 INFO [JBossASKernel] and supplies:
      00:06:11,953 INFO [JBossASKernel] Class:example.jboss5.ws.MyWs
      00:06:11,953 INFO [JBossASKernel] jndi:app-1.0/MyWsImpl/remote-example.jboss5.ws.MyWs
      00:06:11,984 INFO [JBossASKernel] jndi:app-1.0/MyWsImpl/remote
      00:06:11,984 INFO [JBossASKernel] Added bean(jboss.j2ee:ear=app-1.0.ear,jar=ws-1.0.jar,name=MyWsImpl,service=EJB3) to KernelDeployment of: ws-1.0.jar
      00:06:12,156 INFO [JBossASKernel] Created KernelDeployment for: ws2-1.0.jar
      00:06:12,156 INFO [JBossASKernel] installing bean: jboss.j2ee:ear=app-1.0.ear,jar=ws2-1.0.jar,name=MyWs2Impl,service=EJB3
      00:06:12,156 INFO [JBossASKernel] with dependencies:
      00:06:12,156 INFO [JBossASKernel] and demands:
      00:06:12,156 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
      00:06:12,156 INFO [JBossASKernel] and supplies:
      00:06:12,156 INFO [JBossASKernel] jndi:app-1.0/MyWs2Impl/remote
      00:06:12,156 INFO [JBossASKernel] jndi:app-1.0/MyWs2Impl/remote-example.jboss5.ws2.MyWs2
      00:06:12,156 INFO [JBossASKernel] Class:example.jboss5.ws2.MyWs2
      00:06:12,171 INFO [JBossASKernel] Added bean(jboss.j2ee:ear=app-1.0.ear,jar=ws2-1.0.jar,name=MyWs2Impl,service=EJB3) to KernelDeployment of: ws2-1.0.jar
      00:06:13,062 INFO [SessionSpecContainer] Starting jboss.j2ee:ear=app-1.0.ear,jar=ws-1.0.jar,name=MyWsImpl,service=EJB3
      00:06:13,078 INFO [EJBContainer] STARTED EJB: example.jboss5.ws.MyWsImpl ejbName: MyWsImpl
      00:06:13,218 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
      
       app-1.0/MyWsImpl/remote - EJB3.x Default Remote Business Interface
       app-1.0/MyWsImpl/remote-example.jboss5.ws.MyWs - EJB3.x Remote Business Interface
      
      00:06:13,421 INFO [SessionSpecContainer] Starting jboss.j2ee:ear=app-1.0.ear,jar=ws2-1.0.jar,name=MyWs2Impl,service=EJB3
      00:06:13,421 INFO [EJBContainer] STARTED EJB: example.jboss5.ws2.MyWs2Impl ejbName: MyWs2Impl
      00:06:13,453 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
      
       app-1.0/MyWs2Impl/remote - EJB3.x Default Remote Business Interface
       app-1.0/MyWs2Impl/remote-example.jboss5.ws2.MyWs2 - EJB3.x Remote Business Interface
      
      00:06:13,828 INFO [DefaultEndpointRegistry] register: jboss.ws:context=app-1.0-ws-1.0,endpoint=MyWsImpl
      00:06:19,187 INFO [WSDLFilePublisher] WSDL published to: file:/C:/andrey/work/app/jboss-5.0.1.GA/server/default/data/wsdl/app-1.0.ear/ws-1.
      0.jar/MyWsImplService61229.wsdl
      00:06:19,218 INFO [DefaultEndpointRegistry] register: jboss.ws:context=app-1.0-ws2-1.0,endpoint=MyWs2Impl
      00:06:19,671 INFO [WSDLFilePublisher] WSDL published to: file:/C:/andrey/work/app/jboss-5.0.1.GA/server/default/data/wsdl/app-1.0.ear/ws2-1
      .0.jar/MyWs2ImplService61231.wsdl
      00:06:21,281 INFO [MyService] Starting service ..............
      00:06:21,281 ERROR [MyService] javax.naming.NameNotFoundException: TransactionManager not bound
      00:06:21,281 INFO [MyService] Service started ..............
      00:06:21,296 INFO [TomcatDeployment] deploy, ctxPath=/app-1.0-ws-1.0
      00:06:21,390 WARN [config] Unable to process deployment descriptor for context '/app-1.0-ws-1.0'
      00:06:26,046 INFO [TomcatDeployment] deploy, ctxPath=/app-1.0-ws2-1.0
      00:06:26,109 ERROR [TomcatDeployment] ENC setup failed
      javax.naming.NameAlreadyBoundException: TransactionSynchronizationRegistry
       at org.jnp.server.NamingServer.bind(NamingServer.java:209)
       at org.jnp.interfaces.NamingContext.bind(NamingContext.java:646)
       at org.jnp.interfaces.NamingContext.bind(NamingContext.java:607)
       at org.jboss.web.tomcat.service.deployers.TomcatDeployment$EncListener.lifecycleEvent(TomcatDeployment.java:465)
       at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4388)
       at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:312)
       at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:144)
       at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
       at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
       at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
      
      


      This simple application contains two web services (ejb3 beans) and JBOSS service (sar) packaged into same ear.

      First ws:

      @Stateless
      @WebService
      public class MyWsImpl implements MyWs {
      
       private final Log log = LogFactory.getLog(getClass());
      
      
       public MyWsImpl() {
      
       }
      
      
       @WebMethod
       public String doWork() {
       log.info("web method 1");
       return "Web method 1";
       }
      }
      


      Second ws:

      @Stateless
      @WebService
      public class MyWs2Impl implements MyWs2 {
      
       private final Log log = LogFactory.getLog(getClass());
      
      
       public MyWs2Impl() {
      
       }
      
      
       @WebMethod
       public String doWork() {
       log.info("web method 2");
       return "Web method 2";
       }
      }
      


      JBOSS service:

      public class MyService extends ServiceMBeanSupport implements MyServiceMBean {
      
       private final Log log = LogFactory.getLog(getClass());
      
      
      
       public MyService() {
      
       }
      
       public String getAtt() {
       return "att";
       }
      
       public void setAtt(String s) {
      
       }
      
      
       protected void startService() throws Exception {
       log.info("Starting service ..............");
       lookup();
       log.info("Service started ..............");
       }
      
       protected void stopService() throws Exception {
       log.info("Service stopped..................");
       }
      
      
       private void lookup() {
       InitialContext c = null;
       try {
       String jndiName = "java:comp/TransactionManager";
       c = new InitialContext();
       Object o = c.lookup(jndiName);
      
       log.info("Found: " + o);
       } catch(Exception ex) {
       log.error(ex);
       } finally {
       if (c != null) {
       try {
       c.close();
       } catch (Exception ex) {
       //
       }
       }
       }
       }
      }
      


      jboss-service.xml:
       <mbean code="example.jboss5.svc.MyService" name="example.my:service=MyService">
      
       <depends>jboss:service=Naming</depends>
       <depends>jboss:service=WebService</depends>
      
       </mbean>
      


      The problem appears only when JBOSS service performs lookup of java:comp/TransactionManager (it's necessary for perform some DB initialization using JTA during startup of application). If method lookup() will be commented in startService web service will be deployed successfully.

      Any ideas on how to resolve it? Is it related to https://jira.jboss.org/jira/browse/JBAS-4445 ?