import javax.inject.Inject;
import javax.inject.Singleton;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/add")
@Singleton
public class CounterController {
private final CounterService counterService;
// Resteasy/CDI requires @Context+@Singleton for constructor injection to work
// https://issues.jboss.org/browse/RESTEASY-1538
// http://stackoverflow.com/a/33658338/365237
@Inject
public CounterController(@Context CounterService counterService) {
this.counterService = counterService;
}
@POST
public void add(@Suspended final AsyncResponse asyncResponse, @Valid
CounterRequest counterRequest) {
asyncResponse.resume(counterService.count(counterRequest));
}
}
и
import javax.ejb.Asynchronous;
import javax.ejb.Stateless;
@Stateless
@Asynchronous
public class CounterService {
public CounterResult count(CounterRequest counterRequest) {
return new CounterResult(
counterRequest.getInt1() + counterRequest.getInt2());
}
}
отлично работают, если я использую версию wildfly 2018.3.0, однако, если я использую 2018.4.0 или 2018.5.0, я получаю
2018-06-08 23:14:30,898 ERROR [stderr] (main) Exception in thread "main" java.lang.reflect.InvocationTargetException
2018-06-08 23:14:30,898 ERROR [stderr] (main) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2018-06-08 23:14:30,898 ERROR [stderr] (main) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2018-06-08 23:14:30,898 ERROR [stderr] (main) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2018-06-08 23:14:30,898 ERROR [stderr] (main) at java.lang.reflect.Method.invoke(Method.java:497)
2018-06-08 23:14:30,898 ERROR [stderr] (main) at org.wildfly.swarm.bootstrap.MainInvoker.invoke(MainInvoker.java:53)
2018-06-08 23:14:30,898 ERROR [stderr] (main) at org.wildfly.swarm.bootstrap.MainInvoker.main(MainInvoker.java:106)
2018-06-08 23:14:30,898 ERROR [stderr] (main) Caused by: org.wildfly.swarm.container.DeploymentException: org.wildfly.swarm.container.DeploymentException: WFSWARM0004: Deployment failed: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"wildfly-swarm-example-1.0-SNAPSHOT.war\".WeldStartService" => "Failed to start service
2018-06-08 23:14:30,898 ERROR [stderr] (main) Caused by: org.jboss.weld.exceptions.DeploymentException: Exception List with 5 exceptions:
2018-06-08 23:14:30,898 ERROR [stderr] (main) Exception 0 :
2018-06-08 23:14:30,898 ERROR [stderr] (main) org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type DeploymentContext with qualifiers @Default
2018-06-08 23:14:30,898 ERROR [stderr] (main) at injection point [BackedAnnotatedField] @Inject org.wildfly.swarm.container.runtime.cdi.configurable.DeploymentProducer.context
2018-06-08 23:14:30,900 ERROR [stderr] (main) Exception 2 :
2018-06-08 23:14:30,900 ERROR [stderr] (main) org.jboss.weld.exceptions.DeploymentException: WELD-001410: The injection point has non-proxyable dependencies: [BackedAnnotatedField] @Inject private org.wildfly.swarm.container.runtime.RuntimeDeployer.defaultDeploymentCreator
2018-06-08 23:14:30,901 ERROR [stderr] (main) Caused by: org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001435: Normal scoped bean class org.wildfly.swarm.container.runtime.deployments.DefaultDeploymentCreator is not proxyable because it has no no-args constructor - Managed Bean [class org.wildfly.swarm.container.runtime.deployments.DefaultDeploymentCreator] with qualifiers [@Any @Default].
Пример репозитория: работает , не работает .
У меня есть beans.xml как
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
, и я используюmvn clean wildfly-swarm:run
.
Идея о причине?Это будет ошибка?Я просмотрел список изменений и не увидел ничего подходящего для меня.Единственное критическое изменение не создавало класс приложения jax-rs по умолчанию, но у меня этот класс все равно есть.