Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBERET000640 - Wildfly 14 #117

Closed
sousadax12 opened this issue Dec 5, 2018 · 13 comments
Closed

JBERET000640 - Wildfly 14 #117

sousadax12 opened this issue Dec 5, 2018 · 13 comments
Assignees

Comments

@sousadax12
Copy link

I am getting the follow error when i try to run a programmatic job definition. I am using wildfly 14, java ee 8 and jberet 1.3.1.Final.

JBERET000640: A BatchEnvironment implementation could not be found. Please ensure the SPI has been implemented and is on the class path

@chengfang chengfang self-assigned this Dec 5, 2018
@chengfang
Copy link
Contributor

On the surface it looks like a class path problem. The BatchEnvironment impl for WildFly is included in WildFly distro and normally should already be available to jberet. Do you see the same error when running other batch jobs that do not involve programmatic job definition? Can you also paste the full stack trace?

@sousadax12
Copy link
Author

sousadax12 commented Dec 5, 2018

With JBeret i only tried programmatic job definition. But i tried to run a simple job from javax library and worked.

16:54:20,609 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /testBatch/api/ping: org.jboss.resteasy.spi.UnhandledException: javax.batch.operations.BatchRuntimeException: JBERET000640: A BatchEnvironment implementation could not be found. Please ensure the SPI has been implemented and is on the class path
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:78)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:222)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:197)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:459)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:233)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:139)
at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:142)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:219)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:227)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter.doFilter(SpanFinishingFilter.java:55)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.batch.operations.BatchRuntimeException: JBERET000640: A BatchEnvironment implementation could not be found. Please ensure the SPI has been implemented and is on the class path
at org.jberet.operations.JobOperatorImpl.(JobOperatorImpl.java:48)
at org.jberet.operations.JobOperatorImpl.(JobOperatorImpl.java:43)
at com.airhacks.ping.boundary.PingResource.dailyQuiz(PingResource.java:42)
at com.airhacks.ping.boundary.PingResource$Proxy$_$$_WeldClientProxy.dailyQuiz(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:509)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:399)
at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:363)
at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:365)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:337)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:310)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:443)
... 55 more

@chengfang
Copy link
Contributor

Did you use BatchRuntime.getJobOperator() to obtain the job operator? This should be used instead of directly instantiating JobOperatorImpl.

@sousadax12
Copy link
Author

sousadax12 commented Dec 5, 2018

I have using this. This code work in old projects that are running with java ee 7 and WF 10.

Job job = new JobBuilder("JobName")
.restartable(false)

            .step(new StepBuilder("StepName")
                    .batchlet("batchTest")
                    .build())


            .build();

    JobOperatorImpl jobOperatorImpl = new JobOperatorImpl();
    long jobOperatorExecutionId = jobOperatorImpl.start(job, new Properties());

@chengfang
Copy link
Contributor

BatchRuntime.getJobOperator() is the standard and portable API, but JobOperatorImpl is an implementation class and should not be directly accessed by applications.

@sousadax12
Copy link
Author

But how can i start a org.jberet.job.model.Job using the BatchRuntime.getJobOperator()?

@chengfang
Copy link
Contributor

The above is also used by the test app that uses programmatic job definition:

https://github.com/jberet/jsr352/blob/1.3.1.Final/test-apps/javaJSL/src/test/java/org/jberet/testapps/javajsl/JavaJSLIT.java

@chengfang
Copy link
Contributor

chengfang commented Dec 6, 2018

Note that this solution is for jberet 1.3 or later.

In summary, if you only need to access the standard API in javax.batch.operations.JobOperator, then call BatchRuntime.getJobOperator().

If you need to access the additional non-spec-defined API in JBeret's implementation of JobOperator, then use

AbstractJobOperator jobOperator = (AbstractJobOperator) JobOperatorContext.getJobOperatorContext().getJobOperator();

as demonstrated in JBeret test class AbstractIT.

@sousadax12
Copy link
Author

sousadax12 commented Dec 6, 2018

This still does not working. Now i am getting:

org.jboss.resteasy.spi.UnhandledException: java.lang.ClassCastException: org.wildfly.extension.batch.jberet.deployment.JobOperatorService cannot be cast to org.jberet.operations.JobOperatorImpl

`Job job = new JobBuilder("JobName")
.restartable(false)

            .step(new StepBuilder("StepName")
                    .batchlet("batchTest")
                    .build())


            .build();

    JobOperatorImpl jobOperator = (JobOperatorImpl) JobOperatorContext.getJobOperatorContext().getJobOperator();


    long jobOperatorExecutionId = jobOperator.start(job, new Properties());`

@sousadax12
Copy link
Author

sousadax12 commented Dec 6, 2018

These are the dependencies:

<dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>8.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jberet</groupId> <artifactId>jberet-core</artifactId> <version>1.3.1.Final</version> <scope>provided</scope> </dependency> </dependencies>

@chengfang
Copy link
Contributor

cast the job operator impl to org.jberet.operations.AbstractJobOperator (the super class of JobOperatorImpl). AbstractJobOperator should provide all the methods you will need to access jberet-specific operations.

This applies for JBeret running in either Java SE or Java EE (WildFly) environment.

@chengfang
Copy link
Contributor

Sorry for the confusion. I've updated my comments and casting to AbstractJobOperator (instead of JobOperatorImpl) should work. Casting to JobOperatorImpl only works in JBeret in Java SE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants