8 Replies Latest reply on Jun 22, 2007 8:36 AM by silvams

    Embedded with Junit and Maven 2/surefire?

    ghinwa

      Has anyone been able to run junit testcases with embeddable Jboss 5 kernel using Maven2/surefire? I have a simple testcase that isn't much different from the examples provided with the beta 2, and it works fine with ant, however when I try to run it using Maven2/surefire I get the following exception:

      ...
      ...
      ...
      Caused by: java.net.MalformedURLException: unknown protocol: vfsfile
       at java.net.URL.<init>(URL.java:574)
       at java.net.URL.<init>(URL.java:464)
       at java.net.URL.<init>(URL.java:413)
       at org.jboss.virtual.plugins.context.file.FileHandler.<init>(FileHandler.java:75)
       at org.jboss.virtual.plugins.context.file.FileHandler.<init>(FileHandler.java:89)
       at org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:253)
       at org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:186)
       at org.jboss.virtual.plugins.context.file.FileSystemContext.<init>(FileSystemContext.java:150)
       at org.jboss.virtual.plugins.context.file.FileSystemContext.<init>(FileSystemContext.java:124)
       at org.jboss.virtual.plugins.context.file.FileSystemContext.<init>(FileSystemContext.java:113)
       at org.jboss.virtual.plugins.context.file.FileSystemContextFactory.getVFS(FileSystemContextFactory.java:54)
       at org.jboss.virtual.VFS.getVFS(VFS.java:132)
       at org.jboss.virtual.VFS.getRoot(VFS.java:146)
       at org.jboss.embedded.DeploymentGroup.getVirtualFile(DeploymentGroup.java:186)
       ... 69 more
      


      even though in my test case i call:
      System.out.println("java.protocol.handler.pkgs=" + System.getProperty("java.protocol.handler.pkgs"));
      


      and the following is printed:
      java.protocol.handler.pkgs=org.jboss.virtual.protocol
      


      any help/insight appreciated.

        • 1. Re: Embedded with Junit and Maven 2/surefire?
          scottl_dhsnet

          PING

          Anyone shed insight on this? Looks like the surefire plugin has some issues:

          ERROR 14-05 19:49:12,420 (DeploymentScanner.java:start:113) -Failed to deploy
          org.jboss.deployers.spi.DeploymentException: Unable to get VirtualFile for url: file:/C:/netbeans_projects/testutils-lib/target/test-classes/conf/jboss-service.xml
          at org.jboss.embedded.DeploymentGroup.getVirtualFile(DeploymentGroup.java:190)
          at org.jboss.embedded.DeploymentGroup.add(DeploymentGroup.java:176)
          at org.jboss.embedded.DeploymentGroup.addResource(DeploymentGroup.java:329)
          at org.jboss.embedded.DeploymentScanner.start(DeploymentScanner.java:85)
          <...snip...>
          Caused by: java.net.MalformedURLException: unknown protocol: vfsfile
          at java.net.URL.(URL.java:574)
          at java.net.URL.(URL.java:464)
          at java.net.URL.(URL.java:413)
          at org.jboss.virtual.plugins.context.file.FileHandler.(FileHandler.java:75)
          at org.jboss.virtual.plugins.context.file.FileHandler.(FileHandler.java:89)
          at org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:253)
          at org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:186)
          at org.jboss.virtual.plugins.context.file.FileSystemContext.(FileSystemContext.java:150)
          at org.jboss.virtual.plugins.context.file.FileSystemContext.(FileSystemContext.java:124)
          at org.jboss.virtual.plugins.context.file.FileSystemContext.(FileSystemContext.java:113)
          at org.jboss.virtual.plugins.context.file.FileSystemContextFactory.getVFS(FileSystemContextFactory.java:54)
          at org.jboss.virtual.VFS.getVFS(VFS.java:132)
          at org.jboss.virtual.VFS.getRoot(VFS.java:146)
          at org.jboss.embedded.DeploymentGroup.getVirtualFile(DeploymentGroup.java:186)

          Any thoughts? This does not occur when using Netbeans project directly.

          • 2. Re: Embedded with Junit and Maven 2/surefire?
            scottl_dhsnet

            Ok, here is some more information. I switch the surefire plugin forkMode to never and the following error occurs:

            (java.io.FilePermission \C:\Documents and Settings\scottl\.m2\repository\jboss\jboss-embedded-all\1.0.0-BETA2\jboss-embedded-all-1.0.0-BETA2.jar read)
            )
            
             at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:1407)
             at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:376)
             at org.jboss.embedded.adapters.JMXKernel.start(JMXKernel.java:157)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:55)
             at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:108)
             at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
             at org.jboss.kernel.plugins.dependency.DispatchJoinPoint.run(DispatchJoinPoint.java:47)
             at java.security.AccessController.doPrivileged(Native Method)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:110)
             at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:145)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.installAction(KernelControllerContextAction.java:197)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$1.run(KernelControllerContextAction.java:145)
             at java.security.AccessController.doPrivileged(Native Method)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.install(KernelControllerContextAction.java:168)
             at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
             at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:233)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:724)
             at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:445)
             at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:555)
             at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:489)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:289)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:192)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:302)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:272)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:119)
             at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:96)
             at org.jboss.embedded.Bootstrap.deployBaseBootstrapUrl(Bootstrap.java:150)
             at org.jboss.embedded.Bootstrap.bootstrapURL(Bootstrap.java:162)
             at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:201)
             at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:214)
             at com.dhsnet.util.test.EJB3IntegrationTest.startContainer(EJB3IntegrationTest.java:79)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
             at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:322)
             at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:156)
             at org.testng.SuiteRunner.privateRun(SuiteRunner.java:236)
             at org.testng.SuiteRunner.run(SuiteRunner.java:145)
             at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901)
             at org.testng.TestNG.runSuitesLocally(TestNG.java:863)
             at org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGExecutor.java:69)
             at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:78)
             at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
             at org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:198)
             at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:398)
             at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:417)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:610)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:564)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:534)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:309)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:276)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
             at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:393)
             at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:182)
             at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:760)
             at org.codehaus.mevenide.netbeans.execute.MavenJavaExecutor.run(MavenJavaExecutor.java:257)
             at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:131)
            ERROR 14-05 20:38:53,168 (AbstractController.java:incrementState:456) -Error installing to Instantiated: name=DeploymentFilter state=Described
            java.lang.IllegalStateException: Class not found: [Ljava.lang.String;
             at org.jboss.metadata.spi.signature.Signature.stringsToClasses(Signature.java:174)
             at org.jboss.metadata.spi.signature.Signature.stringsToClasses(Signature.java:125)
             at org.jboss.metadata.spi.signature.Signature.getParametersTypes(Signature.java:292)
             at org.jboss.metadata.plugins.loader.reflection.AnnotatedElementMetaDataLoader.getComponentMetaDataRetrieval(AnnotatedElementMetaDataLoader.java:138)
             at org.jboss.metadata.plugins.context.AbstractMetaDataContext.getComponentMetaDataRetrieval(AbstractMetaDataContext.java:280)
             at org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge.getComponentMetaData(MetaDataRetrievalToMetaDataBridge.java:159)
             at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.methodHasAnnotations(AOPConstructorJoinpoint.java:202)
             at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.hasMethodMetaData(AOPConstructorJoinpoint.java:172)
             at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.hasInstanceOrJoinpointMetaData(AOPConstructorJoinpoint.java:152)
             at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.dispatch(AOPConstructorJoinpoint.java:99)
             at org.jboss.kernel.plugins.dependency.DispatchJoinPoint.run(DispatchJoinPoint.java:47)
             at java.security.AccessController.doPrivileged(Native Method)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:110)
             at org.jboss.kernel.plugins.dependency.InstantiateAction.installActionInternal(InstantiateAction.java:52)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.installAction(KernelControllerContextAction.java:197)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$1.run(KernelControllerContextAction.java:145)
             at java.security.AccessController.doPrivileged(Native Method)
             at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.install(KernelControllerContextAction.java:168)
             at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
             at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:233)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:724)
             at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:445)
             at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:555)
             at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:489)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:289)
             at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:192)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:302)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:272)
             at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:119)
             at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:96)
             at org.jboss.embedded.Bootstrap.deployBaseBootstrapUrl(Bootstrap.java:150)
             at org.jboss.embedded.Bootstrap.bootstrapURL(Bootstrap.java:162)
             at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:201)
             at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:214)
             at com.dhsnet.util.test.EJB3IntegrationTest.startContainer(EJB3IntegrationTest.java:79)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
             at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:322)
             at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:156)
             at org.testng.SuiteRunner.privateRun(SuiteRunner.java:236)
             at org.testng.SuiteRunner.run(SuiteRunner.java:145)
             at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901)
             at org.testng.TestNG.runSuitesLocally(TestNG.java:863)
             at org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGExecutor.java:69)
             at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:78)
             at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
             at org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:198)
             at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:398)
             at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:417)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:610)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:564)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:534)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:309)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:276)
             at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
             at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:393)
             at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:182)
             at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:760)
             at org.codehaus.mevenide.netbeans.execute.MavenJavaExecutor.run(MavenJavaExecutor.java:257)
             at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:131)
            Caused by: java.lang.ClassNotFoundException: [Ljava.lang.String;
             at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
             at java.security.AccessController.doPrivileged(Native Method)
             at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
             at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
             at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
             at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:103)
             at org.jboss.metadata.spi.signature.Signature.stringsToClasses(Signature.java:170)
             ... 67 more
            
            


            I am no classloader guru...so it cannot find the files when you fork once with surefire and you cannot access the jars when you don't fork.

            Not sure where to go from here. Thoughts?

            • 3. Re: Embedded with Junit and Maven 2/surefire?
              scottl_dhsnet

              Alright, here is a thread from the Nabble email list:

              http://www.nabble.com/Failing-to-find-system-resouces-in-unit-test-in-surefire-t2878047s177.html

              I'm not a surefire expert, this is just from taking a quick look at the source: However you run Surefire (forked or not, with child delegation or not), the system classloader will not contain your test code. In forked mode, it will only contain surefire and your testing framework. Surefire itself will create an isolated classloader that contains your test code and its dependencies and run your tests from that classloader.


              To be able to use embedded JBoss you must have all the files in embedded-jboss/lib/ in your classpath. The main org.jboss.embedded.Bootstrap class uses the classpath to find configuration files so the embedded-jboss/bootstrap/ directory needs to be in your classpath to.


              This seems to be the crux of the issue. If I understand this situation (I am no classloader guru) surefire creates an isolated classloader that does not contain the bootstrap dir when in fork mode 'once', but when in fork mode 'never' it has access to the bootstrap dir by virtue of having access to the system loader but the tests are still in the isolated classloader... does that sound right? Anyone?

              • 4. Re: Embedded with Junit and Maven 2/surefire?
                bill.burke

                Did you forget to call Bootstrap.getInstance().bootstrap()?

                Embedded is supposed to set up the appropriate system property and URLHandler so that it can find the "vfsfile" protocol. Or maybe maven is already doing this?

                • 5. Re: Embedded with Junit and Maven 2/surefire?
                  scottl_dhsnet

                  I am using TestNG as the unit test framework. Bootstrap.getInstance().bootstrap() is called during a @BeforeTest() method. So, yes this is being called.

                  What system properties are being set? Do you think think issue is related to this thread?

                  http://www.jboss.org/?module=bb&op=viewtopic&t=102426

                  Might be possible Maven is messing with or ignoring altogether system properties being set by Embedded....?

                  Thanks for your help.

                  • 6. Re: Embedded with Junit and Maven 2/surefire?
                    scottl_dhsnet

                    Ok solved it.

                    First apply a whole lot of magic to the surefire plugin....

                     <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
                     <version>2.4-SNAPSHOT</version>
                     <configuration>
                     <jvm>${java_1_5_home}/bin/java</jvm>
                     <argLine>${surefire.argLine}</argLine>
                     <forkMode>once</forkMode>
                     <suiteXmlFiles>
                     <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                     </suiteXmlFiles>
                     <additionalClasspathElements>
                     <additionalClasspathElement>src/test/resources/bootstrap</additionalClasspathElement>
                     </additionalClasspathElements>
                     <systemProperties>
                     <property>
                     <name>java.protocol.handler.pkgs</name>
                     <value>org.jboss.virtual.protocol</value>
                     </property>
                     </systemProperties>
                     </configuration>
                     </plugin>
                    
                    
                    


                    Note we have to set the jvm to 1.5 as Embedded runs on 1.5 ONLY. Also note I had to add the java.protocol.handler.pkgs system property to the plugin configuration. Within my test class I added the following to my @BeforeClass method prior to calling Bootstrap.getInstance().bootstrap().
                    org.jboss.net.protocol.URLStreamHandlerFactory factory
                     = new org.jboss.net.protocol.URLStreamHandlerFactory();
                     URL.setURLStreamHandlerFactory(factory);


                    I found this snippet in the thread mentioned in my previous post.

                    Lastly to get the bootstrap/ on the classpath I needed to patch the surefire plugin. See this JIRA issue http://jira.codehaus.org/browse/SUREFIRE-180

                    Amazing amount of work to get all these tools to play nice

                    • 7. Re: Embedded with Junit and Maven 2/surefire?
                      jc7442

                      Another solution would be to have the Bootstrap.bootstrap(URL) with a public modifier. So that it would be possible to start embedded JBoss with a configuration that would not be in the classpath.

                      • 8. Re: Embedded with Junit and Maven 2/surefire?
                        silvams

                        How I solved this problem

                        Firs I use another module to tests, couse if youre in another module the files under resource are in you classpath, you can see it using de -X (debug directive) to maven.

                        So I have for example a helloword project with a helloword-model module a helloword-store module and a helloword-integrationtest module.

                        The helloword-integrationtest module has in his src/test/resources the bootstrap files an in his src/test/java the integration tests. It has in his dependency the helloword-store the helloword-model modules and the embedded apis that I deploy in my shered maven repository.

                        So In my build I have:

                        <plugin>
                         <artifactId>maven-surefire-plugin</artifactId>
                         <version>2.3</version>
                         <configuration>
                         <suiteXmlFiles>
                         <suiteXmlFile>
                         src/test/resources/testng.xml
                         </suiteXmlFile>
                         </suiteXmlFiles>
                         </configuration>
                        </plugin>
                        

                        And Before start the conteiner:
                         org.jboss.net.protocol.URLStreamHandlerFactory factory
                         = new org.jboss.net.protocol.URLStreamHandlerFactory();
                         URL.setURLStreamHandlerFactory(factory);