Closed GoogleCodeExporter closed 9 years ago
I should also mention, this is Eclipse 3.4.1 (as well as 3.5.1RC1) on OS X,
m2eclipse
plugin v. 0.9.8. And this is not limited to the filters. In webapps without
filters I
am getting errors about various missing resources from related projects.
Original comment by aadamc...@gmail.com
on 16 Oct 2009 at 7:39
I am surprised by this report as I've used just such an arrangement. Would you
be
willing to create a small sample that demonstrates the problem? The web app
doesn't
have to do anything interesting, just demonstrate the failure to locate the
filters and
resources.
Original comment by James.Sy...@gmail.com
on 17 Oct 2009 at 12:21
Things look a bit random in my tests. When I tried to reproduce the issue as
originally reported, a vanilla project with a filter in a dependency jar worked.
Either it is now masked by another issue below, or I got stale plugins after a
few
run-jetty-run (un/re)installs yesterday.
Anyways, today I started fresh with rjr 1.1.1 (starting Eclipse with "-clean").
And
now I am consistently getting a java.lang.NoClassDefFoundError on an attempt to
dynamically load a class inside Servlet.init(). I attached a simple test
project. The
project itself does not have any Eclipse project dependencies. I reduced it to
bare
minimum. The case is a bit unusual, but nevertheless it works with 1.0.1. The
class I
am loading is not a maven dependency of the project, but rather from a jar
added in
Eclipse to the Run Configuration via "Run Configurations.. > XYZ Jetty Config >
Classpath" (the jar file - cayenne-modeler-3.0M6.jar is also included in the
download). The exception thrown is complaining about the interface implemented
by the
class in question. Interface itself is available as a Maven dependency
everywhere
else in the project, just not to the dynamically loaded class. So there's some
cross-ClassLoader issue going on.
The code looks like this:
MyServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Object object = Class
.forName("org.example.MyClass", true, loader).newInstance();
}
The stack trace is this:
java.lang.NoClassDefFoundError: org/apache/cayenne/conf/DataSourceFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:352)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at org.example.framework.MyServlet.init(MyServlet.java:19)
Original comment by aadamc...@gmail.com
on 19 Oct 2009 at 7:22
Original comment by aadamc...@gmail.com
on 19 Oct 2009 at 7:23
Attachments:
I think it's kind of wrong usage,
we should make it more clear for this defect in future.
In the classpath of Jetty Run-Configuration,
it's for the *Jetty Web Server* , not for the web application project.
So if you want to use it in web application project ,
it's better to add the external jar to project build Libraries.
I will check the view and the rule , to check if we could do something to make
it better. :P
Original comment by tonylovejava
on 11 Mar 2011 at 9:06
Original comment by tonylovejava
on 20 Mar 2011 at 5:51
It's better to have a doucment talking the different for the classpath provider
in run configuration and the classpath for the webapp project.
Original comment by tonylovejava
on 22 Mar 2011 at 5:13
Try to write a document , hope we get it clear enough. :-|
[Classpath]
Original comment by tonylovejava
on 4 May 2011 at 3:29
Original issue reported on code.google.com by
aadamc...@gmail.com
on 16 Oct 2009 at 7:21