Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Problem finding method while debugging
Problem finding method while debugging [message #184733] Thu, 14 December 2006 15:04 Go to next message
Eclipse User
Originally posted by: ns_dkerber.ns_WarrenRogersAssociates.com

I have a servlet which calls a static method in one of my utility jars
that is throwing a "NoSuchMethodError" when I try running it in debug
mode in Eclipse 3.2. That alone isn't the issue. The weirdness comes
in because it finds the method for code completion, and it compiles it
fine, but when it hits that line during execution, it chokes on it with
the NoSuchMethodError.

How can that be? Why can't it find something when running that it can
when compiling?

I have the utility project listed in both "j2ee module dependencies",
and in "Project References" for the webapp. From what someone said a
couple of days ago, I should only need it in j2ee dependencies, but
something I ran into (don't recall exactly what) was only repairable by
putting it into project references as well.

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Re: Problem finding method while debugging [message #184802 is a reply to message #184733] Thu, 14 December 2006 16:11 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry Isaacs
Messages: 1310
Registered: July 2009
Senior Member
David Kerber wrote:
> I have a servlet which calls a static method in one of my utility jars
> that is throwing a "NoSuchMethodError" when I try running it in debug
> mode in Eclipse 3.2. That alone isn't the issue. The weirdness comes
> in because it finds the method for code completion, and it compiles it
> fine, but when it hits that line during execution, it chokes on it with
> the NoSuchMethodError.
>
> How can that be? Why can't it find something when running that it can
> when compiling?

J2EE apps, such as web applications, run in an app server which provides
the runtime "classpath" for the J2EE app. Since the JDT support doesn't
understand J2EE, it isn't that hard to create a build time "classpath"
that doesn't match what the app's "classpath" will be when it runs in
the app server. There is also the issue of deployment of the J2EE app,
which provides an additional opportunity for something to go wrong.

In your case, there isn't enough information to tell for sure why the
difference is occurring. I assume this still occurs after you have
stopped and restarted the server. If you remove and re-add the Project
to the server, does it still happen? This would help identify if it is
an issue with publishing the web application to the server.

>
> I have the utility project listed in both "j2ee module dependencies",
> and in "Project References" for the webapp. From what someone said a
> couple of days ago, I should only need it in j2ee dependencies, but
> something I ran into (don't recall exactly what) was only repairable by
> putting it into project references as well.
>

I would be curious as to what including the utility project in the
Project References fixed, if you happen to remember at some point.

Cheers,
Larry
Re: Problem finding method while debugging [message #184845 is a reply to message #184802] Thu, 14 December 2006 17:58 Go to previous messageGo to next message
Eclipse User
Originally posted by: ns_dkerber.ns_WarrenRogersAssociates.com

In article <elrt3e$h1k$1@utils.eclipse.org>, Larry.Isaacs@sas.com
says...
> David Kerber wrote:
> > I have a servlet which calls a static method in one of my utility jars
> > that is throwing a "NoSuchMethodError" when I try running it in debug
> > mode in Eclipse 3.2. That alone isn't the issue. The weirdness comes
> > in because it finds the method for code completion, and it compiles it
> > fine, but when it hits that line during execution, it chokes on it with
> > the NoSuchMethodError.
> >
> > How can that be? Why can't it find something when running that it can
> > when compiling?
>
> J2EE apps, such as web applications, run in an app server which provides
> the runtime "classpath" for the J2EE app. Since the JDT support doesn't
> understand J2EE, it isn't that hard to create a build time "classpath"
> that doesn't match what the app's "classpath" will be when it runs in
> the app server. There is also the issue of deployment of the J2EE app,
> which provides an additional opportunity for something to go wrong.

Since I'm in debugging mode and Eclipse is therefore in charge of all
the deployment on Tomcat 5.5.15, I figured it would know exactly where
everything was.

>
> In your case, there isn't enough information to tell for sure why the
> difference is occurring. I assume this still occurs after you have
> stopped and restarted the server. If you remove and re-add the Project
> to the server, does it still happen? This would help identify if it is
> an issue with publishing the web application to the server.

I tried that, and all of a sudden I'm seeing a servlet error when I try
to open the app in firefox:

ava.lang.NoClassDefFoundError: javax/servlet/Servlet
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
java.net.URLClassLoader.defineClass(Unknown Source)
java.net.URLClassLoader.access$100(Unknown Source)
java.net.URLClassLoader$1.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
org.apache.catalina.loader.WebappClassLoader.loadClass
(WebappClassLoader.java:1267)
org.apache.catalina.loader.WebappClassLoader.loadClass
(WebappClassLoader.java:1198)
org.apache.jasper.servlet.JasperLoader.loadClass
(JasperLoader.java:127)
org.apache.jasper.servlet.JasperLoader.loadClass
(JasperLoader.java:65)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
org.apache.jsp.RealTimeConfig_jsp._jspService
(org.apache.jsp.RealTimeConfig_jsp:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.ja va:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java :264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

It's beginning to look to me like Eclipse is getting wrapped around its
own axles here; maybe I need to do a reinstall?

.....

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Re: Problem finding method while debugging [message #184871 is a reply to message #184845] Thu, 14 December 2006 21:55 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry Isaacs
Messages: 1310
Registered: July 2009
Senior Member
David Kerber wrote:
> In article <elrt3e$h1k$1@utils.eclipse.org>, Larry.Isaacs@sas.com
> says...
>> David Kerber wrote:
>>> I have a servlet which calls a static method in one of my utility jars
>>> that is throwing a "NoSuchMethodError" when I try running it in debug
>>> mode in Eclipse 3.2. That alone isn't the issue. The weirdness comes
>>> in because it finds the method for code completion, and it compiles it
>>> fine, but when it hits that line during execution, it chokes on it with
>>> the NoSuchMethodError.
>>>
>>> How can that be? Why can't it find something when running that it can
>>> when compiling?
>> J2EE apps, such as web applications, run in an app server which provides
>> the runtime "classpath" for the J2EE app. Since the JDT support doesn't
>> understand J2EE, it isn't that hard to create a build time "classpath"
>> that doesn't match what the app's "classpath" will be when it runs in
>> the app server. There is also the issue of deployment of the J2EE app,
>> which provides an additional opportunity for something to go wrong.
>
> Since I'm in debugging mode and Eclipse is therefore in charge of all
> the deployment on Tomcat 5.5.15, I figured it would know exactly where
> everything was.

Like the batch scripts that come with the binary Tomcat installs, all
Eclipse does is build Java command with a simple classpath, a few system
properties, a startup class, and a command to specify starting or
stopping. After launching this command, everything is up to Tomcat.
Eclipse is aware of common/lib as far as providing some runtime classes
for the project to build with. But beyond that, Eclipse doesn't
really know what exactly Tomcat is going to do beyond making
WEB-INF/classes and jars in WEB-INF/lib available to the webapp, as
required by the servlet spec.

>
>> In your case, there isn't enough information to tell for sure why the
>> difference is occurring. I assume this still occurs after you have
>> stopped and restarted the server. If you remove and re-add the Project
>> to the server, does it still happen? This would help identify if it is
>> an issue with publishing the web application to the server.
>
> I tried that, and all of a sudden I'm seeing a servlet error when I try
> to open the app in firefox:
>
> ava.lang.NoClassDefFoundError: javax/servlet/Servlet
> java.lang.ClassLoader.defineClass1(Native Method)
> java.lang.ClassLoader.defineClass(Unknown Source)
> java.security.SecureClassLoader.defineClass(Unknown Source)
> java.net.URLClassLoader.defineClass(Unknown Source)
> java.net.URLClassLoader.access$100(Unknown Source)
> java.net.URLClassLoader$1.run(Unknown Source)
> java.security.AccessController.doPrivileged(Native Method)
> java.net.URLClassLoader.findClass(Unknown Source)
> java.lang.ClassLoader.loadClass(Unknown Source)
> java.lang.ClassLoader.loadClass(Unknown Source)
> sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> java.lang.ClassLoader.loadClass(Unknown Source)
> org.apache.catalina.loader.WebappClassLoader.loadClass
> (WebappClassLoader.java:1267)
> org.apache.catalina.loader.WebappClassLoader.loadClass
> (WebappClassLoader.java:1198)
> org.apache.jasper.servlet.JasperLoader.loadClass
> (JasperLoader.java:127)
> org.apache.jasper.servlet.JasperLoader.loadClass
> (JasperLoader.java:65)
> java.lang.ClassLoader.loadClassInternal(Unknown Source)
> org.apache.jsp.RealTimeConfig_jsp._jspService
> (org.apache.jsp.RealTimeConfig_jsp:74)
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.ja va:97)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> org.apache.jasper.servlet.JspServletWrapper.service
> (JspServletWrapper.java:332)
> org.apache.jasper.servlet.JspServlet.serviceJspFile
> (JspServlet.java:314)
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java :264)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>
> It's beginning to look to me like Eclipse is getting wrapped around its
> own axles here; maybe I need to do a reinstall?
>

This stack trace indicates that the RealTimeConfig.jsp in your webapp is
dependent on a class that has been found in the Tomcat server's "simple"
classpath (indicated by the presence of
sun.misc.Launcher$AppClassLoader.loadClass). And that class in turn has
a dependency on javax.servlet.Servlet of the servlet API. The servlet
API classes are in common/lib. Because the "common/lib" classloader is
a child of the "Tomcat server's simple classpath" classloader, classes
in the "Tomcat server's simple classpath" classloader can not see the
server API classes, per the Java spec. This is why the
NoClassDefFoundError error is occurring.

I'm not aware of any classes that are normally included in the Tomcat
server's simple classpath that would have a dependency on the servlet
API. Do you know if something has been added to the Classpath in the
launch configuration for the Tomcat sever? It should list only
bootstrap.jar and optionally for Tomcat 5.5 tools.jar as User Entries.

Cheers,
Larry


> ....
>
Re: Problem finding method while debugging [message #184887 is a reply to message #184871] Thu, 14 December 2006 22:11 Go to previous message
Eclipse User
Originally posted by: ns_dkerber.ns_WarrenRogersAssociates.com

In article <elsh8u$l29$1@utils.eclipse.org>, Larry.Isaacs@sas.com
says...

....

> > Since I'm in debugging mode and Eclipse is therefore in charge of all
> > the deployment on Tomcat 5.5.15, I figured it would know exactly where
> > everything was.
>
> Like the batch scripts that come with the binary Tomcat installs, all
> Eclipse does is build Java command with a simple classpath, a few system
> properties, a startup class, and a command to specify starting or
> stopping. After launching this command, everything is up to Tomcat.
> Eclipse is aware of common/lib as far as providing some runtime classes
> for the project to build with. But beyond that, Eclipse doesn't
> really know what exactly Tomcat is going to do beyond making
> WEB-INF/classes and jars in WEB-INF/lib available to the webapp, as
> required by the servlet spec.
>
> >

....

> This stack trace indicates that the RealTimeConfig.jsp in your webapp is
> dependent on a class that has been found in the Tomcat server's "simple"
> classpath (indicated by the presence of
> sun.misc.Launcher$AppClassLoader.loadClass). And that class in turn has
> a dependency on javax.servlet.Servlet of the servlet API. The servlet
> API classes are in common/lib. Because the "common/lib" classloader is
> a child of the "Tomcat server's simple classpath" classloader, classes
> in the "Tomcat server's simple classpath" classloader can not see the
> server API classes, per the Java spec. This is why the
> NoClassDefFoundError error is occurring.
>
> I'm not aware of any classes that are normally included in the Tomcat
> server's simple classpath that would have a dependency on the servlet
> API. Do you know if something has been added to the Classpath in the
> launch configuration for the Tomcat sever? It should list only
> bootstrap.jar and optionally for Tomcat 5.5 tools.jar as User Entries.

Thanks for the explanations, Larry. As I posted in a separate thread
with a different question, it turned out that the class not found was
due to user error on my part. I ended up killing most of an afternoon
chasing my tail on this one before the stupidity finally took a coffee
break and I was able to see what was in front of my nose ;-/

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Previous Topic:Naming of servlets
Next Topic:jsp Hello World
Goto Forum:
  


Current Time: Sun Oct 26 01:07:50 GMT 2014

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

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