JavaEE Wildfly EJB not injected, war-only project

╄→尐↘猪︶ㄣ 提交于 2019-12-06 11:23:13

Your EJB is not being injected because you have packaged your own copy of a JAX-RS implementation into your web app. This implementation does not know how to inject EJBs.

As this is WildFly 9, you can get rid of all the jersey jars, their dependencies and the complete web.xml.

In your gradle file you need to ensure that the javaee-api-7.0 dependency is given a scope of provided. It should not be packaged with your application as the server provides these classes. You also need to completely remove gradle references to:

  • activation-1.1.jar
  • geronimo-jta_1.1_spec-1.1.1.jar
  • javax.annotation-api-1.2.jar
  • java.inject-1.jar
  • javax.inject-2.4.0-b31.jar
  • javax.mail-1.5.0.jar
  • javax.ws.rs-api-2.0.1.jar
  • validation-api-1.1.0.Final.jar
  • xml-apis-1.0.b2.jar

because these classes are all provided by the javaee-api-7.0 dependency.

Finally, add a java source file containing:

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/rest")
public class JaxRsActivator extends Application {
}

which provides the configuration removed with the web.xml and you should be good to go.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!