【发布时间】:2016-02-03 22:52:24
【问题描述】:
我有一个使用weld se 的小cli 应用程序,如果我从eclipse 中运行该应用程序,它可以正常工作 (使用weld se的main方法:org.jboss.weld.environment.se.StartMain)
问题是我无法创建一个可以运行的可执行 jar。目前我使用 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>
我还尝试了阴影插件:
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
但在所有情况下,我都会遇到同样多的错误:
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
...
同时我也尝试添加
<scan>
<exclude name="org.jboss.weld.**" />
</scan>
按照here 的建议发送到我的 beans.xml。没有变化...
【问题讨论】:
-
您的类文件是否正确捆绑?您可能需要更改您的
<scope> -
这是什么意思? pom中的依赖范围?都有默认范围,但测试的东西有测试。
-
您的 POM 中没有指定 jar 依赖项的依赖项部分吗?有一个名为 scope 的标签,它指定类是否应该捆绑在您的最终 jar 中,或者是否将由运行时环境提供,等等
-
正如我所说我使用默认范围->编译。因为这是一个独立的应用程序,所以运行时是一个简单的 jvm - 没有提供任何东西。
-
好吧,我相当肯定你没有正确设置你的 pom 以在运行时包含类文件。它在您的 IDE 中工作的原因是因为它们很可能被 IDE 自动解析,而当您尝试通过命令行构建和运行时没有完成
标签: java maven executable-jar weld weld-se