Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » HttpServlet class not found if using module dependency
HttpServlet class not found if using module dependency [message #222602] Wed, 08 October 2008 12:23 Go to next message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Hi,

I have a webproject with a "J2EE Module Dependency" to a project that
contains the actual servlet (this servlet is quite generic and can be
used in different webprojects). If I try to run the webproject on the
server (Tomcat 6.0), I get an error saying that the class
javax.servlet.http.HttpServlet cannot be found
(java.lang.NoClassDefFoundError: HttpServlet). The error appears whether
"Serve modules without publishing" is checked or not.

Is this a classloader problem? Is there a way to circumvent it?

Cheers,

Dominik
Re: HttpServlet class not found if using module dependency [message #222604 is a reply to message #222602] Wed, 08 October 2008 14:59 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
Dominik Raymann wrote:
> Hi,
>
> I have a webproject with a "J2EE Module Dependency" to a project that
> contains the actual servlet (this servlet is quite generic and can be
> used in different webprojects). If I try to run the webproject on the
> server (Tomcat 6.0), I get an error saying that the class
> javax.servlet.http.HttpServlet cannot be found
> (java.lang.NoClassDefFoundError: HttpServlet). The error appears whether
> "Serve modules without publishing" is checked or not.
>
> Is this a classloader problem?

Yes.

> Is there a way to circumvent it?

Probably. However, there isn't much here with which to make a guess as
to the exact cause and how to fix. Maybe the stacktrace associated with
the error will provide some clues.

Cheers,
Larry

>
> Cheers,
>
> Dominik
Re: HttpServlet class not found if using module dependency [message #222614 is a reply to message #222604] Thu, 09 October 2008 08:56 Go to previous messageGo to next message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Here's what I found out (and what solved the problem):
The project I am referencing to is a maven project. If I export (via
Java Build Path, Order and Export) all maven dependencies (and therefore
the servlet api too) the error is gone and my web project (not being a
maven project) works fine. Unfortunately this export is not
automatically checked by the m2eclipse plugin on import. I'm not really
sure whether this solution is exactly the best for servlet api & Co. But
it works.

By the way, what is the difference between referencing a project via the
"Java EE Module Dependency" and referencing it via the "Java Build
Path"/"Projects" tab?

Cheers,

Dominik

Larry Isaacs schrieb:
> Dominik Raymann wrote:
>> Hi,
>>
>> I have a webproject with a "J2EE Module Dependency" to a project that
>> contains the actual servlet (this servlet is quite generic and can be
>> used in different webprojects). If I try to run the webproject on the
>> server (Tomcat 6.0), I get an error saying that the class
>> javax.servlet.http.HttpServlet cannot be found
>> (java.lang.NoClassDefFoundError: HttpServlet). The error appears
>> whether "Serve modules without publishing" is checked or not.
>>
>> Is this a classloader problem?
>
> Yes.
>
>> Is there a way to circumvent it?
>
> Probably. However, there isn't much here with which to make a guess as
> to the exact cause and how to fix. Maybe the stacktrace associated with
> the error will provide some clues.
>
> Cheers,
> Larry
>
>>
>> Cheers,
>>
>> Dominik
Re: HttpServlet class not found if using module dependency [message #222615 is a reply to message #222614] Thu, 09 October 2008 10:35 Go to previous messageGo to next message
Kaloyan Raev is currently offline Kaloyan RaevFriend
Messages: 189
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
> By the way, what is the difference between referencing a project via the
> "Java EE Module Dependency" and referencing it via the "Java Build
> Path"/"Projects" tab?

"Java Build Path" specifies the compile-time dependencies between the Java
project in the workspace. These settings are also used by the run
configuration when you try to run you Java application from within the
Eclipse IDE - the dependent projects are included in the classpath.

"Java EE Module Dependencies" specify the compile-time and run-time
dependencies between Java EE modules and JARs. It looks really similar to
the "Java Build Path", but there are important differences specific to the
Java EE technology. The settings of the "Java EE Module Dependencies" are
typically reflected in the MANIFEST.MF's Class-Path parameter. This is the
place where you specify the class-path when running a Java EE application on
an application server. Another place that these settings are used are also
during export of the modules. For example, when you export an EAR all
dependent Java EE modules and JARs are packed in the EAR archive.

In general, you may thing of the Java Build Path like Java SE dependencies
and of the Java EE Module Dependencies like, well, Java EE dependencies.

Greetings,
Kaloyan
Re: HttpServlet class not found if using module dependency [message #222618 is a reply to message #222614] Thu, 09 October 2008 13:17 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
I'm not clear to me exactly how this is fixing the problem since I'm not
sure exactly what the cause of the error was. However, since you
mention maven, it seems conceivable that Bug 242476[1] might be
contributing to this issue, assuming you aren't already using WTP 3.0.2.
What is the difference in the contents of the webapp's WEB-INF/lib
with and without exporting all maven dependencies?

Cheers,
Larry

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=242476

Dominik Raymann wrote:
> Here's what I found out (and what solved the problem):
> The project I am referencing to is a maven project. If I export (via
> Java Build Path, Order and Export) all maven dependencies (and therefore
> the servlet api too) the error is gone and my web project (not being a
> maven project) works fine. Unfortunately this export is not
> automatically checked by the m2eclipse plugin on import. I'm not really
> sure whether this solution is exactly the best for servlet api & Co. But
> it works.
>
> By the way, what is the difference between referencing a project via the
> "Java EE Module Dependency" and referencing it via the "Java Build
> Path"/"Projects" tab?
>
> Cheers,
>
> Dominik
>
> Larry Isaacs schrieb:
>> Dominik Raymann wrote:
>>> Hi,
>>>
>>> I have a webproject with a "J2EE Module Dependency" to a project that
>>> contains the actual servlet (this servlet is quite generic and can be
>>> used in different webprojects). If I try to run the webproject on the
>>> server (Tomcat 6.0), I get an error saying that the class
>>> javax.servlet.http.HttpServlet cannot be found
>>> (java.lang.NoClassDefFoundError: HttpServlet). The error appears
>>> whether "Serve modules without publishing" is checked or not.
>>>
>>> Is this a classloader problem?
>>
>> Yes.
>>
>>> Is there a way to circumvent it?
>>
>> Probably. However, there isn't much here with which to make a guess
>> as to the exact cause and how to fix. Maybe the stacktrace associated
>> with the error will provide some clues.
>>
>> Cheers,
>> Larry
>>
>>>
>>> Cheers,
>>>
>>> Dominik
Re: HttpServlet class not found if using module dependency [message #222621 is a reply to message #222618] Fri, 10 October 2008 08:44 Go to previous message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Mea culpa, maxima culpa.
Err, looks like I overlooked an important fact: the error I was getting
all the time was not (i.e. no longer) because of the Servlet defined in
the referenced project but because of a filter defined in the project
itself. This filter didn't compile because I missed to include the
servlet api in my build path. Then I didn't realize the compile error
since I had several other errors (mainly in HTML files).

So even without exporting (what included the servlet api in the build
path) the application runs now.

In the end, it was all my fault. Sorry for bothering you.

Larry Isaacs schrieb:
> I'm not clear to me exactly how this is fixing the problem since I'm not
> sure exactly what the cause of the error was. However, since you
> mention maven, it seems conceivable that Bug 242476[1] might be
> contributing to this issue, assuming you aren't already using WTP 3.0.2.
> What is the difference in the contents of the webapp's WEB-INF/lib with
> and without exporting all maven dependencies?
>
> Cheers,
> Larry
>
> [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=242476
>
> Dominik Raymann wrote:
>> Here's what I found out (and what solved the problem):
>> The project I am referencing to is a maven project. If I export (via
>> Java Build Path, Order and Export) all maven dependencies (and
>> therefore the servlet api too) the error is gone and my web project
>> (not being a maven project) works fine. Unfortunately this export is
>> not automatically checked by the m2eclipse plugin on import. I'm not
>> really sure whether this solution is exactly the best for servlet api
>> & Co. But it works.
>>
>> By the way, what is the difference between referencing a project via
>> the "Java EE Module Dependency" and referencing it via the "Java Build
>> Path"/"Projects" tab?
>>
>> Cheers,
>>
>> Dominik
>>
>> Larry Isaacs schrieb:
>>> Dominik Raymann wrote:
>>>> Hi,
>>>>
>>>> I have a webproject with a "J2EE Module Dependency" to a project
>>>> that contains the actual servlet (this servlet is quite generic and
>>>> can be used in different webprojects). If I try to run the
>>>> webproject on the server (Tomcat 6.0), I get an error saying that
>>>> the class javax.servlet.http.HttpServlet cannot be found
>>>> (java.lang.NoClassDefFoundError: HttpServlet). The error appears
>>>> whether "Serve modules without publishing" is checked or not.
>>>>
>>>> Is this a classloader problem?
>>>
>>> Yes.
>>>
>>>> Is there a way to circumvent it?
>>>
>>> Probably. However, there isn't much here with which to make a guess
>>> as to the exact cause and how to fix. Maybe the stacktrace
>>> associated with the error will provide some clues.
>>>
>>> Cheers,
>>> Larry
>>>
>>>>
>>>> Cheers,
>>>>
>>>> Dominik
Previous Topic:How to turn off JavaScript validation in the JSP editor?
Next Topic:Differences between the Linux/i386 and Win32/i386
Goto Forum:
  


Current Time: Fri Nov 28 18:32:10 GMT 2014

Powered by FUDForum. Page generated in 0.01734 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software