How to configure CXF in TomEE - java

Is it possible to override settings in TomEE for the embedded CXF JaxRS container? I've been trying to integrate my own in-interceptor for handling rouing of JaxRS services.
What I can't seem to do is get TomEE to load the interceptor when starting my service.
I've read a bunch of stuff that says that I should be able to configure the CXF stuff in TomEE by adding <pojo-deployment> to an openejb-jar.xml file in either META-INF or WEB-INF. When I try using this approach, my interceptor never gets called.
I've also seen references that state that TomEE uses tomee.xml to replace openejb-jar.xml, so I tried to do the pojo-deployment stuff there, but then I get an XML parse error because tomee.xml doesn't seem to understand the pojo-deployment tag.
Can someone point me to some decent docs or better yet a small example of configuring CXF in TomEE?
Thanks

openejb-jar.xml is the way to do it
I blogged about it here http://rmannibucau.wordpress.com/2012/10/04/jax-rsjax-ws-configuration-for-tomee-1-5-0/
only change on recent tomee version is the fact you need to set as class-name the jaxrs application you use (if noone use "jaxrs-application" which means default behavior)
so something like:
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
<pojo-deployment class-name="jaxrs-application">
<properties>
cxf.jaxws.in-interceptors = org.superbiz.MyInInterceptor
</properties>
</pojo-deployment>
</openejb-jar>

Related

Java service using Jersey won't deploy to Jboss

I'm trying to build a Java service that other services could call.
This service is not a WS, but is calling a RestfulWS.
I'm really just building a wrapper around this call. This would find the correct data it needs, set up the JSON for the call. Get a response and send it back up.
Was told to use Jersey for this. Trying to set up all the pom.xml to use Jersey.
Building code works fine, it is when the deploy to the server happens that things fail.
I get the error -- "JBAS011232: Only one JAX-RS Application Class allowed. "
I don't have a web.xml, which I guess is used to skip some ResetEasy files.
I do have exclusions in pom.xml and jboss-deployment-structure.xml.
I still get the error when deploy happens. Not really sure what else to check.
It looks like you have a problem with JAX-RS dependencies. JBoss already has its own implementation of JAX-RS and probably that’s causing the issue. Some solutions are already suggested here Jboss error: Only one JAX-RS Application Class allowed

Call glassfish ejb from stand-alone application

So I have a simple ejb (#stateless) deployed on a glassfish 3.1 server.
I want to call it from a standalone application.
It's working great if I add the gf-client.jar into my run configuration.
But how can I do if I do not have that file (the server is in another machine) ?
I tried using
<dependency>
<groupId>org.glassfish.common</groupId>
<artifactId>glassfish-naming</artifactId>
<version>LATEST</version>
</dependency>
But I have
Exception in thread "main" javax.naming.NameNotFoundException: java:global
at com.sun.enterprise.naming.impl.TransientContext.resolveContext(TransientContext.java:252)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:171)
at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:58)
at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:95)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:233)
at javax.naming.InitialContext.lookup(Unknown Source)
at be.java.tuto.Application.main(Application.java:17)
Thanks.
EDIT:
I just needed to invoke an EJB deployed on GF from my Tomcat server and resurrected my dependencies. And because I dont want to keep them back for myself :)...
My IDE is Eclipse so I created an User Library containing all the files shown above.
Hope this solves your problem!
I was facing the same problem. For just wanting to invoke a GF session-Bean method I had to add the complete gf-client.jar to my clients classpath.
My problem was that this library is referencing almost the whole GF-libray-folder and even after a clean-up there were >15 referenced jars left which I had to add to my clients classpath.
For me I did't want this overhead so I decided to call the remote method via JAX-WS webservice.
The advantage of using webservises is that it is very easy to add webservice capability to an already existing session-bean by annotating the bean-class with #WebService.
After publishing the bean to the appserver you're able to view your deployed endpoint and getting the WSDL. With this you can generate your webservice-stubs automatically by using the wsimport-tool shipped with your JDK and use this generated files in yor client to invoke the remote method.
See example here.
Once created those files are portable and can be used in any client.
So if your willing to change the way your client calls the remote method this would be a portable, lightweight (except of a bit more http overhead) and easy to implement alternative.
P.S.
You don't lose the ability of invoking your method via EJB-call.
Hope this helped, have Fun!

How do I configure log4j per deployed application in Glassfish 3?

I'm trying to use log4j to handle the logs for a web-service which is running under Glassfish 3. Most of the guides I've seen using log4j with Glassfish want me to mess around with Glassfish global settings, which I want to avoid as there will be more than one application deployed per instance of Glassfish.
Is there any way for me to have Glassfish execute a piece of code when my web service is deployed which will allow me to call DOMConfigurator and set up log4j using my XML file?
Thanks for any help!
EDIT: The answer is to place the log4j.xml file in WEB-INF/classes. In our case, it looks as if log4j remains un-configured, but logging does still actually work as expected.
Yes. All you need to do is deploy the log4j configuration with the component you're deploying; log4j will use the locally-scoped configuration as long as it's not being referenced in a parent classloader.
Glassfish' global settings won't factor in at all in that case.

faces-config strange configuration problem?

I have a seam project (you should not be blocked to answer just because it's seam, consider it beeing a jsf one) and all works great with jboss 5.1 until I add this to the faces-config.xml
<faces-config>
<validator>
<validator-id>passwordValidator</validator-id>
<validator-class>com.mydomain.seam_icefaces_test.action.PasswordValidator</validator-class>
</validator>
.....
</faces-config>
to configure a validator (I know I can use a seam validator but I just want to use a jsf one).
At this moment jboss continuously deploy and undeploy my app automatically - which is very strange of course...
Do you know why?
Is this happening when you deploy using a local server in Eclipse? I used to get this issue of constant deploying & undeploying - it was caused by an Eclipse versioning file in the deployment.
Every time you change a config file (like faces-config.xml) Eclipse creates a versioning file, to revert to if necessary. This screws up JBoss. Simply delete this file - it'll be called faces-config.xxxxx where xxxx is something other than xml.

How do you add a dependency to a JBoss EJB with a generated WebService?

I'm trying to deploy an EJB in JBoss that uses the #WebService annotation. However, the EJB has a dependency on an EJB in another ear. By adding the #Depends annotation, the EJB start is delayed until after the ear is loaded, but it appears the WebService generator is still trying to start up the generated WAR as soon as it sees the annotation.
Is there anything similar to #Depends for the generated JBossWS that I can add?
I think what you may need to do is configure the deployment order that JBoss is using. I know this is possible and I think it is what people I work with have done for dependencies like this. If this link doesn't help, you will want to search for something dealing with JBoss deployment order and how to set the order. I had JBoss training a while back and I know this is a solution that is taught.
JBoss Deployment Order

Categories