Discussion:
Why does Netbeans place jersey libs in straight Java EE 6 WAR?
Jan Algermissen
2012-01-24 12:10:42 UTC
Permalink
Hi,

sorry if this is slightly off-topic, but I figured that most of the knowledgeable and likely interested people are on this list.

I am working on a Java EE 6 application, using JAX-RS but no Jersey specific features. However, when I build the application, Netbeans includes jersey libraries in the WAR. When I deploy that WAR to JBoss 6 there seems to be a missing library:

"java.lang.ClassNotFoundException: com.sun.jersey.core.util.FeaturesAndProperties"

Does anyone know, whet the Jersey libs are included in the WAR and if I can keep netbeans from doing that?

Jan
John Yeary
2012-01-24 16:38:12 UTC
Permalink
Hello Jan,

You can right-click on the project and go to Properties --> libraries and
uncheck the package checkboxes to not include the jars in your war file.
This will resolve to using the default EE implementation in GlassFish. See
attached image.

John
____________________________

John Yeary
____________________________

<http://javaevangelist.blogspot.com/> <https://twitter.com/jyeary>
<http://www.youtube.com/johnyeary>
<http://www.linkedin.com/in/jyeary>
<https://plus.google.com/112146428878473069965>
<http://www.facebook.com/jyeary>
<http://feeds.feedburner.com/JavaEvangelistJohnYearysBlog>
<http://netbeans.org/people/84414-jyeary>
____________________________

"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
-- Theodore Roosevelt



On Tue, Jan 24, 2012 at 12:10 PM, Jan Algermissen
Post by Jan Algermissen
Hi,
sorry if this is slightly off-topic, but I figured that most of the
knowledgeable and likely interested people are on this list.
I am working on a Java EE 6 application, using JAX-RS but no Jersey
specific features. However, when I build the application, Netbeans includes
jersey libraries in the WAR. When I deploy that WAR to JBoss 6 there seems
com.sun.jersey.core.util.FeaturesAndProperties"
Does anyone know, whet the Jersey libs are included in the WAR and if I
can keep netbeans from doing that?
Jan
Jan Algermissen
2012-01-26 11:02:51 UTC
Permalink
Thanks John! I figured that out after a while.
Post by John Yeary
Hello Jan,
You can right-click on the project and go to Properties --> libraries and uncheck the package checkboxes to not include the jars in your war file. This will resolve to using the default EE implementation in GlassFish.
Still unintuitive, that GF is doing that by default.

Jan
Post by John Yeary
See attached image.
John
____________________________
John Yeary
____________________________
____________________________
"Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the gray twilight that knows not victory nor defeat."
-- Theodore Roosevelt
Hi,
sorry if this is slightly off-topic, but I figured that most of the knowledgeable and likely interested people are on this list.
"java.lang.ClassNotFoundException: com.sun.jersey.core.util.FeaturesAndProperties"
Does anyone know, whet the Jersey libs are included in the WAR and if I can keep netbeans from doing that?
Jan
<PackageSelection.png>
John Yeary
2012-01-26 14:21:09 UTC
Permalink
Actually, the default behavior does make sense generally. If you add a
framework to your project, you can not expect the application server to
have the required libraries. In this case GlassFish includes JAX-RS
(Jersey), but simply selecting Apache Tomcat as a server choice would
require them.

Also the version on the server can be overridden by the packaged version.
This is accomplished easily by adding the 1.11 framework to your project.
In the case of Apache Tomcat you would simply deploy those bits, for
GlassFish we need to change the sun-web.xml or glassfish-web.xml to
override the classloader and set it to false. Otherwise you will load the
default JAX-RS implementation from Java EE instead of 1.11

<SNIP>

<glassfish-web-app error-url="">
<context-root>/jersey</context-root>
<class-loader delegate="false"/> <!-- NEEDS TO BE SET TO FALSE TO USE
1.11 PACKAGED IN WAR -->
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java
code.</description>
</property>
</jsp-config>
</glassfish-web-app>

</SNIP>
____________________________

John Yeary
____________________________

<http://javaevangelist.blogspot.com/> <https://twitter.com/jyeary>
<http://www.youtube.com/johnyeary>
<http://www.linkedin.com/in/jyeary>
<https://plus.google.com/112146428878473069965>
<http://www.facebook.com/jyeary>
<http://feeds.feedburner.com/JavaEvangelistJohnYearysBlog>
<http://netbeans.org/people/84414-jyeary>
____________________________

"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
-- Theodore Roosevelt
Post by Jan Algermissen
Thanks John! I figured that out after a while.
Post by John Yeary
Hello Jan,
You can right-click on the project and go to Properties --> libraries
and uncheck the package checkboxes to not include the jars in your war
file. This will resolve to using the default EE implementation in GlassFish.
Still unintuitive, that GF is doing that by default.
Jan
Post by John Yeary
See attached image.
John
____________________________
John Yeary
____________________________
____________________________
"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
Post by John Yeary
-- Theodore Roosevelt
On Tue, Jan 24, 2012 at 12:10 PM, Jan Algermissen <
Hi,
sorry if this is slightly off-topic, but I figured that most of the
knowledgeable and likely interested people are on this list.
Post by John Yeary
I am working on a Java EE 6 application, using JAX-RS but no Jersey
specific features. However, when I build the application, Netbeans includes
jersey libraries in the WAR. When I deploy that WAR to JBoss 6 there seems
com.sun.jersey.core.util.FeaturesAndProperties"
Post by John Yeary
Does anyone know, whet the Jersey libs are included in the WAR and if I
can keep netbeans from doing that?
Post by John Yeary
Jan
<PackageSelection.png>
Jan Algermissen
2012-01-26 14:35:06 UTC
Permalink
Actually, the default behavior does make sense generally. If you add a framework to your project, you can not expect the application server to have the required libraries. In this case GlassFish includes JAX-RS (Jersey), but simply selecting Apache Tomcat as a server choice would require them.
Ah, yes. My mistake. I forgot that the target need not be a an EE 6 container (which has JAX-RS already).

Jan
Also the version on the server can be overridden by the packaged version. This is accomplished easily by adding the 1.11 framework to your project. In the case of Apache Tomcat you would simply deploy those bits, for GlassFish we need to change the sun-web.xml or glassfish-web.xml to override the classloader and set it to false. Otherwise you will load the default JAX-RS implementation from Java EE instead of 1.11
<SNIP>
<glassfish-web-app error-url="">
<context-root>/jersey</context-root>
<class-loader delegate="false"/> <!-- NEEDS TO BE SET TO FALSE TO USE 1.11 PACKAGED IN WAR -->
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>
</SNIP>
____________________________
John Yeary
____________________________
____________________________
"Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the gray twilight that knows not victory nor defeat."
-- Theodore Roosevelt
Thanks John! I figured that out after a while.
Post by John Yeary
Hello Jan,
You can right-click on the project and go to Properties --> libraries and uncheck the package checkboxes to not include the jars in your war file. This will resolve to using the default EE implementation in GlassFish.
Still unintuitive, that GF is doing that by default.
Jan
Post by John Yeary
See attached image.
John
____________________________
John Yeary
____________________________
____________________________
"Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the gray twilight that knows not victory nor defeat."
-- Theodore Roosevelt
Hi,
sorry if this is slightly off-topic, but I figured that most of the knowledgeable and likely interested people are on this list.
"java.lang.ClassNotFoundException: com.sun.jersey.core.util.FeaturesAndProperties"
Does anyone know, whet the Jersey libs are included in the WAR and if I can keep netbeans from doing that?
Jan
<PackageSelection.png>
John Yeary
2012-01-26 14:41:47 UTC
Permalink
I am actually glad you questioned it. It gave me an opportunity to respond
with a more elaborate answer which may help someone else.

If something doesn't make sense it is good to question it. Adoption
requires sensible choices, and ease of use.

John
____________________________

John Yeary
____________________________

<http://javaevangelist.blogspot.com/> <https://twitter.com/jyeary>
<http://www.youtube.com/johnyeary>
<http://www.linkedin.com/in/jyeary>
<https://plus.google.com/112146428878473069965>
<http://www.facebook.com/jyeary>
<http://feeds.feedburner.com/JavaEvangelistJohnYearysBlog>
<http://netbeans.org/people/84414-jyeary>
____________________________

"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
-- Theodore Roosevelt
Post by John Yeary
Post by John Yeary
Actually, the default behavior does make sense generally. If you add a
framework to your project, you can not expect the application server to
have the required libraries. In this case GlassFish includes JAX-RS
(Jersey), but simply selecting Apache Tomcat as a server choice would
require them.
Ah, yes. My mistake. I forgot that the target need not be a an EE 6
container (which has JAX-RS already).
Jan
Post by John Yeary
Also the version on the server can be overridden by the packaged
version. This is accomplished easily by adding the 1.11 framework to your
project. In the case of Apache Tomcat you would simply deploy those bits,
for GlassFish we need to change the sun-web.xml or glassfish-web.xml to
override the classloader and set it to false. Otherwise you will load the
default JAX-RS implementation from Java EE instead of 1.11
Post by John Yeary
<SNIP>
<glassfish-web-app error-url="">
<context-root>/jersey</context-root>
<class-loader delegate="false"/> <!-- NEEDS TO BE SET TO FALSE TO USE
1.11 PACKAGED IN WAR -->
Post by John Yeary
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java
code.</description>
Post by John Yeary
</property>
</jsp-config>
</glassfish-web-app>
</SNIP>
____________________________
John Yeary
____________________________
____________________________
"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
Post by John Yeary
-- Theodore Roosevelt
On Thu, Jan 26, 2012 at 6:02 AM, Jan Algermissen <
Thanks John! I figured that out after a while.
Post by John Yeary
Hello Jan,
You can right-click on the project and go to Properties --> libraries
and uncheck the package checkboxes to not include the jars in your war
file. This will resolve to using the default EE implementation in GlassFish.
Post by John Yeary
Still unintuitive, that GF is doing that by default.
Jan
Post by John Yeary
See attached image.
John
____________________________
John Yeary
____________________________
____________________________
"Far better it is to dare mighty things, to win glorious triumphs,
even though checkered by failure, than to take rank with those poor spirits
who neither enjoy much nor suffer much, because they live in the gray
twilight that knows not victory nor defeat."
Post by John Yeary
Post by John Yeary
-- Theodore Roosevelt
On Tue, Jan 24, 2012 at 12:10 PM, Jan Algermissen <
Hi,
sorry if this is slightly off-topic, but I figured that most of the
knowledgeable and likely interested people are on this list.
Post by John Yeary
Post by John Yeary
I am working on a Java EE 6 application, using JAX-RS but no Jersey
specific features. However, when I build the application, Netbeans includes
jersey libraries in the WAR. When I deploy that WAR to JBoss 6 there seems
com.sun.jersey.core.util.FeaturesAndProperties"
Post by John Yeary
Post by John Yeary
Does anyone know, whet the Jersey libs are included in the WAR and if
I can keep netbeans from doing that?
Post by John Yeary
Post by John Yeary
Jan
<PackageSelection.png>
Loading...