I am trying to run this example in java SE mode from my windows command prompt. I have built a jar with all dependencies included in it and running it from my command prompt.
but, keep getting this error. From this answer, i understand that there could be multiple StepContext classes in my runtime classpath.
i now replaced the maven-assembly plugin with the maven-shade plugin to build my fat jar and i can see the following warning while packaging the jar
[WARNING] javax.inject-1.jar, weld-se-2.2.15.Final.jar define 6 overlapping classes:
[WARNING] - javax.inject.Inject
[WARNING] - javax.inject.Singleton
[WARNING] - javax.inject.Scope
[WARNING] - javax.inject.Named
[WARNING] - javax.inject.Provider
[WARNING] - javax.inject.Qualifier
I updated the following dependency to provided and now i don't see the above said warning while packaging but, am still getting exceptions when running the newly generated jar
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
Current exception while executing the JAR file
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 @BatchProperty public org.jberet.creation.BatchBeanProducer.getStringList(InjectionPoint)
at org.jberet.creation.BatchBeanProducer.getStringList(BatchBeanProducer.java:0)
Possible dependencies:
- Implicit Bean [javax.enterprise.inject.spi.InjectionPoint] with qualifiers [@Default],
- Managed Bean [class org.jboss.weld.manager.BeanManagerImpl$InstanceInjectionPoint] with qualifiers [@Any @Default],
- Managed Bean [class org.jboss.weld.injection.EmptyInjectionPoint] with qualifiers [@Any @Default]
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:392)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:294)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:135)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:168)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:543)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
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)
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 @BatchProperty public org.jberet.creation.BatchBeanProducer.getStringBuilder(InjectionPoint)
at org.jberet.creation.BatchBeanProducer.getStringBuilder(BatchBeanProducer.java:0)
Possible dependencies:
- Implicit Bean [javax.enterprise.inject.spi.InjectionPoint] with qualifiers [@Default],
- Managed Bean [class org.jboss.weld.manager.BeanManagerImpl$InstanceInjectionPoint] with qualifiers [@Any @Default],
- Managed Bean [class org.jboss.weld.injection.EmptyInjectionPoint] with qualifiers [@Any @Default]
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:392)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:294)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:135)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:168)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:543)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
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)
at org.jboss.weld.bootstrap.ConcurrentValidator.validateBeans(ConcurrentValidator.java:76)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:504)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:435)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:148)
at org.jberet.se.SEArtifactFactory.<init>(SEArtifactFactory.java:29)
at org.jberet.se.BatchSEEnvironment.getArtifactFactory(BatchSEEnvironment.java:133)
at org.jberet.operations.JobOperatorImpl.<init>(JobOperatorImpl.java:93)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
... 8 more
How can i resolve this problem ?
It seems to me your flattening causes the weld implementation to end up in a jar w/ a beans.xml that causes unintentional parts of the library to show up as managed beans due to a bean discovery mode of "all" (which is also the case of an empty beans.xml with no version).
You should minimally make sure it's bean-discovery-mode="annotated" if you're going to stuff the weld impl into one big jar w/ your application.
Finally was able to run a executable (fat) JAR of a Java batch program in Java SE mode using JBERET implementation.
This link mentioned that and once i switched to 2.4.5.Final it worked fine.