1 Reply Latest reply on Oct 22, 2013 2:14 AM by Jozef Hartinger

    Weld-se not working with groovy when bundled into a fat jar together

    Jianbao Tao Newbie

      I want to use groovy together with weld-se. However, I have never done this before, so I wanted to make a little experiment first. Unfortunately, groovy and weld-se don't seem to get along for the time being. So, I have this experiment class:

      public class HelloWorld {

          public void printHello( @Observes ContainerInitialized event) {

              System.out.println("Hello, World!");

          }

      }

       

      I use gradle to build. All the dependencies are bundled into a fat jar. BTW, I followed this workaround to make weld-se work in a fat jar. I use this command to invoke the program:

      java -cp build/libs/weld-se-1.0-SNAPSHOT.jar org.jboss.weld.environment.se.StartMain

       

      So, here is the problem. When I only this dependency in gradle:

      compile 'org.jboss.weld.se:weld-se:2.0.4.Final'

      everything works properly. However, if I add this groovy dependency:

      compile 'org.codehaus.groovy:groovy-all:2.1.7'

      Then I will get exceptions. Odd yet, the exceptions are not always the same: they are two versions, and it seems random to me which one of the two will actually happen.

       

      So, what's going on here? Is it possible right now to make weld-se and groovy work together in a fat jar? Thank you very much.

       

      Here is one version of the exceptions I have seen:

      Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: javax/servlet/ServletOutputStream

        at org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:71)

        at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:48)

        at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:56)

        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.createClassBeans(ConcurrentBeanDeployer.java:72)

        at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:264)

        at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:497)

        at org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)

        at org.jboss.weld.environment.se.Weld.initialize(Weld.java:143)

        at org.jboss.weld.environment.se.StartMain.go(StartMain.java:41)

        at org.jboss.weld.environment.se.StartMain.main(StartMain.java:52)

      Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream

        at java.lang.Class.getDeclaredMethods0(Native Method)

        at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)

        at java.lang.Class.getDeclaredMethods(Class.java:1845)

        at java.lang.Class.getEnclosingMethod(Class.java:932)

        at org.jboss.weld.util.reflection.Reflections.isNonStaticInnerClass(Reflections.java:388)

        at org.jboss.weld.util.Beans.isTypeManagedBeanOrDecoratorOrInterceptor(Beans.java:514)

        at org.jboss.weld.bootstrap.BeanDeployer.createClassBean(BeanDeployer.java:226)

        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:74)

        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:72)

        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)

        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)

        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

        at java.util.concurrent.FutureTask.run(FutureTask.java:166)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

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

      Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletOutputStream

        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

        ... 16 more

       

      Here is the other one:

      Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: org/apache/tools/ant/Task

        at org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:71)

        at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:48)

        at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:56)

        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.createClassBeans(ConcurrentBeanDeployer.java:72)

        at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:264)

        at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:497)

        at org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:63)

        at org.jboss.weld.environment.se.Weld.initialize(Weld.java:143)

        at org.jboss.weld.environment.se.StartMain.go(StartMain.java:41)

        at org.jboss.weld.environment.se.StartMain.main(StartMain.java:52)

      Caused by: java.lang.NoClassDefFoundError: org/apache/tools/ant/Task

        at java.lang.ClassLoader.defineClass1(Native Method)

        at java.lang.ClassLoader.defineClass(ClassLoader.java:792)

        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)

        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)

        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

        at java.lang.Class.getEnclosingMethod0(Native Method)

        at java.lang.Class.getEnclosingMethodInfo(Class.java:959)

        at java.lang.Class.getEnclosingConstructor(Class.java:1035)

        at org.jboss.weld.util.reflection.Reflections.isNonStaticInnerClass(Reflections.java:388)

        at org.jboss.weld.util.Beans.isTypeManagedBeanOrDecoratorOrInterceptor(Beans.java:514)

        at org.jboss.weld.bootstrap.BeanDeployer.createClassBean(BeanDeployer.java:226)

        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:74)

        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:72)

        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)

        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)

        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

        at java.util.concurrent.FutureTask.run(FutureTask.java:166)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

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

      Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.Task

        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

        ... 27 more