1 Reply Latest reply on Jan 8, 2018 3:04 AM by mkouba

    ClassDefNotFoundException at start of Weld-SE Application

    daniel.danger

      Hi guys,

       

      Actually i want to create a small "Hello World"-like Example of a JavaSE-Application with Weld-SE, but it seems that there is a runtime error.

      Here is my class:

      package de.mycompany.weldapp;  import java.util.List;  import javax.enterprise.event.Observes; import javax.inject.Singleton;  
      import org.jboss.weld.environment.se.bindings.Parameters; import org.jboss.weld.environment.se.events.ContainerInitialized;  
      @Singleton public class App { 
        public void printHello(@Observes ContainerInitialized event,     @Parameters List parameters) { 
          System.out.println("Hello " + parameters.get(0)); 
        } 
      }

      An here is my pom.xml:

       4.0.0  de.mycompany 
      weldapp 0.0.1-SNAPSHOT jar  weldapp 
      http://maven.apache.org   
      UTF-8     org.jboss.weld.se weld-se-shaded 3.0.2.Final   
      junit 
      junit 3.8.1 test   org.apache.maven.plugins 
      maven-compiler-plugin 
      3.7.0  javax.enterprise cdi-api2.0 
      provided  
        
       
       
       
      maven-jar-plugin 
      3.0.2 
        
       
      de.mycompany.weldapp.App 
        
          

      I have installed Java JDK 1.8.0_151 and Maven 3.5.2. The compile-process was successful, but when i execute the created jar-file in the target-directory, i will get the following error all the time:

      A JNI error has occurred, plase check your installation and try again. Exception in thread "main" java.lang.noClassDefFoundError: org/jboss/environment/se/events/ContainerInitialized 
      at java.lang.Class.getDeclaredMethods0(native Method) ... 
      Caused by : java.lang.ClassNotFoundException: org.jboss.weld.environment.se.events.ContainerInitialized 
      at java.net.URLCLassLoader.findClass(Unknown Source) 
      ...

      Is there anything that i did not mention or that i am doing wrong? Is there any dependency, that was not included?

      I have installed Java, Maven and Eclipse again, but nothing helped.

      Thanks a lot Daniel