Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Custom JAR visible to web applications

Hi

I had a similar issue the other day, I received this NoClassDefFound error when I had mistakenly placed the jar file in my WEB-INF/lib with the version number in the filename when the original jar already existed in WEB-INF/lib as well without the version.

What I mean is that I had myjar.jar and deployed myjar-1.0.jar as well. The class in myjar-1.0 was not being loaded.
Removing the version number from myjar's POM resulted in it building to myjar.jar and all worked thereafter.



On Wed, Jul 23, 2014 at 1:37 PM, Ney André de Mello Zunino <zunino@xxxxxxxxxxxxxxx> wrote:
Hi and sorry for the missing details; here they are:

I'm using Jetty 9.2.1 running on OpenJDK 7.

My shared JAR has been placed in my '${jetty.home}/lib/ext' which,
AFAIC, is the same as '${jetty.base}/lib/ext', since I'm not specifying
a different base. Am I right? The classes in the shared JAR have nothing
special about them. They don't use annotations.

My webapp is a very simple Servlet 2.4 application. It contains a filter
which indeed makes use of a couple of classes in the shared JAR. And
here's where the 'NoClassDefFound' error occurs. The app's also got a
Servlet which references classes in the shared JAR. And that's about it.

As I said in my original message, the JAR is definitely being added to
the classpath reported by 'java -jar start.jar --list-classpath'. I've
read about the fact that web applications prioritize libraries and
resources within their 'WEB-INF', but I expected the container's
classpath to be visible as well. Surely, I must be missing something.

Anything else I should add?

Thank you!

On 22-07-2014 20:00, Jan Bartel wrote:
> You don't say which version of jetty, nor the circumstances in which
> the class should be found - is it a servlet/filter/listener or a pojo
> or via an annotation or ...?
>
> Have you put your jar in your ${jetty.base}/lib/ext or in the top
> level ${jetty.home}/lib/ext? Did you enable the ext module in
> ${jetty.base} or in ${jetty.home}?
>
> Jan
>
> On 23 July 2014 00:03, Ney André de Mello Zunino <zunino@xxxxxxxxxxxxxxx> wrote:
>> Hello.
>>
>> I'm new to Jetty and I have a question regarding class paths. I wish to
>> have a custom library (JAR) shared by multiple applications running in
>> the container. I added the JAR file to '<JETTY_HOME>/lib/ext' and
>> verified that it is actually being added to the CLASSPATH by running
>> 'java -jar start.jar --list-classpath'. However, 'NoClassDefFound'
>> errors occur when the web application is run.
>>
>> How can I make my custom JAR visible to the web application? Ideally, I
>> wish I could do that without modifying the WAR deployment so that newly
>> added applications would also have the custom JAR on their CLASSPATH
>> without extra configuration.
>>
>> Thank you in advance and sorry if the question is too trivial. I admit I
>> haven't been able to find a proper solution (given my requirements).
>>
>> --
>> Zunino
>> _______________________________________________
>> jetty-users mailing list
>> jetty-users@xxxxxxxxxxx
>> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
>
>

--
Ney André de Mello Zunino
Analista de Pesquisa e Desenvolvimento
Softplan/Poligraph
+55 48 3027-8000
www.softplan.com.br
twitter.com/softplanonline
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top