You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Anand B N <an...@learningbyte.com> on 2001/08/27 15:48:02 UTC
Tomcat 4 help
Ok here's my problem:-
I have a Singleton class that gets instantiated while the Servlet(a
container servlet) initializes and in my web application I have JSPs with
Javabeans which then use the Singleton class(called TomcatManager) to get
handles on the Wrapper and Deployer objects so that I can control my
web-aplications.
The need here is to contol/administer web applications from a single point
and we wanted to have more control on adminstering the webapp but
automatically copying JARs required etc which the default Admin would not do.
So here's what I did:-
I took the catalina.jar that comes in CATALINA_HOME/server/lib and copied
it on to CATALINA_HOME/comman/lib.
And here's the exception that I get from the Java bean that's trying to use
the Deployer class:-
java.lang.LinkageError: Class org/apache/catalina/Context violates loader
constraints
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
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
org.apache.catalina.loader.StandardClassLoader.findClass(StandardClassLoader.java:670)
at
org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:1088)
at
org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:987)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at
com.lbi.cas.deployment.handlers.ListCASHandler.<init>(ListCASHandler.java:27)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:237)
at
com.lbi.cas.deployment.components.RequestManager.getRequestHandler(RequestManager.java:70)
at
org.apache.jsp._0002fjsp_0002fc3_0005fcas_0005flist_jsp._jspService(_0002fjsp_0002fc3_0005fcas_0005flist_jsp.java:90)
If I'm right this is sometihng to do with dependencies of the classes.
I'm not sure where I'm going wrong.
Anand
Re: Tomcat 4 help
Posted by Anand B N <an...@learningbyte.com>.
Craig,
Thanks for the input but let's say I have a situation wherein my web app
classes are to use a static class that has references of the Catalina
internals(like Deployer,Context) etc. should I come to a conclusion that
it is impossible a,s that's exactly what I'm doing with the application
that I am writing.
As you had suggested my Container servlet is in the server/lib folder and
my javabeans and other classes that the JSPs use in the common/lib folder.
Here's a method in a JavaBean that's called from one of the JSPs to list
available contexts
public boolean service()
{
try{
String contextPaths[] =
TomcatManager.getSharedInstance().getDeployer().findDeployedApps();
Context context;
casInstanceList = new Array();
response = new ResponseObject();
for (int i = 0; i < contextPaths.length; i++) {
context =
TomcatManager.getSharedInstance().getDeployer().findDeployedApp(contextPaths[i]);
casInstanceList.add(context);
}
...
..
}
Here TomcatManager is the static class that get's it's Deployer and Wrapper
instance set by the Container Servlet on initialization.
Though the task of listing context is a job done by the Manager servlet I
would like to do more than that and therefore thought if I had the
reference to Deployer object I would have better control.
The other thing is if I use a IDE like JBuilder this works perfectly fine
and my application has no problems like those mentioned earlier.
Here's my folder structure:-
/catalina
/common
/lib
- casadmin.jar - JAR containing all Javabeans used by my
JSPs/Webapp
/server
/lib
- catalina.jar - This contains my Container Servlet also
/webapp
/casadmin
- JSPs that use the Javabeans found in casadmin.jar
Hope that gives a better picture of what I'm trouble shooting.
Thanks
Anand
At 08:35 AM 8/27/01 -0700, you wrote:
>Moving catalina.jar is pretty much guaranteed to break things, as you
>found out. It's placed where it is for fundamental architectural reasons.
>
>The solution is to do what I described earlier:
>* Put your Container servlet, and any other class that needs
> access to Catalina internals in /servlet/classes or /serv/et/lib/*.jar.
>* Put classes that need to be visbile both to your Container servlet
> *and* to web apps in /common/classes or /common/lib/*.jar.
>
>Under no circumstances will any class loaded from a web app class loader
>be able to access the Catalina internal stuff. That is why, for example,
>the Manager webapp is designed the way that it is -- all requests are done
>via HTTP instead of method calls.
>
>(By the way, you could do the same thing by having your admin servlet use
>HttpURLConnection to perform the actual deploy and undeploy operations via
>ManagerServlet ...)
>
>Craig
>
>
>On Mon, 27 Aug 2001, Anand B N wrote:
>
> > Date: Mon, 27 Aug 2001 19:18:02 +0530
> > From: Anand B N <an...@learningbyte.com>
> > Reply-To: tomcat-user@jakarta.apache.org
> > To: tomcat-user@jakarta.apache.org
> > Subject: Tomcat 4 help
> >
> > Ok here's my problem:-
> >
> > I have a Singleton class that gets instantiated while the Servlet(a
> > container servlet) initializes and in my web application I have JSPs with
> > Javabeans which then use the Singleton class(called TomcatManager) to get
> > handles on the Wrapper and Deployer objects so that I can control my
> > web-aplications.
> >
> > The need here is to contol/administer web applications from a single point
> > and we wanted to have more control on adminstering the webapp but
> > automatically copying JARs required etc which the default Admin would
> not do.
> >
> > So here's what I did:-
> >
> > I took the catalina.jar that comes in CATALINA_HOME/server/lib and copied
> > it on to CATALINA_HOME/comman/lib.
> >
> > And here's the exception that I get from the Java bean that's trying to use
> > the Deployer class:-
> >
> > java.lang.LinkageError: Class org/apache/catalina/Context violates loader
> > constraints
> > at java.lang.ClassLoader.defineClass0(Native Method)
> > at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
> > at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
> > at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
> > 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
> >
> org.apache.catalina.loader.StandardClassLoader.findClass(StandardClassLoader.java:670)
> > at
> >
> org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:1088)
> > at
> >
> org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:987)
> > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> > at java.lang.Class.forName0(Native Method)
> > at java.lang.Class.forName(Class.java:120)
> > at
> >
> com.lbi.cas.deployment.handlers.ListCASHandler.<init>(ListCASHandler.java:27)
> > at java.lang.Class.newInstance0(Native Method)
> > at java.lang.Class.newInstance(Class.java:237)
> > at
> >
> com.lbi.cas.deployment.components.RequestManager.getRequestHandler(RequestManager.java:70)
> > at
> >
> org.apache.jsp._0002fjsp_0002fc3_0005fcas_0005flist_jsp._jspService(_0002fjsp_0002fc3_0005fcas_0005flist_jsp.java:90)
> >
> > If I'm right this is sometihng to do with dependencies of the classes.
> >
> > I'm not sure where I'm going wrong.
> >
> > Anand
> >
> >
> >
Re: Tomcat 4 help
Posted by "Craig R. McClanahan" <cr...@apache.org>.
Moving catalina.jar is pretty much guaranteed to break things, as you
found out. It's placed where it is for fundamental architectural reasons.
The solution is to do what I described earlier:
* Put your Container servlet, and any other class that needs
access to Catalina internals in /servlet/classes or /serv/et/lib/*.jar.
* Put classes that need to be visbile both to your Container servlet
*and* to web apps in /common/classes or /common/lib/*.jar.
Under no circumstances will any class loaded from a web app class loader
be able to access the Catalina internal stuff. That is why, for example,
the Manager webapp is designed the way that it is -- all requests are done
via HTTP instead of method calls.
(By the way, you could do the same thing by having your admin servlet use
HttpURLConnection to perform the actual deploy and undeploy operations via
ManagerServlet ...)
Craig
On Mon, 27 Aug 2001, Anand B N wrote:
> Date: Mon, 27 Aug 2001 19:18:02 +0530
> From: Anand B N <an...@learningbyte.com>
> Reply-To: tomcat-user@jakarta.apache.org
> To: tomcat-user@jakarta.apache.org
> Subject: Tomcat 4 help
>
> Ok here's my problem:-
>
> I have a Singleton class that gets instantiated while the Servlet(a
> container servlet) initializes and in my web application I have JSPs with
> Javabeans which then use the Singleton class(called TomcatManager) to get
> handles on the Wrapper and Deployer objects so that I can control my
> web-aplications.
>
> The need here is to contol/administer web applications from a single point
> and we wanted to have more control on adminstering the webapp but
> automatically copying JARs required etc which the default Admin would not do.
>
> So here's what I did:-
>
> I took the catalina.jar that comes in CATALINA_HOME/server/lib and copied
> it on to CATALINA_HOME/comman/lib.
>
> And here's the exception that I get from the Java bean that's trying to use
> the Deployer class:-
>
> java.lang.LinkageError: Class org/apache/catalina/Context violates loader
> constraints
> at java.lang.ClassLoader.defineClass0(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
> 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
> org.apache.catalina.loader.StandardClassLoader.findClass(StandardClassLoader.java:670)
> at
> org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:1088)
> at
> org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:987)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:120)
> at
> com.lbi.cas.deployment.handlers.ListCASHandler.<init>(ListCASHandler.java:27)
> at java.lang.Class.newInstance0(Native Method)
> at java.lang.Class.newInstance(Class.java:237)
> at
> com.lbi.cas.deployment.components.RequestManager.getRequestHandler(RequestManager.java:70)
> at
> org.apache.jsp._0002fjsp_0002fc3_0005fcas_0005flist_jsp._jspService(_0002fjsp_0002fc3_0005fcas_0005flist_jsp.java:90)
>
> If I'm right this is sometihng to do with dependencies of the classes.
>
> I'm not sure where I'm going wrong.
>
> Anand
>
>
>