4

I have a little cli application that uses weld se that works fine if i run the application from within eclipse (using the main method from weld se: org.jboss.weld.environment.se.StartMain)

The problem is i can't create an executable jar that works. At the moment i use maven-assembly-plugin:

<plugin>                                                                      
    <artifactId>maven-assembly-plugin</artifactId>                            
    <configuration>                                                           
        <archive>                                                             
            <manifest>                                                        
                <addClasspath>true</addClasspath>                             
                <mainClass>org.jboss.weld.environment.se.StartMain</mainClass>
            </manifest>                                                       
        </archive>                                                            
        <descriptorRefs>                                                      
            <descriptorRef>jar-with-dependencies</descriptorRef>              
        </descriptorRefs>                                                     
    </configuration>                                                          
    <executions>                                                              
        <execution>                                                           
            <id>make-my-jar-with-dependencies</id>                            
            <phase>package</phase>                                            
            <goals>                                                           
                <goal>single</goal>                                           
            </goals>                                                          
        </execution>                                                          
    </executions>                                                             
</plugin>

I also tried the shade plugin with: <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

But in all cases i get the same many errors:

Nov 03, 2015 5:50:21 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException
INFO: WELD-000119: Not generating any bean definitions from org.jboss.weld.servlet.api.helpers.ForwardingServletListener because of underlying class loading error: Type javax.servlet.ServletContextListener not found.  If this is unexpected, enable DEBUG logging to see the full error.
... many of this kind with different classes
Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: java.lang.InternalError: Enclosing method not found
...
Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.InternalError: Enclosing method not found
...
Caused by: java.lang.InternalError: Enclosing method not found
...

In meantime i also tried to add

<scan>
    <exclude name="org.jboss.weld.**" />
</scan>

to my beans.xml as suggested here. No change...

dermoritz
  • 12,519
  • 25
  • 97
  • 185
  • are your class files being bundled properly? you might have to change your `` – user1231232141214124 Nov 03 '15 at 17:08
  • what does this mean? scope of dependencies in pom? all have default scope but test stuff has test. – dermoritz Nov 03 '15 at 17:17
  • Do you not have a dependency section of your POM where you specify your jar dependencies? There is a tag called scope which specifies if the classes should be bundled within your final jar or if the will be provided by the runtime environment, etc – user1231232141214124 Nov 03 '15 at 17:21
  • as i said i use default scope->compile. since this is a standalone app the runtime is a simple jvm - nothing is provided. – dermoritz Nov 03 '15 at 17:29
  • ok well im fairly certain you have no set your pom up properly to include the class files at runtime. The reason it is working in your IDE is because they are most likely being autoresolved by the IDE which is not being done when you try building and running via command line – user1231232141214124 Nov 03 '15 at 17:33
  • no this is not the reason, i can see all the classes in the resulting jar. it is not my first maven/executable-jar project, but my first using weld – dermoritz Nov 03 '15 at 17:37

1 Answers1

0

The best solution seems to be to not create an über-jar (all dependencies within jar) but put all dependencies into lib folder. For me this solution worked fine. It also worked (nearly) after i added several more pattern to scan/ exclude in beans.xml but this (or the über jar it self) caused another odd problem.

Community
  • 1
  • 1
dermoritz
  • 12,519
  • 25
  • 97
  • 185