4

I have seen the other questions on CXF under CDI but they all seem to be for JAX-RS style web services.

Is JAX-WS possible in this configuration? If not, how can I expose a JAX-WS service using CDI/Weld in a non-EE container (Tomcat 8)?

Michael Sharek
  • 5,043
  • 2
  • 30
  • 33

2 Answers2

1

If you want to use CDI and JAX-WS in Tomcat then most possibly the easiest you can do is to use Apache TomEE.

TomEE is basically a standard Apache Tomcat, but pimped with lots of JavaEE libs. It brings a full CDI container, JAX-RS, JAX-WS etc. For JAX-WS you should take the 'plus' variant.

If you want it really just embedded or smallish (in size, not in power), then you can also take a look at Apache Meecrowave and bundle the JAX-WS part of CXF to it.

Meecrowave is a EE8 technology based smallish (9MB) Application Server which can be used standalone or embedded (via Meecrowave#bake()). It's pure Apache: Tomcat (Servlets-4.0), OpenWebBeans (CDI-2.0), Johnzon (JSON-P_1.1, JSON-B_1.0), CXF, log4j2.

struberg
  • 730
  • 5
  • 12
0

First, you have to enable CDI on tomcat. See here.

In my case, @Inject did not work on classes with @WebService but I was able to inject using CDI.current().select(MyClass.class).get().

It did not work on @PostConstruct though, but you can use it inside a @WebMethod.

[Note] I was using Metro instead of Apache CXF

juvenislux
  • 290
  • 2
  • 10