7 Replies Latest reply on Nov 6, 2013 10:13 AM by Scott Marlow

    How to use multiple data sources

    Domen Petric Newbie

      Hi,

      I am working on application where i need read and write in two DBs. I am using JBoss 7.1.1.

       

       

      My datasources in standalone.xml:

       

      <datasources>
           <datasource jndi-name="java:jboss/datasources/MysqlDS" pool-name="MySqlDS" enabled="true" use-java-context="true">
                <connection-url>jdbc:mysql://localhost:3306/SERVICES?useUnicode=true&amp;characterEncoding=UTF-8</connection-url>
                <driver>mysql</driver>
                <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                <pool>
                     <min-pool-size>1</min-pool-size>
                     <max-pool-size>10</max-pool-size>
                     <prefill>true</prefill>
                </pool>
                <security>
                     <user-name>username</user-name>
                </security>
                <statement>
                     <prepared-statement-cache-size>32</prepared-statement-cache-size>
                     <share-prepared-statements>true</share-prepared-statements>
                </statement>
           </datasource>
           <datasource jndi-name="java:jboss/datasources/domeneDS" pool-name="domeneDS" enabled="true" use-java-context="true">
                <connection-url>jdbc:mysql://localhost:3306/DOMENE?useUnicode=true&amp;characterEncoding=UTF-8</connection-url>
                <driver>mysql</driver>
                <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                <pool>
                     <min-pool-size>1</min-pool-size>
                     <max-pool-size>10</max-pool-size>
                     <prefill>true</prefill>
                </pool>
                <security>
                     <user-name>username</user-name>
                </security>
                <statement>
                     <prepared-statement-cache-size>32</prepared-statement-cache-size>
                     <share-prepared-statements>true</share-prepared-statements>
                </statement>
           </datasource>
      </datasources>
      

       

       

      My persistance.xml file:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="2.0"
         xmlns="http://java.sun.com/xml/ns/persistence" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
              http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
              <persistence-unit  name="domainDS">
                  <jta-data-source>java:jboss/datasources/domeneDS</jta-data-source>
                  <properties>
                      <property name="hibernate.hbm2ddl.auto" value="validate" />
                      <property name="hibernate.show_sql" value="true" />
                      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
                  </properties>
             </persistence-unit>
             <persistence-unit  name="services">
                 <provider>org.hibernate.ejb.HibernatePersistence</provider>
                 <jta-data-source>java:jboss/datasources/MysqlDS</jta-data-source>
                 <properties>
                     <property name="hibernate.hbm2ddl.auto" value="validate" />
                     <property name="hibernate.show_sql" value="true" />
                     <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
                 </properties> 
              </persistence-unit>
      </persistence>
      

       

       

      my MyBean:

       

      @Named
      @Stateless
      @TransactionManagement(TransactionManagementType.CONTAINER)
      public class MyBean implements Serializable {
      
          private static final long serialVersionUID = 1211342899562731565L;
      
          @PersistenceContext(unitName = "domainDS", name = "domene")
          private EntityManager em;
      
          @PersistenceContext(unitName = "services", name = "servisi")
          private EntityManager ems;
      
      
           public void doSomenthing() {
              Query q = em.createQuery("....");
           }
      
      
      

      My problem:

      Server starts as usual but when MyBean is called i got null pointer exception on em, same on ems. Same happens with all the other beans.

       

      If you have any advice please let me know

       

      Thanks in advance.

        • 1. Re: How to use multiple data sources
          Tomaz Cerar Master

          Hi,

           

          can you post stacktrace that is happening?

           

          also how does packaging of you application look like?

           

          --

          tomaz

          • 2. Re: Re: How to use multiple data sources
            Domen Petric Newbie

            it's ear with one ejb and one war package

             

            12:14:06,723 ERROR [org.jboss.ejb3.invocation] (http-localhost-127.0.0.1-8080-1) JBAS014134: EJB Invocation failed on component Login for method public java.lang.String si.arctur.controller.Login.login(java.lang.String,java.lang.String): javax.ejb.EJBException: java.lang.NullPointerException
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at si.arctur.controller.Login$$$view1.login(Unknown Source) [domene-ejb-1.0-SNAPSHOT.jar:]
                at si.arctur.controller.LoginBean.login(LoginBean.java:52)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
                at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
                at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
                at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
                at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148)
                at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
                at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
                at javax.faces.component.UICommand.broadcast(UICommand.java:300)
                at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
                at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
                at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_25]
            Caused by: java.lang.NullPointerException
                at si.arctur.controller.Login.login(Login.java:65) [domene-ejb-1.0-SNAPSHOT.jar:]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                ... 56 more
            
            12:14:06,747 SEVERE [javax.faces.event] (http-localhost-127.0.0.1-8080-1) Received 'javax.ejb.EJBException' when invoking action listener '#{loginBean.login}' for component 'loginButton'
            12:14:06,748 SEVERE [javax.faces.event] (http-localhost-127.0.0.1-8080-1) javax.ejb.EJBException: java.lang.NullPointerException
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166)
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230)
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
                at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)
                at si.arctur.controller.Login$$$view1.login(Unknown Source)
                at si.arctur.controller.LoginBean.login(LoginBean.java:52)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
                at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39)
                at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
                at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
                at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148)
                at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
                at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
                at javax.faces.component.UICommand.broadcast(UICommand.java:300)
                at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
                at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
                at java.lang.Thread.run(Unknown Source)
            Caused by: java.lang.NullPointerException
                at si.arctur.controller.Login.login(Login.java:65)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374)
                at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127)
                at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135)
                at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
                at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
                ... 56 more
            
            12:14:06,760 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (http-localhost-127.0.0.1-8080-1) JSF1073: javax.faces.event.AbortProcessingException caught during processing of INVOKE_APPLICATION 5 : UIComponent-ClientId=Loginform:loginButton, Message=/login.xhtml @20,120 actionListener="#{loginBean.login}": javax.ejb.EJBException: java.lang.NullPointerException
            12:14:06,761 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (http-localhost-127.0.0.1-8080-1) /login.xhtml @20,120 actionListener="#{loginBean.login}": javax.ejb.EJBException: java.lang.NullPointerException: javax.faces.event.AbortProcessingException: /login.xhtml @20,120 actionListener="#{loginBean.login}": javax.ejb.EJBException: java.lang.NullPointerException
                at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:182) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                at javax.faces.component.UICommand.broadcast(UICommand.java:300) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
                at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
                at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_25]
            Caused by: javax.ejb.EJBException: java.lang.NullPointerException
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at si.arctur.controller.Login$$$view1.login(Unknown Source) [domene-ejb-1.0-SNAPSHOT.jar:]
                at si.arctur.controller.LoginBean.login(LoginBean.java:52) [classes:]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]
                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]
                at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
                at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
                at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]
                at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                ... 25 more
            Caused by: java.lang.NullPointerException
                at si.arctur.controller.Login.login(Login.java:65) [domene-ejb-1.0-SNAPSHOT.jar:]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
                at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                ... 56 more
            
            
            
            • 3. Re: How to use multiple data sources
              Scott Marlow Master

              What happens when you deploy on the latest WildFly 8 (nightly) build (link is here)? 

               

              If you still get the NullPointerException, you can show us the output from "jar tf YourEarName.ear" and also TRACE logging output for org.jboss.as.jpa (see documentation here.)

              • 4. Re: How to use multiple data sources
                Tomaz Cerar Master

                How does your deployment look like?

                 

                ejb-jar? war? ear?

                do you have beans.xml? do you have ejb-jar.xml? and if so where?

                • 5. Re: How to use multiple data sources
                  Radim Hanus Expert

                  just to warn you in advance when you solve NPE problem you will propably face this one:

                  ARJUNA012140: Adding multiple last resources is disallowed

                  because it's possible to enlist only single non-xa datasource in a transaction

                  • 6. Re: How to use multiple data sources
                    Domen Petric Newbie

                    hi

                    sorry for long delay

                     

                    I am interesting if there is any workaround for that bug in jboss 7.1.1

                     

                    I installed WildFly, changed standalone.xml. Now server won't start.

                    15:40:28,083 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 28) JBAS014613: Operation ("add") failed - address: ([
                        ("subsystem" => "datasources"),
                        ("jdbc-driver" => "mysql")
                    ]) - failure description: "JBAS010441: Failed to load module for driver [com.mysql]"
                    15:40:28,097 INFO  [org.jboss.as.naming] (MSC service thread 1-3) JBAS011802: Starting Naming Service
                    15:40:28,099 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-4) JBAS015400: Bound mail session [java:jboss/mail/Default]
                    15:40:28,197 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
                    15:40:28,198 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-11) JBAS010417: Started Driver service with driver-name = h2
                    15:40:28,337 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 49) JBAS017527: Creating file handler for path D:\arctur\wildfly-8.0.0.Beta2-SNAPSHOT/welcome-content
                    15:40:28,404 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017525: Started server default-server.
                    15:40:28,415 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017531: Host domene starting
                    15:40:28,416 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-12) JBAS017531: Host default-host starting
                    15:40:28,472 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017519: Undertow HTTP listener default listening on localhost/127.0.0.1:8080
                    15:40:28,706 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-10) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
                    15:40:28,755 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "domene-ear.ear" (runtime-name: "domene-ear.ear")
                    15:40:28,759 INFO  [org.jboss.as.remoting] (MSC service thread 1-11) JBAS017100: Listening on 127.0.0.1:9999
                    15:40:28,773 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) JBAS015012: Started FileSystemDeploymentService for directory D:\arctur\wildfly-8.0.0.Beta2-SNAPSHOT\standalone\deployments
                    15:40:28,807 INFO  [org.jboss.ws.common.management] (MSC service thread 1-14) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.2.Final
                    15:40:29,128 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "null" (runtime-name: "domene-ejb-1.0-SNAPSHOT.jar")
                    15:40:29,128 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "null" (runtime-name: "domene-web-1.0-SNAPSHOT.war")
                    15:40:29,691 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011401: Read persistence.xml for domainDS
                    15:40:29,691 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011401: Read persistence.xml for services
                    15:40:29,757 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-10) MSC000001: Failed to start service jboss.deployment.subunit."domene-ear.ear"."domene-ejb-1.0-SNAPSHOT.jar".DEPENDENCIES: org.jboss.msc.service.StartException in service jboss.deployment.subunit."domene-ear.ear"."domene-ejb-1.0-SNAPSHOT.jar".DEPENDENCIES: JBAS018733: Failed to process phase DEPENDENCIES of subdeployment "domene-ejb-1.0-SNAPSHOT.jar" of deployment "domene-ear.ear"
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1944) [jboss-msc-1.2.0.Beta2.jar:1.2.0.Beta2]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1877) [jboss-msc-1.2.0.Beta2.jar:1.2.0.Beta2]
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_25]
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_25]
                        at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_25]
                    Caused by: java.lang.IllegalArgumentException: JBAS011470: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment subdeployment "domene-ejb-1.0-SNAPSHOT.jar" of deployment "domene-ear.ear".  Either change the application deployment to have only one persistence unit definition or specify the unitName for each reference to a persistence unit.
                        at org.jboss.as.jpa.container.PersistenceUnitSearch.ambiguousPUError(PersistenceUnitSearch.java:187)
                        at org.jboss.as.jpa.container.PersistenceUnitSearch.findWithinDeployment(PersistenceUnitSearch.java:153)
                        at org.jboss.as.jpa.container.PersistenceUnitSearch.findPersistenceUnitSupplier(PersistenceUnitSearch.java:75)
                        at org.jboss.as.jpa.container.PersistenceUnitSearch.resolvePersistenceUnitSupplier(PersistenceUnitSearch.java:64)
                        at org.jboss.as.jpa.processor.JPAAnnotationProcessor.getPersistenceUnit(JPAAnnotationProcessor.java:369)
                        at org.jboss.as.jpa.processor.JPAAnnotationProcessor.getBindingSource(JPAAnnotationProcessor.java:293)
                        at org.jboss.as.jpa.processor.JPAAnnotationProcessor.processField(JPAAnnotationProcessor.java:171)
                        at org.jboss.as.jpa.processor.JPAAnnotationProcessor.processPersistenceAnnotations(JPAAnnotationProcessor.java:138)
                        at org.jboss.as.jpa.processor.JPAAnnotationProcessor.deploy(JPAAnnotationProcessor.java:100)
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]
                        ... 5 more
                    
                    15:40:29,762 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "domene-ear.ear")]) - failure description: {
                        "JBAS014671: Failed services" => {"jboss.deployment.subunit.\"domene-ear.ear\".\"domene-ejb-1.0-SNAPSHOT.jar\".DEPENDENCIES" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"domene-ear.ear\".\"domene-ejb-1.0-SNAPSHOT.jar\".DEPENDENCIES: JBAS018733: Failed to process phase DEPENDENCIES of subdeployment \"domene-ejb-1.0-SNAPSHOT.jar\" of deployment \"domene-ear.ear\"
                        Caused by: java.lang.IllegalArgumentException: JBAS011470: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment subdeployment \"domene-ejb-1.0-SNAPSHOT.jar\" of deployment \"domene-ear.ear\".  Either change the application deployment to have only one persistence unit definition or specify the unitName for each reference to a persistence unit."},
                        "JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
                            "Services that were unable to start:" => [
                                "jboss.deployment.subunit.\"domene-ear.ear\".\"domene-web-1.0-SNAPSHOT.war\".CONFIGURE_MODULE",
                                "jboss.deployment.unit.\"domene-ear.ear\".CONFIGURE_MODULE"
                            ],
                            "Services that may be the cause:" => ["jboss.jdbc-driver.mysql"]
                        }
                    }
                    15:40:29,764 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
                        ("subsystem" => "datasources"),
                        ("data-source" => "MySqlDS")
                    ]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
                        "jboss.data-source.java:jboss/datasources/MysqlDS is missing [jboss.jdbc-driver.mysql]",
                        "jboss.driver-demander.java:jboss/datasources/MysqlDS is missing [jboss.jdbc-driver.mysql]"
                    ]}
                    15:40:29,765 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
                        ("subsystem" => "datasources"),
                        ("data-source" => "domeneDS")
                    ]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
                        "jboss.data-source.java:jboss/datasources/domeneDS is missing [jboss.jdbc-driver.mysql]",
                        "jboss.driver-demander.java:jboss/datasources/domeneDS is missing [jboss.jdbc-driver.mysql]"
                    ]}
                    15:40:29,767 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
                        ("subsystem" => "datasources"),
                        ("data-source" => "MySqlDS")
                    ]) - failure description: {
                        "JBAS014771: Services with missing/unavailable dependencies" => [
                            "jboss.data-source.java:jboss/datasources/MysqlDS is missing [jboss.jdbc-driver.mysql]",
                            "jboss.driver-demander.java:jboss/datasources/MysqlDS is missing [jboss.jdbc-driver.mysql]"
                        ],
                        "JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
                            "Services that were unable to start:" => [
                                "jboss.data-source.reference-factory.MySqlDS",
                                "jboss.naming.context.java.jboss.datasources.MysqlDS"
                            ],
                            "Services that may be the cause:" => ["jboss.jdbc-driver.mysql"]
                        }
                    }
                    15:40:29,768 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
                        ("subsystem" => "datasources"),
                        ("data-source" => "domeneDS")
                    ]) - failure description: {
                        "JBAS014771: Services with missing/unavailable dependencies" => [
                            "jboss.data-source.java:jboss/datasources/domeneDS is missing [jboss.jdbc-driver.mysql]",
                            "jboss.driver-demander.java:jboss/datasources/domeneDS is missing [jboss.jdbc-driver.mysql]"
                        ],
                        "JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
                            "Services that were unable to start:" => [
                                "jboss.data-source.reference-factory.domeneDS",
                                "jboss.naming.context.java.jboss.datasources.domeneDS"
                            ],
                            "Services that may be the cause:" => ["jboss.jdbc-driver.mysql"]
                        }
                    }
                    15:40:29,799 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "domene-ear.ear" (runtime-name : "domene-ear.ear")
                    15:40:29,801 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
                    JBAS014775:    New missing/unsatisfied dependencies:
                          service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.java:jboss/datasources/MysqlDS, service jboss.data-source.java:jboss/datasources/domeneDS, service jboss.driver-demander.java:jboss/datasources/MysqlDS, service jboss.driver-demander.java:jboss/datasources/domeneDS] 
                    JBAS014777:   Services which failed to start:      service jboss.deployment.subunit."domene-ear.ear"."domene-ejb-1.0-SNAPSHOT.jar".DEPENDENCIES: org.jboss.msc.service.StartException in service jboss.deployment.subunit."domene-ear.ear"."domene-ejb-1.0-SNAPSHOT.jar".DEPENDENCIES: JBAS018733: Failed to process phase DEPENDENCIES of subdeployment "domene-ejb-1.0-SNAPSHOT.jar" of deployment "domene-ear.ear"
                    
                    15:40:30,028 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-12) JBAS015877: Stopped deployment null (runtime-name: domene-ejb-1.0-SNAPSHOT.jar) in 4ms
                    15:40:30,031 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-13) JBAS015877: Stopped deployment null (runtime-name: domene-web-1.0-SNAPSHOT.war) in 7ms
                    15:40:30,033 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-9) JBAS015877: Stopped deployment domene-ear.ear (runtime-name: domene-ear.ear) in 10ms
                    15:40:30,334 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
                    15:40:30,334 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
                    15:40:30,335 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: WildFly 8.0.0.Beta2-SNAPSHOT "WildFly" started (with errors) in 10694ms - Started 188 of 233 services (8 services failed or missing dependencies, 65 services are lazy, passive or on-demand)
                    15:40:30,458 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018558: Undeployed "domene-ear.ear" (runtime-name: "domene-ear.ear")
                    15:40:30,459 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
                    JBAS014777:   Services which failed to start:      service jboss.deployment.subunit."domene-ear.ear"."domene-ejb-1.0-SNAPSHOT.jar".DEPENDENCIES
                    
                    15:40:34,821 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015003: Found domene-ear.ear in deployment directory. To trigger deployment create a file called domene-ear.ear.dodeploy
                    
                    
                    
                    

                     

                    Deployment is in ear.

                     

                    I have two beans.xml

                    One in ejb/src/main/resources/META_INF

                    Second in war/src/main/webapp/WEB_INF

                     

                    I don't have any ejb-jar.xml file

                    • 7. Re: Re: How to use multiple data sources
                      Scott Marlow Master

                      For the:

                      Caused by: java.lang.IllegalArgumentException: JBAS011470: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment subdeployment "domene-ejb-1.0-SNAPSHOT.jar" of deployment "domene-ear.ear".  Either change the application deployment to have only one persistence unit definition or specify the unitName for each reference to a persistence unit. 

                       

                      There is a workaround in WildFly 8.  See documentation here and add a persistence unit with "wildfly.jpa.default-unit" set to value "true".  Basically, you can pick the persistence unit that should be the default.