6 Replies Latest reply on May 24, 2013 9:04 AM by Vivian Steller

    MS3.2: Unexpected element '{urn:infinispan:config:5.2}infinispan' with simple configuration

    Vivian Steller Newbie

      I'm deploying Modeshape 3.2.0 as a JBoss AS Subsystem (using JBoss 7.2.0) and use Arquillian to perform a basic repository test.

       

      When deploying my own repository with a quite simple configuration, an exception is thrown.

       

      This is my Arquillian test case:

       

      {code}

      package eu.sustainhub.data.modeshape.test;

       

       

      import static org.junit.Assert.assertNotNull;

       

       

      import javax.annotation.Resource;

      import javax.jcr.Node;

      import javax.jcr.Repository;

      import javax.jcr.RepositoryException;

      import javax.jcr.Session;

       

       

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.asset.EmptyAsset;

      import org.jboss.shrinkwrap.api.spec.WebArchive;

      import org.junit.After;

      import org.junit.Before;

      import org.junit.Test;

      import org.junit.runner.RunWith;

      import org.modeshape.jcr.ModeShapeEngine;

      import org.modeshape.jcr.RepositoryConfiguration;

       

       

      /**

      * @author Vivian Steller <vivian.steller@uni-ulm.de>

      * @since 1.0

      *

      */

      @RunWith(Arquillian.class)

      public class BaseRepositoryIntegrationTest {

       

       

          private static final String TEST_REPOSITORY = "test";

       

       

          @Deployment

          public static WebArchive createDeployment(){

              WebArchive archive = ShrinkWrap.create(WebArchive.class, "testcase.war")

                      .addAsResource("test-repository.json")

                      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")

                      .addAsWebInfResource("META-INF/jboss-deployment-structure.xml", "jboss-deployment-structure.xml");

              System.out.println(archive.toString(true));

              return archive;

          }

       

          @Resource(mappedName="java:/jcr")

          private ModeShapeEngine engine;

       

          @Before

          public void testEngineDeployRepository() throws Exception {

              assertNotNull(engine);

       

              engine.deploy(RepositoryConfiguration.read("test-repository.json"));

       

              assertNotNull(getRepository());

          }

       

       

          public Repository getRepository() throws RepositoryException {

              return engine.getRepository(TEST_REPOSITORY);

          }

       

       

          @Test

          public void testNodeCreation() throws RepositoryException {

              final Repository repository = engine.getRepository("test");

              final Session session = repository.login();

       

              final Node root = session.getRootNode();

              root.addNode("test");

       

              session.save();

          }

       

       

          @After

          public void testEngineUndeployRepository() throws Exception {

              engine.undeploy(TEST_REPOSITORY);

          }

      }

       

      {code}

       

      This is the test-repository.json configuration:

       

      {code}

      {

          "name": "test",

          "jndiName": "jcr/test"

      }

      {code}

       

      This is the exception thrown, when running testNodeCreation:

       

      {code}

      javax.jcr.RepositoryException: Error while starting 'test' repository: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1]

      Message: Unexpected element '{urn:infinispan:config:5.2}infinispan'

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:603)

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:562)

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:152)

                at eu.sustainhub.data.modeshape.test.BaseRepositoryIntegrationTest.testNodeCreation(BaseRepositoryIntegrationTest.java:62)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

                at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:270)

                at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

                at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

                at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)

                at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263)

                at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226)

                at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)

                at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

                at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

                at org.junit.runner.JUnitCore.run(JUnitCore.java:136)

                at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)

                at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)

                at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)

                at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)

                at java.lang.Thread.run(Thread.java:722)

      Caused by: org.infinispan.config.ConfigurationException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1]

      Message: Unexpected element '{urn:infinispan:config:5.2}infinispan'

                at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:87)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:353)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:326)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:313)

                at org.modeshape.jcr.LocalEnvironment.createContainer(LocalEnvironment.java:201)

                at org.modeshape.jcr.LocalEnvironment.getCacheContainer(LocalEnvironment.java:113)

                at org.modeshape.jcr.RepositoryConfiguration.getCacheContainer(RepositoryConfiguration.java:988)

                at org.modeshape.jcr.RepositoryConfiguration.getWorkspaceContentCacheContainer(RepositoryConfiguration.java:983)

                at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:1047)

                at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:924)

                at org.modeshape.jcr.JcrRepository.doStart(JcrRepository.java:357)

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:601)

                ... 93 more

      Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException: javax.xml.stream.XMLStreamException : ParseError at [row,col]:[2,1]

      Message: Unexpected element '{urn:infinispan:config:5.2}infinispan' [Proxied because : Original exception not deserilizable, ClassNotFoundException]

                at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:108)

                at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)

                at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:77)

                ... 104 more

      {code}

       

      Debugging shows that Modeshape uses the following cache configuration file:

       

      /org/modeshape/jcr/default-workspace-cache-config.xml

       

      Any idea what's going wrong here?

        • 1. Re: MS3.2: Unexpected element '{urn:infinispan:config:5.2}infinispan' with simple configuration
          Horia Chiorean Master

          If you're using ModeShape with AS, you should be using the ModeShape EAP kit, instead of embeding a JSON configuration file inside a WAR.  There are numerous reasons for this, but one of the most compelling is that ModeShape needs to integrate with the JNDI, Infinispan, JGroups etc subsystems that are part of AS. Therefore, your ModeShape configuration would be defined in the AS XML configuration file (like the default provided standalone-modeshape.xml). In your Arquillian test, you wouldn't embeded the repository JSON configuration.

           

          You can find out more here: https://docs.jboss.org/author/display/MODE/ModeShape+and+JBoss+AS7.

          Also, you can look at our Arquillian integration tests: https://github.com/hchiorean/modeshape/tree/master/integration/modeshape-jbossas-integration-tests/src/test/java/org/modeshape/test/integration

          • 2. Re: MS3.2: Unexpected element '{urn:infinispan:config:5.2}infinispan' with simple configuration
            Vivian Steller Newbie

            Thanks very much for the prompt response.

             

            It's a bit sad that deploying custom repos using this setup doesn't work. Pre-configuring the repository in JBoss AS' configuration file implies that every Arquillian test uses the same repository, which not really isolates the tests.

            Plus, to be honest, I'm not really sure why this shouldn't work? In the test, I'm retrieving the Modeshape engine from the JBoss AS subsystem. If engine provides a method to deploy repository configuration I'm expecting this to work at any time, not only at container startup?

            • 3. Re: MS3.2: Unexpected element '{urn:infinispan:config:5.2}infinispan' with simple configuration
              Horia Chiorean Master

              The reason why this doesn't work, is that ModeShape uses internally an "enviroment" which controls classloading, ISPN integration, etc. When running locally (embedded) - which is what your test does - it will use the ISPN public builder API to create caches & cache containers. This will not work inside of AS7, as the way you create and refer caches & cache containers in AS7 is different (as I mentioned earlier, this isn't limited to ISPN, but a whole range of libraries).

               

              When running inside of AS7, there is an "AS7 environment" (called RepositoryService) which needs to be picked up & used by the repositories. Also, the whole repository startup process is different from the standard, embedded mode.

               

              Another issue (and I suspect it's was causing your exception) is classloading: the WAR file deployed by Arquillian will have its own (isolated) classloader and would be able to access modules defined in your jboss-deployment-structure.xml but nothing more. This classloader is different than the one used by AS7 when starting up & dealing with the ISPN subsystem.

              • 4. Re: MS3.2: Unexpected element '{urn:infinispan:config:5.2}infinispan' with simple configuration
                Vivian Steller Newbie

                Thanks again for the in-depth information

                 

                Okay, I get the point what's the trouble if I run Modeshape *embedded* in my test.


                Horia Chiorean wrote:

                 

                When running locally (embedded) - which is what your test does - ...

                However, I do not get *why* it's running embedded. I do never call engine.start(). Instead I'm retrieving the Modeshape via JNDI...?? The engine has already been started by JBoss AS...

                 

                So, and the next question was: is there really no way to keep the repository configuration with the web app archive? I'd love to distribute a .war-file that people could easily drop into their JBoss AS 7 instance (with Modeshape Subsystem installed) and go.. without having to modify their standalone.xml?

                • 5. Re: MS3.2: Unexpected element '{urn:infinispan:config:5.2}infinispan' with simple configuration
                  Horia Chiorean Master

                  No, there isn't a way, as long as you want to use ModeShape's EAP extension.

                   

                  The only thing I can think of (which you would need to try) is to package *everything* (all the dependencies) in the webapp's lib, creating de-facto an embedded, isolated web application. This would be a web application that runs in any web app container (e.g.Tomcat) and would be isolated from any AS7 specific configuration. You would also need to make sure (while running in AS7) that the deployment descriptor doesn't have any dependencies towards modules installed in AS7 (that would cause CL hell)

                   

                  So really you would be bypassing the entire ModeShape subsystem/extension that is provided for EAP.

                  • 6. Re: MS3.2: Unexpected element '{urn:infinispan:config:5.2}infinispan' with simple configuration
                    Vivian Steller Newbie

                    Juhu, I got it fixed - finally.

                     

                    Horia, I still do not agree with you that my test executes Modeshape embedded but you were absolutely right that we've some classpath issue here. Particularly I recognized that the test code works in a servlet directly running in JBoss, so the issue is really related to Arquillian. I debugged once more and realized that - when running the test with Arquillian - there is no Infinispan ConfigurationParser available on the Classpath. As Infinispan loads the ConfigurationParser using the service loader facility it silently fails. So, the end of the story: add inifinispan-core to the Arquillian Test classpath.

                     

                    We've to modify the deployment as follows:

                     

                    {code}

                        @Deployment

                        public static WebArchive createDeployment(){

                            MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class)

                                .loadMetadataFromPom("pom.xml");

                           

                            WebArchive archive = ShrinkWrap.create(WebArchive.class, "testcase.war")

                                    .addAsLibraries(resolver.artifact("org.infinispan:infinispan-core:5.2.1.Final").resolveAsFiles())

                                    .addClass(org.infinispan.configuration.parsing.Parser52.class)

                                    .addAsResource("test-repository.json")

                                    .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")

                                    .addAsWebInfResource("META-INF/jboss-deployment-structure.xml", "jboss-deployment-structure.xml");

                            System.out.println(archive.toString(true));

                            return archive;

                        }

                    {code}

                     

                    Now, also Arquillian finds the ConfigurationParser an passes the test.

                     

                    Well, I still wonder why Arquillian doesn't find the ConfigurationParser without explicitly specifiying the maven dependency:

                    1. it should use really the same classpath as JBoss AS

                    2. I've defined an jboss-deployment-structure.xml with a module dependency to org.infinispan

                    3. the inifispan maven dependency should be on the test classpath anyway.

                     

                    Any thoughts on this / well maybe this is something for the Arquillian guys

                     

                    Thanks again, Horia, for your hints!