tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Baugher <bjb...@gmail.com>
Subject Re: NoSuchMethodError loading class in webapp from common class loader
Date Fri, 03 May 2013 14:45:31 GMT
Sorry I tried to leave on what I thought were unnecessary details.

You are correct my constructor has arguments. One of the arguments comes
from another dependency jar that exists in both the webapp and tomcat/lib
so I think your guess (c) could be right. I guess the solution would be to
move the dependency out of the webapp and into tomcat/lib.


On Fri, May 3, 2013 at 9:16 AM, Konstantin Kolinko
<knst.kolinko@gmail.com>wrote:

> 2013/5/3 Bryan Baugher <bjbq4d@gmail.com>:
> > Hi,
> >
> > I am running Tomcat 7.0.28 on RHEL 6.2 with a single web app. The web app
> > in question uses reflection to load some implementations of our classes
> > (kind of like a service loader) knowing the class name. I am trying to
> add
> > additional implementations by dropping them in the tomcat's lib directory
> > but I keep seeing NoSuchMethodError for the constructor to the class.
> >
> > I know the constructor is there because if I move the jar into the web
> > app's lib directory (webapp/[WEB_APP]/WEB_INF/lib) everything works.
> >
> > I figure this must be some class loader issue I am not understanding but
> > these docs[1][2] don't seem to indicate there should be any issue.
> >
> > -Bryan
> >
> > [1] - http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
> >
> > [2] -
> http://download.oracle.com/otndocs/jcp/servlet-2.4-fr-spec-oth-JSpec/
>
> Using the common classloader is somewhat tricky,  because the "Webapp
> classloader has priority" rule imposed by servlet spec does mess up
> things, as explained in [1].
>
> Your description does not have enough details, nor source code, nor
> stacktaces, and with such I would guess that you have the following:
>
> a) Your constructor has some arguments
> b) The classes mentioned as argument types in that method can be
> loaded both from common class loader and from webapp classloader. (If
> they cannot be loaded from the former, you are also in trouble).
> c) Classes loaded from different classloaders are considered different
> by JVM (even if they have the same name and bytecode),.
> You are asking for a method specifying its arguments by using classes
> loaded by webapp classloader and they do not match the ones loaded by
> common classloader
>
> Just a guess.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
-Bryan

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message