7 Replies Latest reply on Feb 19, 2016 3:57 AM by lolz512

    DeploymentException: Malformed class name

    lolz512

      Hello can anybody help me? I cannot seem to run my Java SE(java 8) w/ CDI Weld enabled on an uber jar. I used maven-shade to create the uber jar. Here is the stacktrace that I always get:

       

      Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: Malformed class name

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

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

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

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

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

              at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:397)

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

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

              at org.apache.deltaspike.cdise.weld.WeldContainerControl.boot(WeldContainerControl.java:68)

              at com.objective.ecm.service.base.server.cli.ServiceStarter.start(ServiceStarter.java:44)

              at com.objective.ecm.asyncjob.copyservice.App.main(App.java:34)

      Caused by: java.lang.InternalError: Malformed class name

              at java.lang.Class.getSimpleName(Unknown Source)

              at java.lang.Class.isAnonymousClass(Unknown Source)

              at org.jboss.weld.util.reflection.Reflections.isStaticNestedClass(Reflections.java:411)

              at org.jboss.weld.util.reflection.Reflections.isTopLevelOrStaticNestedClass(Reflections.java:425)

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

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

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

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

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

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

              at java.util.concurrent.FutureTask.run(Unknown Source)

              at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

              at java.lang.Thread.run(Unknown Source)

        • 1. Re: DeploymentException: Malformed class name
          tremes

          Hi,

          Of course we can try to help but I guess I would need more information. It looks like you have some anonymous class which was picked up as CDI bean but looking at Class.getSimpleName I don't understand how can be satisfied this condition:

          int length = simpleName.length();
          if (length < 1 || simpleName.charAt(0) != '$')
             throw new InternalError("Malformed class name");
          

           

          I see you're using DeltaSpike to boot your SE container. Can you provide some example or reproducer please?

          • 2. Re: DeploymentException: Malformed class name
            tremes

            Ok so I think I was able to reproduce it. I found [WELD-1081] Weld crashes when attempting to read malformed class names - JBoss Issue Tracker so I guess you have some similar Groovy class at your classpath right?

            • 3. Re: DeploymentException: Malformed class name
              lolz512

              @Tomas Remes, Thanks for your response.
              We do not have any Groovy class in our project. We have some anonymous class, typically lambda expression. Samples:

               

              We have a functional interface:

              @FunctionalInterface

              public interface TransactionCallback {

                  void doInOpenTransaction(EntityManager entityManager);

              }

               

              Then a class that uses the interface:

              public class EntityManagerUtils {

                   public static boolean transact(EntityManager em, TransactionCallback transactions) {

                      try {

                          em.getTransaction().begin();

                          transactions.doInOpenTransaction(em);

                          em.getTransaction().commit();

                          return true;

                      } catch (Exception e) {}

                   }

                   public static boolean persist(EntityManager em, Object object, String methodName) {

                      return transact(em, entityManager -> {

                          em.persist(object);

                      });

                   }

              }


              Sample statements in some class:

              EntityManagerUtils.transact(em, (EntityManager em) -> {

                 em.merge(abc);

                 em.merge(xyz);

              });

              • 4. Re: DeploymentException: Malformed class name
                mkouba

                Hi,

                it would be great if we knew wich class name is malformed and throws the exception. If possible, debug the code and use a conditional breakpoint inside the Class.getSimpleName() method. Or provide a simple reproducer so that could debug the code instead

                • 5. Re: DeploymentException: Malformed class name
                  lolz512

                  Okay so it seems oracle ojdbc6 is causing the malformed class name. I just added <weld:exclude name="oracle.**" /> to beans.xml

                   

                  Do you guys recommend to set bean-discovery-mode setting to 'none'? And just include manually? Because right now my setting is 'all' and it seems like it is causing some issues because I have a lot of dependencies included.

                   

                  Thanks

                  • 6. Re: DeploymentException: Malformed class name
                    mkouba

                    Yes, you could disable the discovery completely and add bean classes manually, see also Programmatic Bootstrap API. On the other hand, this might not be the best approach for more complex scenarios (a lot of bean classes from different packages).

                    • 7. Re: DeploymentException: Malformed class name
                      lolz512

                      Okay thanks I set it to all and exclude instead. Thank you guys