You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Cuneo, Nicholas" <nc...@tycoint.com> on 2014/06/02 18:24:58 UTC

RE: Deploying JerseyWS 2.8 w/o web.xml

We are using Ivy for our dependency manager, but I'm not exactly following what you mean.  Are you suggesting  I'm supplying a jar file in my war that  doesn't need to be there because Tomcat has its own version of it?

Thanks,
Nick


-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net]
Sent: Friday, May 30, 2014 4:55 PM
To: Tomcat Users List
Subject: Re: Deploying JerseyWS 2.8 w/o web.xml

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Nick

On 5/30/14, 5:03 PM, Cuneo, Nicholas wrote:
> We are trying to deploy a webservice to tomcat 8.0.5 using Jersey WS
> 2.8.  In the Jersey documentation it mentions deploying without the
> need for a web.xml in your war file using annotations, so I thought
> I’d give that a  try.
>
> However, when I go to deploy my webservice Tomcat is throwing the
> exception below, I can’t figure out what might be the issue.
>
>
>
> Some notes about our environment in case  they come into play:
>
> The webservice  is compiled with java 8.
>
> Tomcat is running on a linux server.
>
> As per the Jersey documentation, I have a class annotated with
> @ApplicationPath which extends ResourceConfig.  Our webservices exist
> in a separate package which is being loaded using the
> packages() function.
>
>
>
> 30-May-2014 20:57:22.592 SEVERE [localhost-startStop-4]
> org.apache.catalina.startup.ContextConfig.processServletContainerIniti
> alizers
>
>
Failed to process JAR found at URL [/api] for
> ServletContainerInitializers for context with name [{1}]
>
> java.io.IOException: java.lang.ClassCastException: Cannot cast
> org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer
> to javax.servlet.ServletContainerInitializer

It looks like you might have a JAR file in WEB-INF/lib that contains ServletContextInitializer or something similar. Tomcat should veto the loading of such classes, but something may have slipped-by.

Remember that runtime class is classloader + class, so the above error may be confusing: JerseyServletContainerInitializer does in fact extend ServletContainerInitializer (at least given their current API
javadoc) so the problem is likely that the ClassLoaders do not match.

Perhaps you are using Maven and it's unaware that Tomcat provides some of the javax.* packages itself?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTiRpRAAoJEBzwKT+lPKRYeZUP/RQ4NlB9yxhGaXVdBNoPVKdq
L8DakkbBlHLOVnOgEcyK++s5iOUFXHSeRVJuTIDQs0fAiDnMjC4V+3wynCJbzgz1
174AsN50+LEG4wvJ+rVwS0yBaEzwn7bHKY5zR/J0Rrry4Ms6J4xTuuL8nofr/qkJ
muNFagg+Ypxfbo9qH0Y/XgFMU7IVy4+ti3dtVKXCZJjjOkaRC9DB6A/Win83onAC
FU8zO2bgrTyGtJFsF1IK5VE9V4lafSIy8HgszWUm3zbG1dmrXpii65vdF+gSBALs
kyTN4bekR15O9ubuHXspqZwpJyEBxRLy71048PEHg0gQ4BCluy6nmksxeRTTtVsH
30VRsp2p/JlUHIJWrB/mJ98Co0hN5h2dwzodARarTm8Qm9P/ZDCDzOLj2cHgv6cY
AodGJYuLcNDiwfyv74kVyf0sr/mj54ghZ61ttLYPpqwcZyDTf9dmPiS/SuB9uSWa
oHOcg36v6s0FSIXlvpM+MZ7R1n+m/Dsj2u5dRkt/L/WzNBR7BSQqfs6vPiYoz5H7
IVRhgxYGZLXTmhNx/0yk14zr3EF8Ww84oXlyXNui2kM6jpGgkbleSV/1dkd6F3Ud
/mZxY8a5rqrqrEN/qgFRx0gk2LEtnQhE8p4qHT/2ij0Q1UQXMpPQBL4bdLIe4Zep
FPjzCGsmV9amCd6jvJU2
=6tVn
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Deploying JerseyWS 2.8 w/o web.xml

Posted by "Cuneo, Nicholas" <nc...@tycoint.com>.
The only error I saw in my catalina logs was the one I copied earlier.
Indeed, removing javax.servlet-api fixed the issue.

Thanks,
Nick


-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net]
Sent: Monday, June 02, 2014 9:58 AM
To: Tomcat Users List
Subject: Re: Deploying JerseyWS 2.8 w/o web.xml

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Nicholas,

On 6/2/14, 12:38 PM, Cuneo, Nicholas wrote:
> I think you are correct, maybe I need to exclude some jars from my
> bundle?
>
> find . -name "*.jar" | xargs grep
> ServletContainerInitializer.class Binary file ./servlet-api.jar
> matches
>
> find ../webapps/api/WEB-INF/lib -name "*.jar" | xargs grep
> ServletContainerInitializer.class Binary file
> ../webapps/api/WEB-INF/lib/jersey-container-servlet-jar-2.8.jar
> matches Binary file
> ../webapps/api/WEB-INF/lib/javax.servlet-api-jar-3.0.1.jar matches

Yes, those are going to be a problem. and need to be removed from WEB-INF/lib

You should also remove anything that provides JSP or EL APIs.

Like I said, Tomcat should be protecting itself against such classes being loaded... are there any warnings during deployment that JAR files are being rejected?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTjK0XAAoJEBzwKT+lPKRYnNoQALTKiIDycnKxYmAWt7QdQy2c
evQYKt1xEQwDUq1qrng7KDWaF5qgy6udm682z0RLgfNVQOmklXEkR8TTnPyuhaDY
QNrTg0ojQytXcVdBiyqiectVTkj9Bqf3nATGqUN20CI2zUuEvK1Bt+dvGzBTRNji
ckJSgNZyA6dbODr84jLZG4s5eVwrS+Ee68EtDuJSxKPtjWiBwMtzJ+1inYL9xHY+
jUXC71UCroj7typlNVeSTL6pUlPrs1xq2FJGNQn6Q5IecevLHK08EZlKkcqVdc5A
BH8/VlSnFgYBIDXCWY+UydFT+M3GmwLX5h120oTczY9doPAHF0W4s6anrzt6hPc7
mMOjHhBbgyMi2EigS/kGCpK4opiLTkGouba8JQQPmc6IhMRZyaEW3WyDDfaFlRGQ
w3cN/mQ0QKY0sirOPa4O2wqeH6rW/tG6i20MCKDOkT9X7KXEvLkvfTZDuQyi7FOI
Ew81AztOODBci6MByrgt7MVPmhLd0I+jaqAERLk3bLAKbd5CFDe5yHo5l3f+JMGB
dS+cQUFLu51GteTLLnhoiyZpER6OXKliZxytlbqbMfyj+iuMvkbnLy+X8XAaiEWk
+BGskIIqLi70c4MOLbZwlVQxQp+DLuQhwWmIQ3Fa+Gf6gF1IhUhY/5AUxKz4hK3P
GdRQ++l8m626y7pfS3Cy
=LKd/
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.

Re: Deploying JerseyWS 2.8 w/o web.xml

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Nicholas,

On 6/2/14, 12:38 PM, Cuneo, Nicholas wrote:
> I think you are correct, maybe I need to exclude some jars from my
> bundle?
> 
> find . -name "*.jar" | xargs grep
> ServletContainerInitializer.class Binary file ./servlet-api.jar
> matches
> 
> find ../webapps/api/WEB-INF/lib -name "*.jar" | xargs grep
> ServletContainerInitializer.class Binary file
> ../webapps/api/WEB-INF/lib/jersey-container-servlet-jar-2.8.jar
> matches Binary file
> ../webapps/api/WEB-INF/lib/javax.servlet-api-jar-3.0.1.jar matches

Yes, those are going to be a problem. and need to be removed from
WEB-INF/lib

You should also remove anything that provides JSP or EL APIs.

Like I said, Tomcat should be protecting itself against such classes
being loaded... are there any warnings during deployment that JAR
files are being rejected?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTjK0XAAoJEBzwKT+lPKRYnNoQALTKiIDycnKxYmAWt7QdQy2c
evQYKt1xEQwDUq1qrng7KDWaF5qgy6udm682z0RLgfNVQOmklXEkR8TTnPyuhaDY
QNrTg0ojQytXcVdBiyqiectVTkj9Bqf3nATGqUN20CI2zUuEvK1Bt+dvGzBTRNji
ckJSgNZyA6dbODr84jLZG4s5eVwrS+Ee68EtDuJSxKPtjWiBwMtzJ+1inYL9xHY+
jUXC71UCroj7typlNVeSTL6pUlPrs1xq2FJGNQn6Q5IecevLHK08EZlKkcqVdc5A
BH8/VlSnFgYBIDXCWY+UydFT+M3GmwLX5h120oTczY9doPAHF0W4s6anrzt6hPc7
mMOjHhBbgyMi2EigS/kGCpK4opiLTkGouba8JQQPmc6IhMRZyaEW3WyDDfaFlRGQ
w3cN/mQ0QKY0sirOPa4O2wqeH6rW/tG6i20MCKDOkT9X7KXEvLkvfTZDuQyi7FOI
Ew81AztOODBci6MByrgt7MVPmhLd0I+jaqAERLk3bLAKbd5CFDe5yHo5l3f+JMGB
dS+cQUFLu51GteTLLnhoiyZpER6OXKliZxytlbqbMfyj+iuMvkbnLy+X8XAaiEWk
+BGskIIqLi70c4MOLbZwlVQxQp+DLuQhwWmIQ3Fa+Gf6gF1IhUhY/5AUxKz4hK3P
GdRQ++l8m626y7pfS3Cy
=LKd/
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Deploying JerseyWS 2.8 w/o web.xml

Posted by "Cuneo, Nicholas" <nc...@tycoint.com>.
I think you are correct, maybe I need to exclude some jars from my bundle?

find . -name "*.jar" | xargs grep ServletContainerInitializer.class
Binary file ./servlet-api.jar matches

find ../webapps/api/WEB-INF/lib -name "*.jar" | xargs grep ServletContainerInitializer.class
Binary file ../webapps/api/WEB-INF/lib/jersey-container-servlet-jar-2.8.jar matches
Binary file ../webapps/api/WEB-INF/lib/javax.servlet-api-jar-3.0.1.jar matches

Thanks,
Nick


-----Original Message-----
From: Cuneo, Nicholas [mailto:ncuneo@tycoint.com]
Sent: Monday, June 02, 2014 9:25 AM
To: Tomcat Users List
Subject: RE: Deploying JerseyWS 2.8 w/o web.xml

We are using Ivy for our dependency manager, but I'm not exactly following what you mean.  Are you suggesting  I'm supplying a jar file in my war that  doesn't need to be there because Tomcat has its own version of it?

Thanks,
Nick


-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net]
Sent: Friday, May 30, 2014 4:55 PM
To: Tomcat Users List
Subject: Re: Deploying JerseyWS 2.8 w/o web.xml

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Nick

On 5/30/14, 5:03 PM, Cuneo, Nicholas wrote:
> We are trying to deploy a webservice to tomcat 8.0.5 using Jersey WS
> 2.8.  In the Jersey documentation it mentions deploying without the
> need for a web.xml in your war file using annotations, so I thought
> I’d give that a  try.
>
> However, when I go to deploy my webservice Tomcat is throwing the
> exception below, I can’t figure out what might be the issue.
>
>
>
> Some notes about our environment in case  they come into play:
>
> The webservice  is compiled with java 8.
>
> Tomcat is running on a linux server.
>
> As per the Jersey documentation, I have a class annotated with
> @ApplicationPath which extends ResourceConfig.  Our webservices exist
> in a separate package which is being loaded using the
> packages() function.
>
>
>
> 30-May-2014 20:57:22.592 SEVERE [localhost-startStop-4]
> org.apache.catalina.startup.ContextConfig.processServletContainerIniti
> alizers
>
>
Failed to process JAR found at URL [/api] for
> ServletContainerInitializers for context with name [{1}]
>
> java.io.IOException: java.lang.ClassCastException: Cannot cast
> org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer
> to javax.servlet.ServletContainerInitializer

It looks like you might have a JAR file in WEB-INF/lib that contains ServletContextInitializer or something similar. Tomcat should veto the loading of such classes, but something may have slipped-by.

Remember that runtime class is classloader + class, so the above error may be confusing: JerseyServletContainerInitializer does in fact extend ServletContainerInitializer (at least given their current API
javadoc) so the problem is likely that the ClassLoaders do not match.

Perhaps you are using Maven and it's unaware that Tomcat provides some of the javax.* packages itself?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTiRpRAAoJEBzwKT+lPKRYeZUP/RQ4NlB9yxhGaXVdBNoPVKdq
L8DakkbBlHLOVnOgEcyK++s5iOUFXHSeRVJuTIDQs0fAiDnMjC4V+3wynCJbzgz1
174AsN50+LEG4wvJ+rVwS0yBaEzwn7bHKY5zR/J0Rrry4Ms6J4xTuuL8nofr/qkJ
muNFagg+Ypxfbo9qH0Y/XgFMU7IVy4+ti3dtVKXCZJjjOkaRC9DB6A/Win83onAC
FU8zO2bgrTyGtJFsF1IK5VE9V4lafSIy8HgszWUm3zbG1dmrXpii65vdF+gSBALs
kyTN4bekR15O9ubuHXspqZwpJyEBxRLy71048PEHg0gQ4BCluy6nmksxeRTTtVsH
30VRsp2p/JlUHIJWrB/mJ98Co0hN5h2dwzodARarTm8Qm9P/ZDCDzOLj2cHgv6cY
AodGJYuLcNDiwfyv74kVyf0sr/mj54ghZ61ttLYPpqwcZyDTf9dmPiS/SuB9uSWa
oHOcg36v6s0FSIXlvpM+MZ7R1n+m/Dsj2u5dRkt/L/WzNBR7BSQqfs6vPiYoz5H7
IVRhgxYGZLXTmhNx/0yk14zr3EF8Ww84oXlyXNui2kM6jpGgkbleSV/1dkd6F3Ud
/mZxY8a5rqrqrEN/qgFRx0gk2LEtnQhE8p4qHT/2ij0Q1UQXMpPQBL4bdLIe4Zep
FPjzCGsmV9amCd6jvJU2
=6tVn
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.