我正在使用Wildfly Weld在JavaSE上使用JavaSE在CDI2.0上进行POC。我能够使用maven exec:java命令运行该应用程序。我添加了带有依赖插件的maven单个jar,以使用Java主类制作单个jar。拿了一个jar并执行了jar也很好(java -jar appl * .jar)。
我已经使用SmallRye添加了FaultTolerence(Microprofile)。使用maven exec:java命令也可以正常工作。但是不能在Jar中工作,并且依赖项出现以下提到的错误。尽管我在beans.xml中添加了<exclude name="org.jboss.weld.**" />
如何解决此问题?
我想要一个具有所有依赖性的jar,并且运行时没有任何问题
项目在我的git repo https://github.com/Gnanapandithan/standalone
中可用我已遵循http://www.mastertheboss.com/jboss-frameworks/cdi/building-a-cdi-2-standalone-java-application并添加了容错(SmallRye),但没有用。
@Asynchronous
@Retry(maxRetries = 2,retryOn = NullPointerException.class, delay = 200)
@Fallback(fallbackMethod = "sayHello")
public Future<String> greet() {
try {
System.out.println(" Greet ..................");
} catch (Exception e) {
e.printStackTrace();
}
String s = null;
s.length();
System.out.println("Hello World!");
return CompletableFuture.completedFuture("OK");
}
private Future<String> sayHello() {
System.out.println(" sayHello...");
return CompletableFuture.completedFuture( "I am from Hello..");
}
pom.XML
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0.SP1</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-shaded</artifactId>
<version>3.1.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.fault-tolerance</groupId>
<artifactId>microprofile-fault-tolerance-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-fault-tolerance</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-config</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13-beta-1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.demo.small.AppMain</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.demo.small.AppMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
例外:
INFO: WELD-001125: Illegal bean type rx.functions.Func1<java.util.List<? extends rx.Observable<?>>, rx.Observable<?>[]> ignored on [EnhancedAnnotatedTypeImpl] final static class rx.internal.util.InternalObservableUtils$ToArrayFunc1
Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: Exception List with 10 exceptions:
Exception 0 :
org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type InjectionPoint with qualifiers @Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedMethod] @Produces io.smallrye.config.inject.ConfigProducer.getConfig(InjectionPoint)
at io.smallrye.config.inject.ConfigProducer.getConfig(ConfigProducer.java:0)
Possible dependencies:
- Implicit Bean [javax.enterprise.inject.spi.InjectionPoint] with qualifiers [@Default],
- Managed Bean [class io.smallrye.config.inject.ConfigInjectionBean$InjectionPointMetadataInjectionPoint] with qualifiers [@Any @Default]
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:386)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:290)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:143)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:164)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:526)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:64)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
at org.jboss.weld.executor.CommonForkJoinPoolExecutorServices.lambda$wrap$0(CommonForkJoinPoolExecutorServices.java:70)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinTask.externalAwaitDone(ForkJoinTask.java:326)
at java.util.concurrent.ForkJoinTask.doJoin(ForkJoinTask.java:391)
at java.util.concurrent.ForkJoinTask.quietlyJoin(ForkJoinTask.java:1079)
at java.util.concurrent.ForkJoinPool.invokeAll(ForkJoinPool.java:2725)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:59)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:67)
at org.jboss.weld.bootstrap.ConcurrentValidator.validateBeans(ConcurrentValidator.java:62)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:487)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:490)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:93)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:804)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:176)
at com.demo.small.AppMain.main(AppMain.java:12)
Exception 1 :
org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type InjectionPoint with qualifiers @Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedMethod] @Dependent @Produces @ConfigProperty io.smallrye.config.inject.ConfigProducer.produceDoubleConfigProperty(InjectionPoint)
at io.smallrye.config.inject.ConfigProducer.produceDoubleConfigProperty(ConfigProducer.java:0)
Possible dependencies:
- Implicit Bean [javax.enterprise.inject.spi.InjectionPoint] with qualifiers [@Default],
- Managed Bean [class io.smallrye.config.inject.ConfigInjectionBean$InjectionPointMetadataInjectionPoint] with qualifiers [@Any @Default]
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:386)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:290)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:143)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:164)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:526)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:64)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
at org.jboss.weld.executor.CommonForkJoinPoolExecutorServices.lambda$wrap$0(CommonForkJoinPoolExecutorServices.java:70)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinTask.externalAwaitDone(ForkJoinTask.java:326)
at java.util.concurrent.ForkJoinTask.doJoin(ForkJoinTask.java:391)
at java.util.concurrent.ForkJoinTask.quietlyJoin(ForkJoinTask.java:1079)
at java.util.concurrent.ForkJoinPool.invokeAll(ForkJoinPool.java:2725)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:59)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:67)
at org.jboss.weld.bootstrap.ConcurrentValidator.validateBeans(ConcurrentValidator.java:62)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:487)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:490)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:93)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:804)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:176)
at com.demo.small.AppMain.main(AppMain.java:12)
Exception 2 :
org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type InjectionPoint with qualifiers @Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedMethod] @Dependent @Produces @ConfigProperty io.smallrye.config.inject.ConfigProducer.produceBooleanConfigProperty(InjectionPoint)
at io.smallrye.config.inject.ConfigProducer.produceBooleanConfigProperty(ConfigProducer.java:0)
Possible dependencies:
- Implicit Bean [javax.enterprise.inject.spi.InjectionPoint] with qualifiers [@Default],
- Managed Bean [class io.smallrye.config.inject.ConfigInjectionBean$InjectionPointMetadataInjectionPoint] with qualifiers [@Any @Default]
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:386)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:290)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:143)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:164)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:526)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:64)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
at org.jboss.weld.executor.CommonForkJoinPoolExecutorServices.lambda$wrap$0(CommonForkJoinPoolExecutorServices.java:70)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinTask.externalAwaitDone(ForkJoinTask.java:326)
at java.util.concurrent.ForkJoinTask.doJoin(ForkJoinTask.java:391)
at java.util.concurrent.ForkJoinTask.quietlyJoin(ForkJoinTask.java:1079)
at java.util.concurrent.ForkJoinPool.invokeAll(ForkJoinPool.java:2725)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:59)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:67)
at org.jboss.weld.bootstrap.ConcurrentValidator.validateBeans(ConcurrentValidator.java:62)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:487)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:490)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:93)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:804)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:176)
at com.demo.small.AppMain.main(AppMain.java:12)