EJB Injection in ReSTEasy JBoss AS 7 - resteasy

Does anyone know if JBoss AS 7 has support for EJB injection in ReSTEasy applications per J2EE spec? I know this did not work in AS6 and was a known spec violation.
Thanks for any help/insights.

Yes the EJB injection is supported. I will explain a trick to put everything together to work:
You have to create a file beans.xml on /Web-Inf/
You have to change your Application Class. Change singletons by class.
Example:
singletos.add(new HelloResource())
replace this line by empty or clazzes.add(HelloResource.class)
After that you can use ejb injection on JBoss7 and RestEasy using ejb annotation #EJB.

Related

Best solution to "hot-deploy" Apache Camel routes and beans classes?

We use Apache Camel as a standalone application for ~ 2 years. It works very
well but the need to restart the process to upgrade the application each time
we add new routes becomes an issue.
We are searching for a new deployment solution that could allow us to deploy
new routes without having to restart the main process.
There is no problem for us to rewrite our Java DSL routes in XML but the issue
is that most of them (and probably future ones too) make use of custom beans,
processors, components etc. to inject some logic that is too complex to
be expressed in pure XML/Java DSL route.
After searching through Camel documentation, hot deploying XML routes seems to
be possible with spring-boot or with Karaf/OSGI.
But i have no idea if it is possible to "hot-deploy" bean, processors,
components etc. classes that are needed by theses XML routes. OSGI/Karaf looks
promising but i have never used boths technologies and it is not easy to grasp their purpose at first glance.
Which deployment method and which technology could allow us to "hot deploy' routes and beans classes ?
If you want to hot-deploy Java code, then you need an application server like platform such as Apache Karaf/ServiceMix/JBoss Fuse etc or a traditional like Tomcat, JBoss, WildFly etc (for WAR files).
Then you can do a "hot deployment" as a deployment of the application.
To hot-deploy a single class or some classes inside a running JVM is harder, and you would need special tooling such as JRebel.
You could try to use camel-blueprint to setup the context/route.
By exposing your bean as osgi service, you can use those beans in routes.
I would suggest you to take a look into apache camel blueprint maven archetype and camel component archetype to get started.
Hot deploy in Apache Karaf is simple, simply drop the bundle into $KARAF_HOME/deploy and it will reload automatically.
Reference:
camel-archetype-component camel-archetype-blueprint
Do let me know if this help.
PS: I don't have enough reputation for commenting hence the answer.

How configure JAX-WS for the WLP v 16.0.0.4

I use jaxws-2.2 feature and need to know how to configure JAX-WS for the WLP v 16.0.0.4.
WLP uses Apache CXF implementation for JAX-WS. Apache CXF JAX-WS configuration includes the next two steps.
Create servlet class mapping (org.apache.cxf.transport.servlet.CXFServlet) in the web.xml
Create the JAX-WS endpoint configuration (jaxws:endpoint) in the cxf-servlet.xml
Maybe there are the other ways for configuration JAX-WS Apache CXF implementation on Liberty, however, I don't know it. All examples for cxf-servlet.xml that I found related to Spring:
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.1/html/Deploying_into_a_Web_Server/DeployCxf.html
Apache CXF http://cxf.apache.org/docs/jax-ws-configuration.html
IBM https://www.ibm.com/developerworks/websphere/library/techarticles/1001_thaker/1001_thaker.html (please see attached pdf and sample application).
I couldn't find the cxf-servlet.xml example for the pure Java EE application without Spring (and any others 3rd party) dependencies.
Kind regards,
Alexander
Once you've added the jax-ws feature to server.xml, the easiest thing is to create a war file with a class in it, just like you would a servlet, but this class has an #WebService annotation on it instead of an #WebServlet. The public methods will become your webservice operations. WSDL will be produced automatically when you deploy the war file. It's exact URL is probably detectable by looking at Liberty's messages.log file. Web.xml is optional.
It's a big mistake to deal with the JAX-WS implementation provided within WLP (here cxf)...
You don't need specific "configuration", just stick with the JAX-WS specification that has lots of annotations to define the services, the operations, the endpoints and the parameter mapping (JAX-B) etc. You don't need any configuration file
In short, just create a POJO, annotated the class with #WebService and the methods with #WebMethod
You'll find lots of tutorial on the web. One from Oracle is here
Check the classes in the javax.jwsand javax.jws.soap packages in the official jee6/jee7 javadoc
It's the same principle for REST services, ie plain annotated POJO classes..

SSL (HTTPS) support in functional web framework

How am I supposed to to configure SSL for a Spring Boot Service using the functional web framework?
The configuration via setting server.ssl.* properties does not work (meaning nothing happens at all) and if I am reading the docs right, only server.port and server.address are supported.
As runtime I prefer netty, but I would be fine with tomcat as well.
Indeed, using the server.ssl.* configuration keys is the right way to go. This is not yet supported as of Spring Boot 2.0.0.M5, but it will be in a future Milestone version (you can follow issue #9431 for that).
You could use customizers as a workaround; Spring Boot provides a few of those for Tomcat already (see TomcatConnectorCustomizer), but unfortunately not yet for Netty (see #10418).
In the meantime, you can provide your own ReactiveWebServerFactory bean and manually set up your Netty server to do that.

JAX-WS with Apache CXF under CDI/Weld

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)?
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.
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

JAX-RPC runtime for Tomcat

I have ported a Java EE web application from JBoss 4.0.5/Java 5 to Tomcat 6.0.33/Java 6.
The web application exposes some web services. They were implemented as JAX-RPC web services in JBoss, I have adapted them as JAX-WS web services using CXF 2.6 as the implementation run-time. Now I have been requested to make available in the new environment (Tomcat 6.0.33/Java 6) also the JAX-RPC web services for compatibility with existing clients. The two versions of the same web services would of course be available through two different end point URLs.
The JAX-RPC web services in JBoss 4.0.5/Java 5 are implemented using Spring (the implementation class extends org.springframework.remoting.jaxrpc.ServletEndpointSupport, found in spring-remoting-2.0.8.jar) but I cannot guess which is the underlaying implementation framework for JAX-RPC made available by JBoss. I just can see that the configuration files are webservices.xml and jaxrpc-mapping.xml.
I tried to "replicate" that Spring configuration in Tomcat but when I try to retrieve the WSDL I get an error javax.servlet.ServletException: Class pack.age.MyEndPoint is not a Servlet. Indeed that class (the JAX-RPC end point implementation class) is not a servlet but under JBoss 4.0.5/Java 5 it is declared in web.xml as a servlet and it works.
Could you please help? I imagine I just have to supply the proper JAX-RPC implementation framework to Tomcat (I would like to avoid AXIS because it uses different configuration files). Thanks in advance.

Resources