Tomcat/Eclipse: NoClassDefFoundError

M

Magnus Warker

Hi,

there is a Tomcat application which uses another library, provided as a
JAR-file.

The code compiles without problems in Eclipse, after I added the needed
JAR-file to the class path.

But the integrated Tomcat (Sysdeo) throws a NoClassDefFoundError and is
missing a class from the external library.

I already defined the classpath. Why is this not propagated to Tomcat? How
is this done the standard way?

Thank you,
Magnus
 
A

Axel

Magnus said:
Hi,

there is a Tomcat application which uses another library, provided as a
JAR-file.

The code compiles without problems in Eclipse, after I added the needed
JAR-file to the class path.

But the integrated Tomcat (Sysdeo) throws a NoClassDefFoundError and is
missing a class from the external library.

I already defined the classpath. Why is this not propagated to Tomcat? How
is this done the standard way?

Thank you,
Magnus

Hi Magnus,

I think you just added the jar file to the eclipse classpath, right? You
should put in the WEB-INF/lib directory so that it's deployed to tomcat
too. That should solve you problem, if I got you right. In Eclipse you
can reference the file from the WEB-INF/lib folder as well.

Cheers,
Axel
 
A

Andrew Thompson

Magnus Warker wrote:
..
there is a Tomcat application which uses another library, provided as a
JAR-file. ..
But the integrated Tomcat (Sysdeo) throws a NoClassDefFoundError ...
I already defined the classpath.

What or whose classpath?
...Why is this not propagated to Tomcat? How
is this done the standard way?

The standard way to make archives od classes available
to a web-app, is to place the archive in WEB-INF/lib and
perhaps restart the server.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
 
M

Magnus Warker

Hi Andrew and Axel,

thank you for your hints! I added the JAR as a symlink to the WEB-INF/lib
folder, and it worked.

But let me ask two questions about that:

1. Why do I need to specify this twice?
Once for Eclipse to treat my code as "known code" (syntax highlighting and
son on), and once for Tomcat to work? This is somewhat doubled
configuration, isn't it?

2. What about many projects using one library?
Assume many web projects using a single JAR library. Copying JAR files all
the time does not seem conventional for me. What I did in this case was
creating a symbolic link. Is this the normal way?

Thanks a lot!
Magnus
 
A

Axel Seinsche

Hi Magnus,

Magnus said:
thank you for your hints! I added the JAR as a symlink to the WEB-INF/lib
folder, and it worked.
That's fine. ;-)
But let me ask two questions about that:

1. Why do I need to specify this twice?
Once for Eclipse to treat my code as "known code" (syntax highlighting and
son on), and once for Tomcat to work? This is somewhat doubled
configuration, isn't it?
You don't need to specify it twice. Answer see question 2.
2. What about many projects using one library?
Assume many web projects using a single JAR library. Copying JAR files all
the time does not seem conventional for me. What I did in this case was
creating a symbolic link. Is this the normal way?
Of course you can do it with a symbolic link. This works for Linux/Unix
systems. But the normal way would be to copy the jar file in the
WEB-INF/lib folder in your eclipse project. When eclipse creates a WAR
or whatever archive you need, the lib will be automatically be deployed
with your project. Inside eclipse you can add jar files from your
WEB-INF/lib folder to be able to compile.
Thanks a lot!
Magnus
Hope this helps and answers your questions.

Cheers,
Axel
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Magnus said:
But let me ask two questions about that:

1. Why do I need to specify this twice?
Once for Eclipse to treat my code as "known code" (syntax highlighting and
son on), and once for Tomcat to work? This is somewhat doubled
configuration, isn't it?

You could view it that way, but consider that
you used Eclipse to develop an web
app with version N of the jar and NetBeans to develop another
web app with version N+1 of the jar and both got deployed to
the same Tomcat residing on a web hotel that you have only
HTTP and FTP access to.

They way it is makes that no problem. So consider it a feature.
You may not need it now. But you may need it some day.
2. What about many projects using one library?
Assume many web projects using a single JAR library. Copying JAR files all
the time does not seem conventional for me. What I did in this case was
creating a symbolic link. Is this the normal way?

shared/lib exist for that purpose, but be really sure that you want
that jar used by all web apps before putting something there.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top