tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filippo Machi <filippoma...@gmail.com>
Subject Re: Loading Super Classes with ClassLoader in Tomcat
Date Mon, 10 Oct 2011 17:39:24 GMT
Ciao Piter,
usually class loaders are arranged unto a hierarchy, who's the parente
classloader of the one you're using to define the class fronte the byte
array? It should've be the classloader whose scope us your webapp..
Hth
Fil
Il giorno 10/ott/2011 19.27, "Peter Lavin" <lavinp@cs.tcd.ie> ha scritto:

>
> Dear Users,
> I am running web-services (developed in CXF) in a Tomcat 7.0.14 server,
> Java version "1.6.0_17", OS, Linux <hostname> 2.6.18-238.9.1.el5 #1 SMP Tue
> Apr 12 18:10:13 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
>
>
> Part of my service code takes a byte array and defines a class using its
> contents which was not previously loaded in the JVM, code snippet as
> follows...
>
> Class<?> c = defineClass(name, byArray, 0, byArray.length);
>
> This code is in a class which extends java.lang.ClassLoader.
>
> The class represented by the byte array btArray is a class which extends a
> super class.
>
> Background...
>  * Dynamic loading of a class this way works in the IDE (Eclipse) when not
> running in a Tomcat server.
>  * The super class from which the loaded class extends is included in the
> war file, the files are present on the tomcat server.
>  * When loading a class which does not extend a super class (no
> inheritance), the above code works fine within the service in Tomcat.
>  * When using a class which implements an interface an interface but no
> inheritance, it also fails (with the following exception).
>  * When using a class which implements an interface which is in java.io.*,
> e.g. Serializable, the class loads ok within the Tomcat server.
>
> I have tried to use WebappClassloader, but cannot get the service to deploy
> when this class is imported from catalina.jar.
>
> Relevant parts of the error output is pasted here...
>
> WARNING: Application {http://peteragent.sga.org/}**
> AgentServiceImplService#{http:**//peteragent.sga.org/}process<http://peteragent.sga.org/%7DAgentServiceImplService#%7Bhttp://peteragent.sga.org/%7Dprocess>has
thrown exception, unwinding now
> org.apache.cxf.interceptor.**Fault: common/core/**AbstractServiceProvider
>        at org.apache.cxf.service.**invoker.AbstractInvoker.**
> createFault(AbstractInvoker.**java:155)
> [...abridgment...]
> Caused by: java.lang.**NoClassDefFoundError: common/core/**
> AbstractServiceProvider
>        at java.lang.ClassLoader.**defineClass1(Native Method)
>        at java.lang.ClassLoader.**defineClass(ClassLoader.java:**632)
>        at java.lang.ClassLoader.**defineClass(ClassLoader.java:**478)
>        at common.utilities.ClassLoading.**FileClassLoader.loadClass(**
> FileClassLoader.java:24)
> [end]
>
>
> My questions, has anyone also had this problem?
> Is WebappClassLoader designed to overcome this problem?
> Does anyone know why the class loads, but the JVM/ClassLoader is unable to
> find the super classes (although they are present). I'm aware that Tomcat
> uses a different ClassLoader for each webapp, but the required classes
> should be present in the ClassLoader of the webapp in question as they are
> in the war, and are in the file .../webapps/serviceName/WEB-**INF/classes/
> directory.
>
>
> with thanks,
> Peter
>
>
> --
> with best regards,
> Peter Lavin,
> PhD Candidate,
> Computer Architecture & Grid Research Group,
> Lloyd Institute, 005,
> Trinity College Dublin, Ireland.
> +353 1 8961536
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<users-unsubscribe@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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