Dynamically add jar file to classpath while tomcat is running

2002-07-11 Thread KAKARONTZAS GEORGE

Hi all,
I'm building a system that must be able to execute any java app that
will be uploaded.
In fact the server (a web app running under tomcat) just dispatches
these applications to other pcs.
The problem is that while the server serializes the application class
files for dispatching I get a HTTP 500 error on the pcs that want to
execute the code.
I'm not getting this if I copy the app files (contained in a jar) in the
WEB-INF/lib before starting tomcat.
So I concluded that the reason for the error is that this jar file is
not in the classpath of the web application class loader.
First I want to ask if you agree with that.
Second, if you do is there a way to add a jar file in the web
application class loader classpath, while the application is running.
Note that I modified the code so that the jar file is copied in
WEB-INF/lib after uploading, but that didn't work.

Thanks
-George



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Applet-servlet communication problem with Tomcat 4.0.3

2002-05-13 Thread KAKARONTZAS GEORGE

Many thanks.
-George

-Original Message-
From: Douglas, Rory [mailto:[EMAIL PROTECTED]] 
Sent: Monday, May 13, 2002 3:56 PM
To: 'Tomcat Users List'
Subject: RE: Applet-servlet communication problem with Tomcat 4.0.3

This looks like something to do with your CATALINA_HOME directory. I had
problems installing to Program Files/Apache Tomcat, because of the space
in
Program Files. You could try moving/re-installing your tomcat to
somewhere
else without spaces in the pathname - like c:\dev\tomcat4.0.3 or
something.


-Original Message-----
From: KAKARONTZAS GEORGE [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 13, 2002 7:27 AM
To: [EMAIL PROTECTED]
Subject: Applet-servlet communication problem with Tomcat 4.0.3


I'm having an Applet oppening a URLConnection with a servlet and sending
an object.
Here's the Applet side of the communication:
 
//This is the method initiating the connection
public void available(SellOrder o) throws Exception
{
URL servlet = new URL("http", "localhost", 8080,
"/servlet/AvailableServlet");
Serializable objs[] = { o };
ObjectInputStream in = ServletWriter.postObjects(servlet,
objs);
String status = (String) in.readObject();
in.close();
}

public class ServletWriter {
 
static public ObjectInputStream postObjects(URL servlet,
Serializable objs[]) throws Exception
{
URLConnection con = servlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setDefaultUseCaches(false);
con.setUseCaches(false);
con.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
 
// Write the arguments as post data
ObjectOutputStream out = new
ObjectOutputStream(con.getOutputStream());
int numObjects = objs.length;
for (int x = 0; x < numObjects; x++) {
out.writeObject(objs[x]);
}
 
out.flush();
out.close();
 
return new ObjectInputStream(
con.getInputStream() );
}
 
}
 
On the server side of the communication I have the AvailableServlet with
the following code:
 
public class AvailableServlet extends HostServlet {
 
public void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
System.out.println("Available is called.");
ObjectInputStream in=
new
ObjectInputStream(req.getInputStream());
ObjectOutputStream out=
new
ObjectOutputStream(res.getOutputStream());
try {
 //read the host order
 SellOrder o = (SellOrder)
in.readObject();
 _server.available(o);
out.writeObject("OK");
in.close();
out.close();
}

catch (Exception ex) {
System.out.println(ex.getMessage());
}

}   
}
 
This communication works fine when running with Tomcat 3.2.1 (Windows XP
Pro - standalone). But it throws the following exception on the server
when running on Tomcat 4.0.3 (same platform standalone or service):

Available is called.
RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments;
nested excep
tion is:
java.net.MalformedURLException: no protocol: Files/Apache

As you can see from the output the doPost() method is called.  The
exception is thrown when the doPost() method executes the readObject()
method on the stream.
 
Any help would be greately appreciated.
Thanks
-George
 



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Applet-servlet communication problem with Tomcat 4.0.3

2002-05-13 Thread KAKARONTZAS GEORGE

I'm having an Applet oppening a URLConnection with a servlet and sending
an object.
Here's the Applet side of the communication:
 
//This is the method initiating the connection
public void available(SellOrder o) throws Exception
{
URL servlet = new URL("http", "localhost", 8080,
"/servlet/AvailableServlet");
Serializable objs[] = { o };
ObjectInputStream in = ServletWriter.postObjects(servlet,
objs);
String status = (String) in.readObject();
in.close();
}

public class ServletWriter {
 
static public ObjectInputStream postObjects(URL servlet,
Serializable objs[]) throws Exception
{
URLConnection con = servlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setDefaultUseCaches(false);
con.setUseCaches(false);
con.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
 
// Write the arguments as post data
ObjectOutputStream out = new
ObjectOutputStream(con.getOutputStream());
int numObjects = objs.length;
for (int x = 0; x < numObjects; x++) {
out.writeObject(objs[x]);
}
 
out.flush();
out.close();
 
return new ObjectInputStream(
con.getInputStream() );
}
 
}
 
On the server side of the communication I have the AvailableServlet with
the following code:
 
public class AvailableServlet extends HostServlet {
 
public void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
System.out.println("Available is called.");
ObjectInputStream in=
new
ObjectInputStream(req.getInputStream());
ObjectOutputStream out=
new
ObjectOutputStream(res.getOutputStream());
try {
 //read the host order
 SellOrder o = (SellOrder)
in.readObject();
 _server.available(o);
out.writeObject("OK");
in.close();
out.close();
}

catch (Exception ex) {
System.out.println(ex.getMessage());
}

}   
}
 
This communication works fine when running with Tomcat 3.2.1 (Windows XP
Pro - standalone). But it throws the following exception on the server
when running on Tomcat 4.0.3 (same platform standalone or service):

Available is called.
RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments;
nested excep
tion is:
java.net.MalformedURLException: no protocol: Files/Apache

As you can see from the output the doPost() method is called.  The
exception is thrown when the doPost() method executes the readObject()
method on the stream.
 
Any help would be greately appreciated.
Thanks
-George