Injecting Managed Bean into Webservice

夙愿已清 提交于 2019-12-10 23:27:00

问题


I'm trying to inject a Managed Bean within a Webservice but the injected Bean is allways null. Does anybody knows why and if so could you provide some hints or a workaround?

@WebService(targetNamespace = "http://impl.soap.valueservice.drivelog.com/", endpointInterface = "com.drivelog.valueservice.soap.impl.ValueService", portName = "ValueServiceImplPort", serviceName = "ValueServiceImplService")
public class ValueServiceImpl implements ValueService {

    @Inject
    private ValueServiceFacade valueBean;

...
}

@ManagedBean
public class ValueServiceFacadeImpl implements ValueServiceFacade {
...
}

回答1:


This is really embarrassing.

According to this blog post (https://weblogs.java.net/blog/jitu/archive/2010/02/19/jax-ws-cdi-java-ee-6-0) and this post (https://blogs.oracle.com/arungupta/entry/totd_124_using_cdi_jpa), this should work but I can't make it work using TomEE here.

There is also some discussion about JSRs here (https://bugzilla.redhat.com/show_bug.cgi?id=1001610) but I can't really tell you why it does not work.

For TomEE (openEJB) all I could find was a lot of issues closed (related to https://issues.apache.org/jira/browse/OPENEJB-1592) with a scary comment "All done for certification", and maybe, the JEE Web Profile does not need to make these work together, while Geronimo, that implements the full EJB Profile, may need to work with this.

Please also see Java EE 6 WebService and CDI injection

So I can't really answer this. At the same time, I'll ask you to provide us some more information about what container you're using, so we can help you better.



来源:https://stackoverflow.com/questions/17526751/injecting-managed-bean-into-webservice

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