11 Replies Latest reply on Sep 11, 2009 9:24 AM by Jose Manuel Sánchez

    deploy vritual jar failed on embedded jboss

    Louie Liu Newbie

      Hello,

      I am trying to use embedded jboss to test my EJB3 session bean. It is failed on the vritual jar deployment.

      I am using maven2 + jdk1.5.

      The error message:

      -------------------------------------------------------------------------------
      Test set: TestSuite
      -------------------------------------------------------------------------------
      Tests run: 23, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 6.429 sec <<< FAILURE!
      startup(com.westernasset.calendar.CalendarServiceBeanTest) Time elapsed: 0 sec <<< FAILURE!
      java.lang.RuntimeException: Unable to deploy
      at com.westernasset.calendar.EJB3Container.deploy(EJB3Container.java:66)
      at com.westernasset.calendar.EJB3Container.startup(EJB3Container.java:24)
      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:580)
      at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:398)
      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:82)
      at org.testng.TestRunner.beforeRun(TestRunner.java:490)
      at org.testng.TestRunner.run(TestRunner.java:458)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:301)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276)
      at org.testng.SuiteRunner.run(SuiteRunner.java:191)
      at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
      at org.testng.TestNG.run(TestNG.java:701)
      at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62)
      at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141)
      at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
      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:338)
      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
      Caused by: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      *** CONTEXTS IN ERROR: Name -> Error
      vfs://12094970850210/ -> java.lang.AssertionError: expected a jar or file url, but was vfs://12094970850210/

      at com.westernasset.calendar.EJB3Container.deploy(EJB3Container.java:65)
      ... 27 more
      Caused by: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      *** CONTEXTS IN ERROR: Name -> Error
      vfs://12094970850210/ -> java.lang.AssertionError: expected a jar or file url, but was vfs://12094970850210/

      at com.westernasset.calendar.EJB3Container.deploy(EJB3Container.java:65)
      ... 27 more

      Please help.

      Thanks.

      
      <dependency>
       <groupId>org.jboss.seam.embedded</groupId>
       <artifactId>hibernate-all</artifactId>
       <version>beta3</version>
       <scope>test</scope>
       </dependency>
       <dependency>
       <groupId>org.jboss.seam.embedded</groupId>
       <artifactId>jboss-embedded-all</artifactId>
       <version>beta3</version>
       <scope>test</scope>
       </dependency>
       <dependency>
       <groupId>org.jboss.seam.embedded</groupId>
       <artifactId>thirdparty-all</artifactId>
       <version>beta3</version>
       <scope>test</scope>
       </dependency>
      
      import org.jboss.deployers.spi.DeploymentException;
      import org.jboss.embedded.Bootstrap;
      import org.jboss.virtual.plugins.context.vfs.AssembledContextFactory;
      import org.jboss.virtual.plugins.context.vfs.AssembledDirectory;
      import org.testng.annotations.AfterTest;
      import org.testng.annotations.BeforeTest;
      
      public class EJB3Container {
      
       private static boolean globalSetup = false;
       private static AssembledDirectory jar;
      
       @BeforeTest
       protected void startup() {
       if (globalSetup) {
       return;
       }
       try {
       Bootstrap.getInstance().bootstrap();
       deploy();
       } catch (DeploymentException e) {
       e.printStackTrace();
       }
      
       }
      
       @AfterTest
       protected void shutdown() {
       if (globalSetup) {
       return;
       }
       undeploy();
       }
      
       private void deploy() {
       jar = AssembledContextFactory.getInstance().create("ejbTest.jar");
      
       jar.addClass(BusinessCalendar.class);
      
       jar.addClass(BusinessCalendarDate.class);
      
       jar.addClass(CalendarService.class);
      
       jar.addClass(CalendarServiceSessionBean.class);
      
       jar.addClass(Holiday.class);
      
       jar.addClass(HolidayCalendar.class);
      
       jar.addClass(HolidayHandlerType.class);
      
       jar.mkdir("META-INF").addResource("testPersistence.xml", "persistence.xml");
      
       try {
      
       Bootstrap.getInstance().deploy(jar);
      
       } catch (DeploymentException e) {
       e.fillInStackTrace();
       throw new RuntimeException("Unable to deploy", e);
       }
       }
      
       private static void undeploy() {
       try {
       Bootstrap.getInstance().undeploy(jar);
       AssembledContextFactory.getInstance().remove(jar);
       } catch (DeploymentException e) {
       throw new RuntimeException("Unable to undeploy", e);
       }
       }
      
      }
      
      


        • 1. Re: deploy vritual jar failed on embedded jboss
          Ales Justin Master

          What's the exact line (ok, I see it's 65 or 66, but don't want to do copy/paste :-)) that causes this?

          • 2. Re: deploy vritual jar failed on embedded jboss
            Louie Liu Newbie

            Sorry about it, here is the complete code:

            package com.westernasset.calendar;
            
            import org.jboss.deployers.spi.DeploymentException;
            import org.jboss.embedded.Bootstrap;
            import org.jboss.virtual.plugins.context.vfs.AssembledContextFactory;
            import org.jboss.virtual.plugins.context.vfs.AssembledDirectory;
            import org.testng.annotations.AfterTest;
            import org.testng.annotations.BeforeTest;
            
            public class EJB3Container {
            
             private static boolean globalSetup = false;
             private static AssembledDirectory jar;
            
             @BeforeTest
             protected void startup() {
             if (globalSetup) {
             return;
             }
             try {
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here before bootstrap()!!!");
             Bootstrap.getInstance().bootstrap();
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here after bootstrap()!!!");
             deploy();
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here before deploy()!!!");
             } catch (DeploymentException e) {
             e.printStackTrace();
             }
            
             }
            
             @AfterTest
             protected void shutdown() {
             if (globalSetup) {
             return;
             }
             undeploy();
             }
            
             private void deploy() {
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()-----1!!!");
             jar = AssembledContextFactory.getInstance().create("ejbTest.jar");
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()-----2!!!");
             jar.addClass(BusinessCalendar.class);
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()3!!!");
             jar.addClass(BusinessCalendarDate.class);
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()4!!!");
             jar.addClass(CalendarService.class);
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()5!!!");
             jar.addClass(CalendarServiceSessionBean.class);
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()6!!!");
             jar.addClass(Holiday.class);
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()7!!!");
             jar.addClass(HolidayCalendar.class);
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()8!!!");
             jar.addClass(HolidayHandlerType.class);
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()9!!!");
             jar.mkdir("META-INF").addResource("testPersistence.xml", "persistence.xml");
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here deploy()10!!!");
             try {
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here before deploy(jar)!!!");
             Bootstrap.getInstance().deploy(jar);
             System.out.println("XXXXXXXXXXXXXXXXXXXXXX--------->Working here after deploy(jar)!!!");
             } catch (DeploymentException e) {
             e.fillInStackTrace();
             throw new RuntimeException("Unable to deploy", e);
             }
             }
            
             private static void undeploy() {
             try {
             Bootstrap.getInstance().undeploy(jar);
             AssembledContextFactory.getInstance().remove(jar);
             } catch (DeploymentException e) {
             throw new RuntimeException("Unable to undeploy", e);
             }
             }
            
            }
            


            • 3. Re: deploy vritual jar failed on embedded jboss
              Louie Liu Newbie

              Again, the exact line is:

              ootstrap.getInstance().deploy(jar);


              Thanks a lot!!!

              • 4. Re: deploy vritual jar failed on embedded jboss
                Ales Justin Master

                Trace where this line in Embedded source is used: 'expected a jar or file url, but was'.
                Should probably explain more.

                If you have trouble locating it, let me know.

                • 5. Re: deploy vritual jar failed on embedded jboss
                  Louie Liu Newbie

                  Hi, Here is the place I found:

                  $ grep -H -r "expected a jar or file url, but was" .
                  ./ejb3/src/main/org/jboss/ejb3/deployers/.svn/text-base/PersistenceUnitParsingDe
                  ployer.java.svn-base: assert persistenceUnitRootUrl.getProtocol().equals("j
                  ar") || persistenceUnitRootUrl.getProtocol().equals("file") : "expected a jar or
                  file url, but was " + persistenceUnitRootUrl;
                  ./ejb3/src/main/org/jboss/ejb3/deployers/PersistenceUnitParsingDeployer.java:
                  assert persistenceUnitRootUrl.getProtocol().equals("jar") || persistenceUnitR
                  ootUrl.getProtocol().equals("file") : "expected a jar or file url, but was " + p
                  ersistenceUnitRootUrl;

                  or

                  package org.jboss.ejb3.deployers;

                  import java.net.URL;
                  import java.util.HashMap;

                  import javax.persistence.spi.PersistenceUnitTransactionType;

                  import org.hibernate.cfg.EJB3DTDEntityResolver;
                  import org.hibernate.ejb.packaging.PersistenceXmlLoader;
                  import org.jboss.deployers.structure.spi.DeploymentUnit;
                  import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
                  import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
                  import org.jboss.ejb3.metadata.jpa.spec.PersistenceUnitsMetaData;
                  import org.jboss.ejb3.protocol.jarjar.Handler;
                  import org.jboss.logging.Logger;
                  import org.jboss.virtual.VirtualFile;

                  /**
                  * Find and parse persistence.xml.
                  *
                  * In a jar:
                  * META-INF/persistence.xml
                  *
                  * In a war (JPA 6.2):
                  * WEB-INF/classes/META-INF/persistence.xml
                  *
                  * @author Carlo de Wolf
                  * @version $Revision: 72433 $
                  */
                  public class PersistenceUnitParsingDeployer extends AbstractVFSParsingDeployer
                  {
                  private static final Logger log = Logger.getLogger(PersistenceUnitParsingDeployer.class);

                  static
                  {
                  Handler.init();
                  }

                  public PersistenceUnitParsingDeployer()
                  {
                  super(PersistenceUnitsMetaData.class);
                  setName("persistence.xml");
                  }

                  @Override
                  protected PersistenceUnitsMetaData parse(DeploymentUnit unit, String name, PersistenceUnitsMetaData root) throws Exception
                  {
                  // Try to find the metadata
                  VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;

                  VirtualFile file = vfsDeploymentUnit.getMetaDataFile(name);
                  if (file == null)
                  {
                  // FIXME: hack to get a war persistence unit
                  try
                  {
                  file = vfsDeploymentUnit.getFile("WEB-INF/classes/META-INF/persistence.xml");
                  if(file == null)
                  return null;
                  }
                  catch(IllegalStateException e)
                  {
                  return null;
                  }
                  // -- //
                  }

                  PersistenceUnitsMetaData result = parse(vfsDeploymentUnit, file, root);
                  if (result != null)
                  init(vfsDeploymentUnit, result, file);
                  return result;
                  }

                  @Override
                  protected PersistenceUnitsMetaData parse(VFSDeploymentUnit unit, VirtualFile file, PersistenceUnitsMetaData root)
                  throws Exception
                  {
                  VirtualFile persistenceRoot = file.getParent().getParent();

                  // We can't pass in a VFS url.
                  //URL persistenceUnitRootUrl = persistenceRoot.toURL();

                  // FIXME: is this a supported hack?
                  // This introduces severe regression, will go the jar: url way (EJB-326)
                  //URL persistenceUnitRootUrl = new URL("jarjar:" + persistenceRoot.getHandler().toURL());

                  // http://opensource.atlassian.com/projects/hibernate/browse/EJB-326
                  URL persistenceUnitRootUrl = persistenceRoot.toURL();
                  assert persistenceUnitRootUrl.getProtocol().equals("jar") || persistenceUnitRootUrl.getProtocol().equals("file") : "expected a jar or file url, but was " + persistenceUnitRootUrl;

                  URL persistenceXmlUrl = file.toURL();
                  PersistenceUnitsMetaData metaData = new PersistenceUnitsMetaData(persistenceUnitRootUrl, PersistenceXmlLoader.deploy(persistenceXmlUrl, new HashMap<String, String>(),
                  new EJB3DTDEntityResolver(), PersistenceUnitTransactionType.JTA));
                  log.info("Found persistence units " + metaData);
                  // FIXME: if in EAR then unscoped else scoped
                  return metaData;
                  }
                  }


                  Please help. Thanks a lot.

                  Louie

                  • 6. Re: deploy vritual jar failed on embedded jboss
                    Ales Justin Master

                    Ah, yes, the old persistence deployer problem:
                    - http://www.jboss.com/index.html?module=bb&op=viewtopic&t=132068

                    I'm just in the process of rewriting this piece.
                    Providing our own persistence metadata, plus a new chain of deployers that will handle it.
                    I'll post here when it's done.

                    • 7. Re: deploy vritual jar failed on embedded jboss
                      Alex Grönholm Novice

                      It's been a month now, and still nothing? Looks like Embedded is a very low priority project at JBoss. What are we supposed to do in the meantime? As it stands, Embedded beta 3 can't be used because the old deployment style doesn't work anymore, and the new one hasn't been documented yet.

                      • 8. Re: deploy vritual jar failed on embedded jboss
                        Ales Justin Master

                        See this discussion:
                        - http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4154473#4154473
                        With what we have now - VFS and ability to handle nested jars in memory - it's not so trivial to get it right; specially with such bad spec assumption.

                        • 9. Embedded jboss Beta 3 Status
                          Eric Huang Newbie

                          Hi,
                          I am new to Embedded JBoss (the latest version beta3). I believe it is a great tool and has many value added. I am planning to use for JUnit testing and
                          from end to end in a lightweight server.
                          However, I can't get the samples working. I stared with this link and didn't get very far. http://wiki.jboss.org/wiki/EmbeddedAndJavaSE
                          -- env.
                          -- JDK 1.5
                          -- MYEclipse version 6.M
                          -- XP
                          -- Local version of JBoss AS 4.04. 4.2.2 and 5.x beta. (this shouldn't matter, right? because the embedded one came with its own)


                          -- added an oracle-ds.xml to the deploy directory.
                          -- I solved the JABX2.1 problem by placing the correct version jar to the directory.
                          -- Problem is ***Missing CONTEXT DEPENDENCY ***

                          I after 2 days looking around (not too good job on my end) I found these comments.

                          Is there a fix? Did anyone has a Junit test version working for these(ds.xml, jndi, annotation, ejb3, jta, etc) ? AND HOW?

                          IS THERE A WORK AROUND? Many thanks in advance.

                          Why there isn't a fix release quicker? DBUnit is just one small test case.

                          This tool has good idea for pluggable Standalone, Jboss, tomcat. etc.
                          The Hard part is for it to work and find sample deployment and config doc.




                          • 10. Re: deploy vritual jar failed on embedded jboss
                            Paul Hankes Drielsma Newbie

                            Has anyone found a solution for this? I have a test suite that was working on Embedded JBoss beta 2 without maven, but I'm having a terrible time transitioning it to maven. With beta 2 dependencies, I get errors like "No container configured called Stateless Beans".

                            With Beta 3, I get this VFS deployment error. I've tried excluding a variety of thing like the org.jboss.ejb3 VFS deployers and getting the latest ones from the snapshots repository, but no dice. I'm using maven 2.0.9.

                            It's exactly the same problem: if I add a persistence.xml file to my virtual jar, then this problem arises. Otherwise, it's fine (but obviously deployment fails because the persistence unit isn't found). I copied my code exactly from Bill Burke's Wiki pages. Any help would be greatly appreciated here.

                            Best,
                            Pablo

                            • 11. Re: deploy vritual jar failed on embedded jboss
                              Jose Manuel Sánchez Newbie

                              RE: Does anyone have a solution for this?

                              In the last SP10 it still happens

                              Thx.
                              Jose.