users@jersey.java.net

[Jersey] Re: Jersey client in Jboss application

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Sun, 4 Nov 2012 17:09:28 -0800 (PST)

There is a similar issue with Glassfish. On the Jersey site they show how you can replace the bundled jersey classes in glassfish with the latest. In this way, you don't bundle it with your WAR file.

I gotta ask (and not trying to hijack the thread but assume others with knowledge of how classloaders work within JEE might know this answer)...  I always thought that if you bundled a jar file in a WAR file, like jersey, it would ALWAYS use the .war!/WEB-INF/classes and /WEB-INF/lib/ jar files BEFORE any libraries within the JEE container class path. But in Glassfish, you actually have to configure this sort of behavior. So what happens is if you don't configure it, and you bundle jersey with your WAR, glassfish will find it's possibly older (or newer) version of jersey and use it instead. The same goes for other libraries that glassfish bundles. I always thought that as a web app developer, we were guaranteed that all JEE containers had to always load classes from the WEB-INF/classes and WEB-INF/lib/*.jar files first.. allowing the deployer to determine if they had the specific versions of libraries their code depended on. It's quite annoying to not
 have this guarantee.

At any rate.. you will need to see if you can simply replace the jersey library jar files in jboss 7 with the latest from jersey. I am sure there must be a way to do it. The good thing is, you can remove them from your WAR if that is the case, lessening the size of it for remote deployment making it faster to deploy.







>________________________________
> From: Márcio Dantas <marciopd_at_gmail.com>
>To: users_at_jersey.java.net
>Sent: Friday, November 2, 2012 12:52 PM
>Subject: [Jersey] Jersey client in Jboss application
>
>
>Hi,
>
>I'm writing a rest client that will be running on a war application in Jboss 7 and using the maven jersey-client artifact as dependency.
>
>The problem is that jersey-client depends on jersey-core, which has jax-rs classes along with jersey's specific core classes.
>
>As Jboss already has the jax-rs classes I'm getting classloader issues.
>
>Why are jax-rs and jersey-core classes in the same jar? Wouldn't be better to split them in separate jars?
>
>Is there a way to use jersey client in jboss without doing classloader config?
>
>thx,
>Marcio Dantas
>
>
>