JSR352 JBeret - 使用JBeret运行SleepyBatchlet时出错

时间:2017-10-02 06:40:11

标签: java maven jsr352 jberet

我正在尝试使用JBeret实现在Java SE模式下运行符合JSR352的Java批处理程序。

我接受了SleepyBatchlet程序converted to a executable JAR (with all necessary dependencies packaged along with it) to use Jberet并尝试从我的Windows命令提示符运行它,但是得到了这个错误堆栈跟踪。我的Eclipse IDE

运行时没有任何错误

我已经检查过Eclipse中使用的jdk版本和命令提示符是一样的。

这是我运行java -jar jarfilename.jar

时的例外情况
Exception 0 :
org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type InjectionPoint with qualifiers @Default
  at injection point [UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedMethod] @Produces @BatchProperty public org.jberet.creation.BatchBeanProducer.getS
hort(InjectionPoint)
  at org.jberet.creation.BatchBeanProducer.getShort(BatchBeanProducer.java:0)
  Possible dependencies:
  - 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],
  - Implicit Bean [javax.enterprise.inject.spi.InjectionPoint] with qualifiers [@Default]

        at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:369)
        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:282)
        at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:133)
        at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:164)
        at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:507)
        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(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

        at org.jboss.weld.bootstrap.ConcurrentValidator.validateBeans(ConcurrentValidator.java:76)
        at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:468)
        at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:392)
        at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:85)
        at org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.validateBeans(ForwardingBootstrap.java:75)
        at org.jboss.weld.environment.se.Weld.initialize(Weld.java:144)
        at org.jberet.se.SEArtifactFactory.<init>(SEArtifactFactory.java:31)
        at org.jberet.se.BatchSEEnvironment.getArtifactFactory(BatchSEEnvironment.java:89)
        at org.jberet.operations.JobOperatorImpl.<init>(JobOperatorImpl.java:69)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.lang.Class.newInstance(Class.java:442)
        at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
        ... 4 more

使用maven目标clean install exec:java

从Eclipse运行时的同一项目
WARN: WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled
Oct 02, 2017 2:36:08 PM org.jberet.repository.JdbcRepository getDDLLocation
INFO: JBERET000021: About to initialize batch job repository with ddl-file: sql/jberet.ddl for database H2
Batchlet submitted: 1
SleepyBatchlet: process: entry
SleepyBatchlet: process: sleep for: 15
SleepyBatchlet: process: [0] sleeping for a second...
SleepyBatchlet: process: [1] sleeping for a second...
SleepyBatchlet: process: [2] sleeping for a second...
SleepyBatchlet: process: [3] sleeping for a second...
SleepyBatchlet: process: [4] sleeping for a second...

这是POM文件条目

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.ibm.ws.jbatch.sample.sleepybatchlet</groupId>
    <artifactId>SleepyBatchletSample</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>SleepyBatchletSample</name>

    <dependencies>

        <dependency>
            <groupId>org.jboss.spec.javax.batch</groupId>
            <artifactId>jboss-batch-api_1.0_spec</artifactId>
            <version>1.0.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.jberet</groupId>
            <artifactId>jberet-core</artifactId>
            <version>1.0.2.Final</version>
        </dependency>

        <dependency>
            <groupId>org.jberet</groupId>
            <artifactId>jberet-support</artifactId>
            <version>1.0.2.Final</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.2_spec</artifactId>
            <version>1.0.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core</artifactId>
            <version>2.1.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.weld.se</groupId>
            <artifactId>weld-se</artifactId>
            <version>2.1.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jberet</groupId>
            <artifactId>jberet-se</artifactId>
            <version>1.0.2.Final</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.marshalling</groupId>
            <artifactId>jboss-marshalling</artifactId>
            <version>1.4.2.Final</version>
        </dependency>


        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.178</version>
        </dependency>


    </dependencies>

    <build>
    <plugins>
    <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <!-- get all project dependencies -->
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <finalName>PilotJBeret</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                    <!-- MainClass in mainfest make a executable jar -->
                    <archive>
                        <manifest>
                            <mainClass>com.ibm.ws.jbatch.sample.sleepybatchlet.Main</mainClass>
                        </manifest>
                    </archive>

                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <!-- bind to the packaging phase -->
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

    </plugins>

    </build>

</project>

1 个答案:

答案 0 :(得分:0)

有人在Eclipse之外的Maven生成的Java代码有问题: Error only with maven: NoClassDefFoundError: feign/codec/Encoder

实际上这是命令行和缺少的依赖项。 因此,我建议您检查是否确实包含了所需的类(看来您的项目创建了一个应该包含所有依赖项的超级jar)。另外,请检查是否存在名称不明确的地方,因为您的错误消息会提示它。