10 Replies Latest reply on Jul 10, 2015 9:16 AM by hchiorean

    FULL_XA does not work on ModeShape 4.1

    mustafamizrak

      Hi all,

       

      I am trying to integrate my database and modeshape (4.1 and infinispan 6.0.2) transaction (two-phase commitment) but I get NullPointerException :

      1. I have configured my db on WildFly 8.2 as an XA data source and I access it via JNDI and
      2. I have configured cache-container with the following properties:

        <cache-container name=...
          <local-cache name=...
            <locking isolation="READ_COMMITTED"/>
            <transaction mode="FULL_XA" locking="PESSIMISTIC"/>
            <file-store ...
          </local-cache>
        </cache-container>
        
        
        
        


      3. When I add/creatte a node on an external file resource via file system connector, I am getting:

        // from JcrXaSession.java (from modeshape) at line 6:
        java.lang.NullPointerException
        
        // ((XAResource) session).start(xid, XAResource.TMNOFLAGS) call
        public void start( Xid xid, int flags ) throws XAException {
          delegate().start(xid, flags);
        }
        
        
        
        
        
        

       

      How can I use  FULL_XA with ModeShape? Or what may be wrong?

       

      Thanks!

       

      Mustafa

        • 1. Re: FULL_XA does not work on ModeShape 4.1
          hchiorean

          What does the full stack trace look like ? ModeShape only delegates in this particular case to Infinispan's AdvancedCache#getXAResource(). If that returns <null> it means Infinispan may not be configured/integrating correctly with the tx manager.

          • 2. Re: FULL_XA does not work on ModeShape 4.1
            mustafamizrak

            full stack trace:

             

             

            org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: java.lang.NullPointerException
                at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
                at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
                at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150) [spring-orm-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_20]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_20]
                at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_20]
            Caused by: org.springframework.transaction.CannotCreateTransactionException: java.lang.NullPointerException
                at ...transactionManager.doBegin(...transactionManager.java:125) [classes:]
                at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:463) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:276) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) [spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_20]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_20]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_20]
                at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_20]
                at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                ... 41 more
            Caused by: java.lang.NullPointerException
                at org.infinispan.transaction.xa.TransactionXaAdapter.start(TransactionXaAdapter.java:132) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]
                at org.modeshape.jcr.JcrXaSession.start(JcrXaSession.java:51) [modeshape-jcr-4.1.0.Final.jar:4.1.0.Final]
                at ...userTransaction.begin(...userTransaction.java:67) [classes:]
                at ...transactionManager.doBegfin(...transactionManager.java:114) [classes:]
                ... 64 more
            
            
            • 3. Re: FULL_XA does not work on ModeShape 4.1
              hchiorean

              Is your code attempting to enlist the ModeShape session with the transaction ? If yes, that won't work and could cause the problem you're seeing.

              In general, when using XA you shouldn't attempt to manually enlist the session with the transaction but rather rely on Infinispan's automatic enlistement - just configuring the cache as FULL_XA is enough from ModeShape's perspective.

               

              If your code isn't enlisting the ModeShape session with the transaction, can you provide a sample test case which we can run locally to see this problem ? Simply defining a cache in Wildfly as FULL_XA coupled with a <xa-datasource/> definition doesn't trigger this problem, meaning it requires a more complicated setup.

              • 4. Re: FULL_XA does not work on ModeShape 4.1
                mustafamizrak

                Is your code attempting to enlist the ModeShape session with the transaction ? If yes, that won't work and could cause the problem you're seeing.

                In general, when using XA you shouldn't attempt to manually enlist the session with the transaction but rather rely on Infinispan's automatic enlistement - just configuring the cache as FULL_XA is enough from ModeShape's perspective.

                          Yes, I use session with manual transaction. I have tried automatic enlistment but transaction did not work.

                 

                If your code isn't enlisting the ModeShape session with the transaction, can you provide a sample test case which we can run locally to see this problem ?

                          I am trying a simple case actually: I have a Spring MVC application (with hibernate) such that I save some documents on file system via modeshape and I save nodeuuid and added date on the database.

                          What I want from transaction is that when an exception occurred, no need to save information to the database and if database exception occurred, modeshape should not commit/save the document to the file system.

                 

                Simply defining a cache in Wildfly as FULL_XA coupled with a <xa-datasource/> definition doesn't trigger this problem, meaning it requires a more complicated setup.

                          Could you provide more detailed such configuration?

                 

                Regards.

                • 5. Re: FULL_XA does not work on ModeShape 4.1
                  hchiorean

                  You may want to look at https://issues.jboss.org/browse/MODE-2427 and Configuration - ModeShape 4 - Project Documentation Editor.

                  You can see how to configure XA datasources in Wildfly here: DataSource configuration - WildFly 8 - Project Documentation Editor. Once you have such a datasource configured, all you need to do is configure the ISPN cache as FULL_XA or NON_DURABLE_XA (see above). There shouldn't be any need to manually enlist the ModeShape session into a transaction.

                  • 6. Re: FULL_XA does not work on ModeShape 4.1
                    mustafamizrak

                    I have already configured my repository as follows (in standalone.xml, WF 8.2):

                     

                    <subsystem xmlns="urn:jboss:domain:infinispan:2.0">
                         ...
                         <cache-container name="cacheName" default-cache="localCache" jndi-name="cacheName" module="org.modeshape">
                              <local-cache name="localCache" jndi-name="localCache" statistics-enabled="true">
                                   <locking isolation="READ_COMMITTED"/>
                                   <transaction mode="FULL_XA" locking="PESSIMISTIC"/>
                                   <eviction strategy="LRU" max-entries="10000"/>
                                   <file-store passivation="false" purge="false" path="somewhere"/>
                              </local-cache>
                         </cache-container>
                    </subsystem>
                    
                    <subsystem xmlns="urn:jboss:domain:datasources:2.0">
                         <datasources>
                              ...
                              <datasource ...>
                              </datasource>
                              <xa-datasource jndi-name="java:/datasources/someXAName" pool-name="someXAName" enabled="true" use-java-context="true">
                                        <xa-datasource-property name="URL">
                                            ...
                                        </xa-datasource-property>
                                        <xa-datasource-property name="User">
                                            ...
                                        </xa-datasource-property>
                                        <xa-datasource-property name="Password">
                                            ...
                                        </xa-datasource-property>
                                        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                                        <driver>oracle</driver>
                                        <xa-pool>
                                            <min-pool-size>4</min-pool-size>
                                            <max-pool-size>20</max-pool-size>
                                            <prefill>true</prefill>
                                            <is-same-rm-override>false</is-same-rm-override>
                                            <no-tx-separate-pools>true</no-tx-separate-pools>
                                        </xa-pool>
                                        <validation>
                                            <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
                                            <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
                                            <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
                                        </validation>
                             </xa-datasource>
                                  <drivers>
                                        <driver name="h2" module="com.h2database.h2">
                                            <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                                        </driver>
                                        <driver name="oracle" module="com.oracle.db">
                                            <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                                        </driver>
                                        <driver name="modeshape" module="org.modeshape.jdbc">
                                            <driver-class>org.modeshape.jdbc.LocalJcrDriver</driver-class>
                                        </driver>
                                 </drivers>
                         </datasources>
                    </subsystem>
                    
                    

                     

                    Unfortunately, it does not work as expected with XAResource rather than sync. What may be wrong?

                     

                    Regards.

                    • 7. Re: FULL_XA does not work on ModeShape 4.1
                      mustafamizrak

                      Neither automatic enlistement nor manual enlistement works with above FULL_XA infinispan configuration.

                      Any suggesiton hchiorean?

                      • 8. Re: FULL_XA does not work on ModeShape 4.1
                        hchiorean

                        No, unless you can create a sample test case which illustrates the problem so that I can look at it locally.

                        • 9. Re: FULL_XA does not work on ModeShape 4.1
                          mustafamizrak

                          Requested sample test project (spring based) is attached for this.

                          • 10. Re: FULL_XA does not work on ModeShape 4.1
                            hchiorean

                            Can you please try updating & running the test project with the latest ModeShape (4.3.0.Final). We're now using Infinispan 7 (which is significantly different from 6). If the problem is still there, feel free to open a JIRA with the sample test case. Thanks.