How to remove Jersey and Apache ResponseImpl Collision? - glassfish

I have prepared a sample camel rest web application. When i deploy it in Glassfish, i'm getting error as like below. How to resolve this?
<ns1:XMLFault xmlns:ns1="http://cxf.apache.org/bindings/xformat"><ns1:faultstring xmlns:ns1="http://cxf.apache.org/bindings/xformat">java.lang.ClassCastException: com.sun.jersey.core.spi.factory.ResponseImpl cannot be cast to org.apache.cxf.jaxrs.impl.ResponseImpl</ns1:faultstring></ns1:XMLFault>

The WAR file you're deploying probably contains Apache CXF. Both Jersey and CXF are JAX-RS implementations and Jersey is built into Glassfish. Having two JAX-RS implementations on the classpath is causing a problem.
Assuming that you're using Maven, try replacing your CXF dependency with a dependency on the JAX-RS API or on Jersey. Mark the dependency as <scope>provided</scope> to avoid including it in your WAR file since Glassfish will provide it.

Related

Mule 4.x Sample Example With Standard War File Deployment

We want to embed mule community edition 4.x is our war file. Is there a sample anywhere showing this. With Mule 3x we used the MuleXmlBuilderContextListener.
UPDATE:
I added the mule repositories to my settings.xml as mentioned in the mule documention. I am referencing 4.1.4 and the different mule jar files I need are available except for the builders. I am trying to initialize the mule with the org.mule.runtime.config.builders.MuleXmlBuilderContextServlet passing in the location of the mule context.
When I look for that class in the mule repositories, the latest version I find is here:
<dependency>
<groupId>org.mule.runtime</groupId>
<artifactId>mule-module-builders</artifactId>
<version>4.0.0-FD.4</version>
</dependency>
and during startup I see some errors in comparability. Does anyone know where in the mule repositories I can find version 4.1.4 of the mule-module-builders atrifact?

Deploying Mule to Tomcat

i'm very new to mule esb. I have some question after try mule.
1.how can i run mule project by Tomcat? (I've try this issue but seem not working : http://www.mulesoft.org/documentation/display/current/Deploying+Mule+as+a+Service+to+Tomcat)
I have error when I starting tomcat like something was wrong.
2.How can I packing mule project to .war? ,I see that my editor(sts) don't think that mule application is a web application but the file path of mule application seem to be similar to maven generate project so... I don't know.
I use mule version 3.4.0
thank you,
First of all, you should use the Mule Standalone, if you can. If you really need to use Tomcat, I suggest you package all the Mule dependencies into the application war with Maven, and not try to work with the jars manually. See the answer by David Dossot here and an example Maven project here. Note that the example project uses Mule 3.1.2, so you probably want to update it a bit.

Is there a maven plugin to do wsdl to java with xstream mappings?

At present i know that there is a plugin called cxf-codegen plugin which converts wsdl to java with jaxb bindings .At present I just give the wsdl file and xsd file , the maven cxf-codegen plugin takes care of conversion fron wsdl to java with default jaxb bindings. I am searching for a solution as simple as that .
The system I am going to work with uses xstream.So I need to find a maven plugin to do wsdl to java with xstream bindings . The system uses restlet as rest framework .
Is there anything available as such ?
Thanks

Does Mule CloudHub use Java SE or EE by default?

I'm uploading an application to CloudHub and getting ClassNotFound errors for javax.validation.ValidatorFactory. I believe the javax.validation package is found only in EE and not SE, which is available in my localhost environment. So, is EE not available to CloudHub apps by default?
Mule is not a JavaEE container so it doesn't embed all the JavaEE extensions to the standard JDK.
If you download Mule Standalone EE and look at the JARs in lib/opt you'll see what JavaEE JARs are available by default, which include (but is not limited to):
Activation 1.1
JMS 1.1
JTA 1.1
If you need more JARs or different versions, it is up to you to ship them with your app. You may have to use classloader filtering if you want to use a different version of a JAR provided by Mule.

Is there a Maven plugin to package Entity beans in J2EE app?

I haven't found a Maven plugin or target that will package my app and deploy it to Glassfish without error. I get this exception:
[ERROR] com.sun.enterprise.admin.cli.CommandException: remote failure: Exception while preparing the app : java.lang.RuntimeException: Could not resolve a persistence unit corresponding to the persistence-unit-ref-name [org.us.impl.MyClass/entityManagerFactory] in scope of the module called [man-java-really-stinks-app]. Please verify your application.
This isn't a Spring/Hibernate/EntityManagerFactory/Jpa problem. The app runs fine in the embedded Maven Glassfish container.
I changed packaging to ear in my pom.xml and got this when I deployed to Glassfish
Error during deployment : org.xml.sax.SAXParseException: The content of element type "application" is incomplete, it must match "(icon?,display-name,description?,module+,security-role*)".
IS there a plugin that will take care of the J2EE packaging requirements?
Bonus question: Since the Entities (just POJOS!) and the application need to be packaged differently, is it best to separate these into Maven sub-projects?
I haven't found a Maven plugin or target that will package my app and deploy it to Glassfish without error.
For the packaging, there is everything you need: the maven-jar-plugin for JARs (including JARs packaging JPA entities), the maven-war-plugin for WARs, the maven-ejb-plugin for EJB-JARs, the maven-ear-plugin for EARs, the maven-rar-plugin for resource adapters.
This isn't a Spring/Hibernate/EntityManagerFactory/Jpa problem. The app runs fine in the embedded Maven Glassfish container.
Well, I'm still tempted to say that there is a JPA configuration problem somewhere anyway, the container is clearly failing at finding a (default?) persistence unit. But since I have no idea of the kind of app you're running (I guess it's a webapp but would like to get confirmation), what your persistence.xml looks like, how you inject the EntityManager, how you configured the database access, how you configured Spring, the version of GlassFish you're running, etc, etc, it will be hard to say anything more.
I changed packaging to ear in my pom.xml and got this when I deployed to Glassfish
That's not that easy. Building an EAR typically involves a multi-modules build, and you are expected to provide a special deployment descriptor. But I'm not convinced you need an EAR packaging and if you can avoid it, don't use it.
IS there a plugin that will take care of the J2EE packaging requirements?
As I said, there are plugins for everything you need, from J2EE to Java EE 6. Just provide the details requested above.
Bonus question: Since the Entities (just POJOS!) and the application need to be packaged differently, is it best to separate these into Maven sub-projects?
Entities and the application do NOT (always) need to be packaged differently, you can package entities directly inside a WAR (I'm extrapolating but I suspect this is your case). I just think you have a configuration problem somewhere, even if the application is running in GF Embedded.
By the way, almost Everything is POJO in Java EE (Entities, Session Beans, Message Driven Beans, etc), but there is no direct consequence on packaging, packaging and POJOness are unrelated.
org.us.impl.MyClass had a #PersistenceUnit annotation. The persistince is managed by Spring, but Glassfish takes a sweep of the annotation classes and tries to resolve it itself. You can tell Glassfish to knock it off by adding
metadata-complete="true"
to your web.xml, like so
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
metadata-complete="true">
Further reading: https://glassfish.dev.java.net/issues/show_bug.cgi?id=4204