JSR352 JBeret-使用JBeret运行SleepyBatchlet时出错 [英] JSR352 JBeret - Error while running SleepyBatchlet using JBeret

查看:60
本文介绍了JSR352 JBeret-使用JBeret运行SleepyBatchlet时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JBeret实现以Java SE模式运行JSR352兼容的Java批处理程序.

I am trying to run a JSR352 compliant java batch program in Java SE mode using JBeret implementation.

我使用了 SleepyBatchlet 程序,

I took the SleepyBatchlet program, converted to a executable JAR (with all necessary dependencies packaged along with it) to use Jberet and tried running it from my windows command prompt but, got this error stack trace. The same project runs without any error from my Eclipse IDE

我检查了Eclipse和Command提示符中使用的jdk版本是否相同.

I have checked to see the jdk version used in Eclipse and Command prompt is the same.

这是我运行 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目标从Eclipse运行时,同一个项目 clean install exec:java

The same project when run from Eclipse using the maven goal clean install exec:java

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>

推荐答案

在Eclipse之外,有人遇到了Maven生成的Java代码的问题:仅适用于maven的错误:NoClassDefFoundError:feign/codec/Encoder

Here someone had a problem with Maven-generated java code outside of Eclipse: Error only with maven: NoClassDefFoundError: feign/codec/Encoder

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

In fact it was the command line and the missing dependencies. Therefore I'd suggest to check if the required classes are really contained (it seems your project creates a super-jar that should contain all dependencies). Also check whether there may be ambiguous names since your error message hints it.

这篇关于JSR352 JBeret-使用JBeret运行SleepyBatchlet时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆