8 Replies Latest reply on Feb 13, 2008 1:41 PM by drathnow

    Embedded JBoss, Maven, and the ubiquitous Jar

    drathnow


      For the most part, I've managed to figure out how to setup Embedded JBoss with Eclipse so I can run my unit tests. Now I'm trying to figure out how to setup my Maven pom.xml file so that I can run my tests from the command line with Maven.

      After muddling around with the jar file dependencies, I'm stuck with the following exception:

      Error installing to Start: name=ResourcesToDeploy3 state=Create
      org.jboss.deployers.spi.DeploymentException: Unable to find deployDir from url: file:/c:/developer/fdexec/Applications/bridge/target/test-classes/deploy/
      at org.jboss.embedded.DeploymentGroup.getDeployerDirUrls(DeploymentGroup.java:536)
      at org.jboss.embedded.DeploymentGroup.getDeployerDirUrlsFromResource(DeploymentGroup.java:52
      2)



      There are more of these but all the errors refer to the directories and files required by Embedded JBoss to start. All the the directory and files do exist on disk in the location specified in the exception.

      As Maven does, my project is separated into two jars, one containing the production code and the other all the test code. The test jar file contains all the deployment directories and files.

      Can anyone tell me what I'm doing wrong?

      Thanks,
      Dave.

        • 1. Re: Embedded JBoss, Maven, and the ubiquitous Jar

          Hi Dave,

          I had a similar problem once. I have located all the neccessary directories (conf, deploy, deployers etc.) under "src/test/resources" of my maven project I want to test, then the embedded jboss starts correctly.

          I once tried to put the directories into a "test environment" jar, but that doesn't work, because the embedded jboss want real directories.
          Hopes that helps.

          Regards
          Marco

          • 2. Re: Embedded JBoss, Maven, and the ubiquitous Jar
            drathnow

            Marco,

            I already have these directories under "src/test/resources". I assumed the whole point of building a jar file was so you don't have to rely on directories outside the jar file. Am I wrong?

            Dave.

            • 3. Re: Embedded JBoss, Maven, and the ubiquitous Jar
              drathnow


              So am I the only one using Embedded JBoss for unit testing? Am I also the only one trying to use Maven to build and run tests with EJ?

              • 4. Re: Embedded JBoss, Maven, and the ubiquitous Jar

                Hi Dave,

                we are using maven, testng and embedded jboss for testing. But as I mentioned we have the configuration and deployment directories in the articfact we are testing under "src/test/resources".

                Could you explain a little more your structure? Is there a reason why you have all your test code in a separate sub project?

                Marco

                • 5. Re: Embedded JBoss, Maven, and the ubiquitous Jar
                  drathnow

                  Sorry, I guess I wasn't clear. All my test code is in the same project and being built by maven into two jar: on contain production code, one containing test code. The structure of my project is as follows:

                  src/main/java
                  src/main/resources
                  src/test/java
                  src/test/resources

                  I have all the embedded jboss stuff under the src/test/resources directory. However, when Maven builds my project, it is not copying the stuff from the src/test/resources directory into the target/test-classes directory.

                  Any suggestions?

                  • 6. Re: Embedded JBoss, Maven, and the ubiquitous Jar
                    drathnow

                    Hold the Phone!

                    I was wrong. The test resources are being copied over and the file being complained about in the stack trace is really there.

                    Any suggestions?

                    • 7. Re: Embedded JBoss, Maven, and the ubiquitous Jar
                      drathnow

                      After wading through the stack trace, I came across this little tid-bit:

                      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(FileSys
                      temContext.java:253)
                      at org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSys
                      temContext.java:186)
                      at org.jboss.virtual.plugins.context.file.FileSystemContext.(FileSystemContext.java:15
                      0)
                      at org.jboss.virtual.plugins.context.file.FileSystemContext.(FileSystemContext.java:12
                      4)

                      I'm assuming I've missed something from my classpath.
                      at org.jboss.virtual.plugins.context.file.FileSystemContext.(FileSystemContext.java:11
                      3)

                      • 8. Re: Embedded JBoss, Maven, and the ubiquitous Jar
                        drathnow


                        Problem solved. With that last exception, I found this:

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

                        Thanks for all the help.