10 Replies Latest reply on May 24, 2010 6:01 PM by Dan Allen

    Weld Embedded Error

    Ken Finnigan Master

      Hi,

       

      I'm getting an error when using the Weld Embedded container for Arquillian.  I get this error when running tests within the Seam i18n module or when I try to build Arquillian from source.

       

      The error is:

       

      -------------------------------------------------------------------------------
      Test set: org.jboss.arquillian.weld.WeldEmbeddedIntegrationTestCase
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.29 sec <<< FAILURE!
      org.jboss.arquillian.weld.WeldEmbeddedIntegrationTestCase  Time elapsed: 0 sec  <<< ERROR!
      java.lang.NoClassDefFoundError: ch/qos/cal10n/IMessageConveyor
           at org.jboss.weld.logging.MessageConveyorFactory.load(MessageConveyorFactory.java:43)
           at org.jboss.weld.logging.MessageConveyorFactory.messageConveyerFactory(MessageConveyorFactory.java:50)
           at org.jboss.weld.logging.LoggerFactory.<init>(LoggerFactory.java:41)
           at org.jboss.weld.logging.LoggerFactory.loggerFactory(LoggerFactory.java:59)
           at org.jboss.weld.bootstrap.WeldBootstrap.<clinit>(WeldBootstrap.java:111)
           at org.jboss.arquillian.weld.WeldSEContainer.deploy(WeldSEContainer.java:112)
           at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:62)
           at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:50)
           at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
           at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
           at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:78)
           at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:151)
           at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
           at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:170)
           at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:272)
           at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:166)
           at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
           at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:118)
           at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
           at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
           at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
           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:345)
           at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
      Caused by: java.lang.ClassNotFoundException: ch.qos.cal10n.IMessageConveyor
           at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
           at java.security.AccessController.doPrivileged(Native Method)
           at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
           at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
           ... 28 more

       

      Adding the following dependency to the weld-embedded pom resolves it, but did not know if that was the best or only way to resolve it?

       

      <dependency>
               <groupId>ch.qos.cal10n</groupId>
               <artifactId>cal10n-api</artifactId>
               <version>0.7.2</version>
      </dependency>

       

       

      Thanks

      Ken

        • 1. Re: Weld Embedded Error
          Aslak Knutsen Master

          That dependency is suppose to get pulled in via: org/slf4j/slf4j-ext/1.5.10/slf4j-ext-1.5.10.pom

           

          There is a problem tho, some maven repositories(e.g. the GlassFish one) have replaced the original pom with a version without the  cal10n-api dependency. If you get  slf4j-ext from Maven Central or Jboss Developers repo you should be fine.

          • 2. Re: Weld Embedded Error
            Ken Finnigan Master

            I pulled in that dependency manually and that did fix the error when running the weld-embedded tests within Arquillian.

             

            I am now getting an unusual error running my own test within weld-embedded.  Has anyone seen anything like this before?

             

            -------------------------------------------------------------------------------
            Test set: org.jboss.seam.international.test.locale.AvailableLocalesTest
            -------------------------------------------------------------------------------
            Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.07 sec <<< FAILURE!
            org.jboss.seam.international.test.locale.AvailableLocalesTest  Time elapsed: 0.421 sec  <<< ERROR!
            org.jboss.arquillian.impl.event.FiredEventException: org.jboss.weld.exceptions.DefinitionException: Exception #0 :null
                 at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:68)
                 at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
                 at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:78)
                 at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:151)
                 at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:170)
                 at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:272)
                 at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:166)
                 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                 at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:118)
                 at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
                 at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
                 at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
                 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:345)
                 at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
            Caused by: org.jboss.weld.exceptions.DefinitionException: Exception #0 :null
                 at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:55)
                 at org.jboss.weld.bootstrap.events.BeforeBeanDiscoveryImpl.fire(BeforeBeanDiscoveryImpl.java:66)
                 at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:361)
                 at org.jboss.arquillian.weld.WeldSEContainer.deploy(WeldSEContainer.java:113)
                 at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:62)
                 at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:50)
                 at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
                 ... 18 more

            org.jboss.seam.international.test.locale.AvailableLocalesTest  Time elapsed: 0.421 sec  <<< ERROR!
            java.util.EmptyStackException
                 at java.util.Stack.peek(Stack.java:85)
                 at java.util.Stack.pop(Stack.java:67)
                 at org.jboss.arquillian.impl.EventTestRunnerAdaptor.afterClass(EventTestRunnerAdaptor.java:87)
                 at org.jboss.arquillian.junit.Arquillian$3$2.evaluate(Arquillian.java:174)
                 at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:272)
                 at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:166)
                 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                 at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:118)
                 at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
                 at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
                 at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
                 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:345)
                 at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)

            • 3. Re: Weld Embedded Error
              Aslak Knutsen Master

              Yes, I have seen that one before, but I don't remember the cause. :o/

               

              Can you attach your test case?

              • 4. Re: Weld Embedded Error
                Ken Finnigan Master

                Aslak,

                 

                I've attached a simplified test case that has the problem.

                 

                Any thoughts as to a resolution would be appreciated.

                 

                Ken

                • 5. Re: Weld Embedded Error
                  Aslak Knutsen Master

                  Could you provided it in something else then zipx format ?

                   

                  A copy/paste of the source on the forum is ok.

                  Use the Wiki Markup button and {code:java} ... {code}

                  • 6. Re: Weld Embedded Error
                    Lincoln Baxter III Master

                    I'm getting the same errors now. Here's my test-case:

                     

                     

                    {code:java}/*
                    * JBoss, Home of Professional Open Source
                    * Copyright 2010, Red Hat, Inc., and individual contributors
                    * by the @authors tag. See the copyright.txt in the distribution for a
                    * full listing of individual contributors.
                    *
                    * This is free software; you can redistribute it and/or modify it
                    * under the terms of the GNU Lesser General Public License as
                    * published by the Free Software Foundation; either version 2.1 of
                    * the License, or (at your option) any later version.
                    *
                    * This software is distributed in the hope that it will be useful,
                    * but WITHOUT ANY WARRANTY; without even the implied warranty of
                    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
                    * Lesser General Public License for more details.
                    *
                    * You should have received a copy of the GNU Lesser General Public
                    * License along with this software; if not, write to the Free
                    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
                    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
                    */
                    package org.jboss.seam.international.status.builder;

                    import static org.junit.Assert.assertEquals;

                    import javax.inject.Inject;

                    import org.jboss.arquillian.api.Deployment;
                    import org.jboss.arquillian.junit.Arquillian;
                    import org.jboss.seam.international.status.Bundles;
                    import org.jboss.seam.international.status.MessageFactory;
                    import org.jboss.shrinkwrap.api.Archive;
                    import org.jboss.shrinkwrap.api.ArchivePaths;
                    import org.jboss.shrinkwrap.api.ShrinkWrap;
                    import org.jboss.shrinkwrap.api.spec.JavaArchive;
                    import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
                    import org.junit.Test;
                    import org.junit.runner.RunWith;

                    /**
                    * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
                    *
                    */
                    @RunWith(Arquillian.class)
                    public class TemplateMessageTest
                    {
                       @Deployment
                       public static Archive<?> createTestArchive()
                       {
                          return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(MessageFactory.class, Bundles.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
                       }

                       @Inject
                       MessageFactory factory;

                       @Test
                       public void testParameterizedTemplate() throws Exception
                       {
                          String expected = "There are 5 cars, and they are all green; green is the best color.";
                          TemplateMessage builder = factory.info("There are {0} cars, and they are all {1}; {1} is the best color.", 5, "green");
                          assertEquals(expected, builder.build().getText());
                       }

                       @Test
                       public void testParameterizedTemplateInsertsParamNumbersIfNotEnoughParamValues() throws Exception
                       {
                          String expected = "There are 5 cars, and they are all {1}; {1} is the best color.";
                          TemplateMessage builder = factory.warn("There are {0} cars, and they are all {1}; {1} is the best color.", 5);
                          assertEquals(expected, builder.build().getText());
                       }

                       @Test
                       public void testPlainTextTemplate() throws Exception
                       {
                          String expected = "There are 5 cars, and they are all green; green is the best color.";
                          TemplateMessage builder = factory.error("There are 5 cars, and they are all green; green is the best color.");
                          assertEquals(expected, builder.build().getText());
                       }

                       @Test
                       public void testPlainTextTemplateWithParamsIsUnmodified() throws Exception
                       {
                          String expected = "There are 5 cars, and they are all green; green is the best color.";
                          TemplateMessage builder = factory.fatal("There are 5 cars, and they are all green; green is the best color.", "blue", "red", 6);
                          assertEquals(expected, builder.build().getText());
                       }
                    }{code}

                    • 7. Re: Weld Embedded Error
                      Ken Finnigan Master

                      Sorry about that!

                       

                      Here is the Bean I am using:

                       

                      {code}

                      package org.jboss.seam.test;

                       

                      import javax.annotation.PostConstruct;

                      import javax.enterprise.context.ApplicationScoped;


                      @ApplicationScoped

                      public class TestBean

                      {

                         private String empty = null;

                       

                         @PostConstruct

                         public void init()

                         {

                            empty = "empty";

                         }

                      }

                      {code}

                       

                      And here is the test case:

                       

                      {code}

                      package org.jboss.seam.test;

                      import javax.inject.Inject;
                      import org.jboss.arquillian.api.Deployment;
                      import org.jboss.arquillian.junit.Arquillian;
                      import org.jboss.shrinkwrap.api.ArchivePaths;
                      import org.jboss.shrinkwrap.api.ShrinkWrap;
                      import org.jboss.shrinkwrap.api.spec.JavaArchive;
                      import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
                      import org.junit.Assert;
                      import org.junit.Test;
                      import org.junit.runner.RunWith;

                      @RunWith(Arquillian.class)
                      public class TestClass
                      {
                         @Deployment
                         public static JavaArchive createTestArchive()
                         {
                            return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(Test.class).addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
                         }

                         @Inject
                         TestBean bean;

                         @Test
                         public void test()
                         {
                            Assert.assertNotNull(bean);
                         }
                      }
                      {code}
                      • 8. Re: Weld Embedded Error
                        Aslak Knutsen Master

                        This runs here if I change from

                         

                        {code:java}

                         

                        return ShrinkWrap.create("test.jar", JavaArchive.class)
                                         .addClasses(Test.class)
                                         .addManifestResource(
                                             new ByteArrayAsset(new byte[0]),
                                             ArchivePaths.create("beans.xml"));

                         

                        {code}

                         

                        to

                         

                         


                        {code:java}

                         

                        return ShrinkWrap.create("test.jar", JavaArchive.class)
                                         .addClasses(TestBean.class)
                                         .addManifestResource(
                                             new ByteArrayAsset(new byte[0]),
                                             ArchivePaths.create("beans.xml"));

                         

                        {code}

                         

                         

                         

                        addClasses in the example deployes JUnits @Test class, not your TestBean.

                        • 9. Re: Weld Embedded Error
                          Ken Finnigan Master

                          That's weird, I made the same change and still get the same error.

                          • 10. Re: Weld Embedded Error
                            Dan Allen Master

                            There are two problems going on here. Weld is dropping the cause of the exception, so all you see is.

                            Exception #0: null

                             

                            Which is basically telling you, "You have a problem, but it could be anything."

                             

                            The real problem was that Weld was encountering a NoClassDefFoundException:

                            java.lang.NoClassDefFoundError: org/jboss/weld/extensions/util/annotated/NewAnnotatedTypeBuilder

                            And that problem is caused by the fact that i18n relies on a snapshot of Seam XML Config, which relies on a snapshot of Weld Extensions, which you probably need to build again.

                             

                            The problem in Weld has been filed as WELD-531

                             

                            Btw, I encourage you to use your debugger when you encounter such problems. Since we publish the source artifacts to Maven, it's really easy to crack open the debugger and put a breakpoint where the exception is being thrown.