Servlets and Object Serialization
Say, you have a Servlet which sends Objects across an ObjectOutputStream which is obtained from its corresponding HttpServletResponse.
res.getOutputStream().writeObject(myObject);
From what I observe it is impossible to obtain an ObjectInputStream from the URLConnection of the calling servlet until it is finished processing.
Does anyone know if there is a way to do this?
URLConnection conn = _myUrl.openConnection();
conn.setDoOutput(false);
conn.setUseCaches(false);
conn.setRequestProperty("Content-Type", "application/octet-stream");
ObjectInputStream in = new ObjectInputStream(conn.getInputStream());
System.out.println("This won't get called until the calling Servlet has finished processing, is it possible to retrieve before???");
String s = in.readObject().toString();
hi , I made a similar query some time ago and came up with the following solution.
serverUrl_ = new URL(url_);
HttpURLConnection con_ = (HttpURLConnection)serverUrl_.openConnection();
con_.setRequestMethod("POST");
con_.setDoOutput(true);
con_.setDoInput(true);
con_.setUseCaches(false);
ObjectOutputStream out_ = new ObjectOutputStream(con_.getOutputStream());
out_.writeObject(new String("a test example to string"));
The servlet would read this in as follows:
protected void doPost(HttpServletRequest request_, HttpServletResponse response_){
try{
//get required io streams
ObjectInputStream ois_ = new ObjectInputStream(request_.getInputStream());
ObjectOutputStream object_ = new ObjectOutputStream(response_.getOutputStream());
String test_ = (String)ois_.readObject();
if(test_ instanceof String){
System.out.println("String value is: "+test_);
} else {
System.out.println("error reading string")
} catch(Exception ioe){
ioe.printStackTrace();
this should give you the basic idea how to pass objects through http.
Hope it helps
rob
Similar Messages
-
Servlet and Object Serialization
Hi,
I am developing a routing server in Java
2 Instances of the same server will be running in 2 different data centers.
The servers have a Jetty server embedded with a Servlet inside.
Server 1 will use a GET method to talk to the Server 2 -> Servlet which will write the state of an object back which will read by Server 1 and reconstruct the object back.
Do you find any issues in Object Serialization/DeSerialization in the Servlet.
What are the factors that I need to consider in this case?
Regards,
JanaMake sure that your servlet handles the transaction in the same thread that doPost() or doGet() is called in.
I ended up porting some old ServerSocket based code to a servlet, and was handing off the request and response objects to a handler thread on the server side. I ended up with a ton of intermittent errors like this.
Once I started handling the transactions in the same thread things worked heartbreakingly well. -
EOFException and Object Serialization
Hello, I am trying to build a distributed file storing system by using Multicast Sockets and I experience a problem the past 2 days.
I have to use multicast sockets because it is not my decision.
The problem appears when i have to transfer a file between 2 machines via UDP Datagrams.
I know that the size of the byte array that is contained in a datagram is quite small so I built a function that breaks the file in to small byte arrays that have the size of 9500 bytes each.
I insert these byte arrays in a new object that I call message and has additional information and I serialize the message object
I send this byte array through the UDP socket and when I try do deserialize it on the other side I receive an EOFException that comes from the ObjectStream and particularly the method read() of the ObjectInputStream returns -1 which means it found the EOF in message that is been transported.
I checked the bytes that are contained in the byte array with the partition of the file that is being transferred and I noticed that inside the file there are a number of negative numbers., which, as far as I know, shouldn't be happening.
do you have any ideas for the reason these are happening?
Thank you.
VagelisYou can get negative bytes in an object stream.
Try ensuring you have sent the length of the data and the data has been received in the correct order. Note Datagrams don't guarentee the order that packets were sent is the order they will be received.
I would put a check sum at the end of your data to ensure the data is sound before attempting to decode it.
If your packets are large, one option may be to compress the data with DeflatorOutputStream and InflatorInputStream. This can compress large object streams very well. -
Applet-servlet communication, object serialization, problem
hi,
I encountered a problem with tomcat 5.5. Grazing the whole web i didn't find any solution (some guys are having the same problem but they also got no useful hint up to now). The problem is as follows:
I try to build an applet-servlet communication using serialized objects. In my test scenario i write a serialized standard java object (e.g. a String object) onto the ObjectOutputStream of the applet/test-application (it doesn't matters wheter to use the first or the latter one for test cases) and the doPost method of the servlet reads the object from the ObjectInputStream. That works fine. But if i use customized objects (which should also work fine) the same code produces an classnotfound exception. When i try to read and cast the object:
TestMessage e = (TestMessage)objin.readObject();
java.lang.ClassNotFoundException: TestMessage
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
...That seems strange to me, because if i instantiate an object of the same customized class (TestMessage) in the servlet code, the webappclassloader doesn't have any problems loading and handling the class and the code works fine!
The class is located in the web-inf/classes directory of the application. I've already tried to put the class (with and without the package structure) into the common/classes and server/classes directory, but the exception stays the same (I've also tried to build a jar and put it in the appropriate lib directories).
I've also tried to catch a Throwable object in order to get information on the cause. But i get a "null" value (the docu says, that this will may be caused by an unknown error).
I've also inspected the log files intensively. But they gave me no hint. Until now I've spend a lot of time on searching and messing around but i always get this classnotfound exception.
I hope this is the right place to post this problem and i hope that there is anyone out there who can give me some hint on solving this problem.
Kindly regards,
Danielhi, thanks for the reply,
all my classes are in the web-inf/classes of the web-app and have an appropriate package structure. thus the TestMessage class is inside a package.
i tried some names for the testclass but it didn't matter. the exception stays the same. I also tried to put the jar in the common/lib but the problem stays.
Well the problem with loaded classes: As i mentioned in the post above i can instantiate an object of TestMessage in the code without any problems (so the classloader of my webapp should know the class!!)
only when reading from the objectinputstream the classloader doesn't seem to know the class?? maybe theres a parent classloader resposible for that and doesn't know the class?
strange behaviour...
p.s. sending the same object from the servlet to the client works well
regards
daniel
Message was edited by:
theazazel -
My Code is mentioned below
public class PMLCommandDTO implements Serializable {
ConfigureTagFilter cfgTagFltrObj;
WriteTagData writeTagDataObj;
ExtensionCommand extnCmdObj;
// all getter setter method.
}Now I set ConfigureTagFilter object (which is not serialized) to the
PMLCommandDTO class.
PMLCommandDTO serializedObj;
serializedObj = new PMLCommandDTO();
serializedObj.setCfgTagFltrObj(cfgTagFltrObj);Now Can I my "serializedObj" is serialized and can I use it to
javax.jms.ObjectMessage ---- > setObject(Serializable) method.Cross post, already being responded in
http://forum.java.sun.com/thread.jspa?threadID=5214314&tstart=0
db -
I try to use the new IO API to implement a non-blocking multi-threaded server that communicates with client applications by exchanging serialized objects. I started from the code in the JavaWorld article at http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html .
With the new features of J2SDK 1.4.0, you don't have to create a separate thread per connected client. That is a big improvement.
But when I read an object with ObjectInputStream, I get a java.nio.channels.IllegalBlockingModeException.
Has anybody successfully implemented such a server since the release of the new io API?
Thanks.
Jean-RobertHi,
I tried to decode it and reconstruct the object as follows:
buffer.flip();
// Decode buffer
decoder.decode(buffer, charBuffer, false);
// Display
charBuffer.flip();
String str = charBuffer.toString();
try
ByteArrayInputStream bis = new ByteArrayInputStream(str.getBytes());
ObjectInputStream ois = new ObjectInputStream(bis);
Object obj = ois.readObject();
if (obj != null)
System.out.println(obj.getClass().getName());
System.out.println("Construction successful");
catch (Exception e)
e.printStackTrace();
I think it is constructing the object. But it gave me the following exception:
java.io.InvalidClassException: MessageValueObject; local class incompatible: stream classdesc serialVersionUID = -1062950779601993928, local class serialVersionUID = -1038743931604855240
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:454)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1511)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1425)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1616)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
at com.csxwt.zodiac.client.common.NIOPushletClient.run(NIOPushletClient.java:254)
at java.lang.Thread.run(Thread.java:536)
Whe I compared the bytes of returned object with the actual object I noticed that two bytes were different from the orignal. They were replaced with '?' (byte code 063) in the reconstructed byte stream.
If anybody have a clue please help me too -
Sharing an object/class bewteen servlets and applications
Hi there,
I wish to know how to share a class/object between all
types of other classes, be they applications or servlets, but I encounter the following problem.
Basically, if I instantiate the common class using, say a servlet, then when I try to gain a handle on the instance of that class from an application, the application creates a new(or it's own) instance. Similarly, if I instantiate first within an application.
How do I prevent this from happening?
The actual class files for both the application and servlets are all the same.
Appreciate the help,
Fintan.I am actually implementing the singleton pattern in
this common class.ok, that clarifies the issue a bit...
The RMI route seems to me to be a bit too much work > as a solution to a very simple concept.actually, it's really not a simple concept. What you really want isn't just an application singleton, where there is one instance in the application/servlet JVM. What you really want is more along the lines of a universal singleton, where there is only one instance for ALL applications/servlets...
Interestingly, if I run two java apps side by side in
two DOS windows that each call a getInstance
method in common singleton, both apps create their
own instance.
How come? Separate instances of VM?Yes, this is exactly correct. The same is true of C++ Singletons; if you start a second application it will create another instance of the Singleton because one does not yet exist in the application.
How do I get aroun this one?Like I said, think of it as a universal singleton. Consider Verisign a universal singleton--everyone comes to them for certificates. How does this run? Well, truthfully, Verisign operates as a service, right? So you need some way of setting up a service that really holds onto the object and brokers (aha, 5 dollar word!) who has access to it, who can modify it, and who can read from it. This leads you to a few options... RMI, CORBA, or writing your own object server.
Networking is really easy in Java, so here's another option... You can set up a server that listens for messages on a specific socket/port with whatever protocol you specify to get/set values. Have the server run on only one specific machine. Then you can have all the servlets and applications come to the machine to get the information.
Gee, this sounds like a back-end database. =)
If all this is too complex, maybe you need to rethink the design... do you really need to have the exact same object shared between all application/servlet instances? Or is it acceptable to just make sure they all contain the same data?
If what you really want is a real-time data update scheme, then you probably want something like a subscribe-publish architecture where the one server publishes the origainal data. Then when a client updates the server, the server posts an update message to all the clients, who then in turn update their internal data.
Anyway, I'm just throwing out some ideas. I'm sure you can come up with some better ones of your own since you know what your requirements are. =)
Once again appreciate the help!I hope it actually was. =)
--David -
Passing objects between Servlets and JSP
Hi,
I have passed a ResultSet from a Servlet to JSP using RequestDispatcher forward(). I can access the ResultSet in the JSP page. How can I now pass this ResultSet into another JSP page once the form has been submitted?
Thanks in advance.You should never passing expensive resources like ResultSet around like that. This indicate an open DB connection somewhere while it should already be closed at this stage.
Read on about the DAO pattern and make use of servlets and beans. -
Servlets and Workspaces (AND ClassCastExceptions)
I have a similiar situation but am not getting a ClassCastException but rather a
NullPointerException when I try
to use a contained object in my stored object.
I do this in the server:
WorkspaceServicesDef workspaceServices = services.workspace();
WorkspaceDef defaultWS = workspaceServices.getWorkspace();
WorkspaceDef dataWS = defaultWS.getWorkspace("DATA_WORKSPACE",
WorkspaceDef.CREATE,
WorkspaceDef.SCOPE_SERVER);
dataWS.store(cMSKey, ms);
and this in the JSP page:
// Get the default T3Client Workspace
WorkspaceDef defaultWS = t3.services.workspace().getWorkspace();
// Attach to the system subWorkspace already created
WorkspaceDef myDataWS = defaultWS.getWorkspace("DATA_WORKSPACE",
WorkspaceDef.ATTACH,
WorkspaceDef.SCOPE_SERVER);
MimicServer ms = (MimicServer) myDataWS.fetch("MimicServer");
Questions:
1)Must I make the Object I want to store in the WorkSpace Serializable?? The
Documentation says it can just be
a Java Object??
2) In my JSP page I get a good Object reference, but its contents are null
(Probably because I didn't implement write() and read()).
Thanks,
matt obrien
[email protected]
Mark Griffith wrote:
> Alexandre:
>
> Although byte for byte the FooObject is the same, according to the VM they
> are different class. This is because a class's type distinctiveness is
> based not only its interfaces,methods,data members etc but ALSO on its
> classloader. There is a different classloader for the
> serversclasses_FooObject and the servletclasses_FooObject so they are
> considered different, so you get a CCE.
>
> Problem is that the servletclasses directory is designed to solve the
> problem of reloading servlet classes and objects they used when modified
> without having to restart the server. But this introduces the problem
> discussed above. The only solution currently is to put the FooObject only in
> one place or another. Unfortunately if you want a class in servletclasses
> to interact classes loaded by the system/server classloader you cannot put
> the class in the servletclasses without getting a CCE on reload of the
> servlet in servletclasses. In this case you must put the class only in the
> serverclasses directory. And this means of course you can only reload the
> FooObject in the serverclasses directory if you bounce the server. (the
> default java classloading behavior).
>
> This will be handled more elegantly in our next major release Spring 2000,
> however note (and prepare by designing accordingly) the solution is to allow
> the Servlet to interact with interfaces not actual classes and these
> interfaces can be stuffed into system/server loaded classes such as
> workspaces and httpsessions, thus preventing CCE's.
>
> Cheers
> Mark G
>
> Alexandre Aubry wrote:
>
> > I have a named workspace which is created at startup of the server
> > within a starup class.
> > When the startup method is called, I instantiate and put an object
> > called FooObject in the workspace.
> >
> > Then, in a servlet, called Dispatcher, in the service method, I
> > retrieved my named workspace and the object
> > FooObject which is in this workspace. At this time, I have a
> > ClassCastException.
> >
> > To give you more details about my configuration, here is my directory
> > configuration:
> > weblogic
> > |----------- serverclasses
> > |------------- startupObject
> > |------------- FooObject
> > |----------- servletclasses
> > |------------- myServlet
> > |------------- FooObject (which is exactly
> > the same of the serverclasses one)
> >
> > Do you have any ideas ? The idea is to instantiate a given object at the
> > startup of the web server and to retrieve
> > these objects within servlets and JSPs.
> >
> > Regards.
> >
> > --
> > Alexandre Aubry
> > Consultant
> > Fi System, The Web Agency
> > http://www.fisystem.fr
> > mailto:[email protected]
> > Phone: +33 1 55 04 03 03 Fax: +33 1 55 04 03 04
>
> --
> =====================================================
> Reply to the newsgroup. Don't reply to this mail
> alias. This is used only for answering posts on
> WebLogic Newsgroups.
> =====================================================
-
Using a class or servlet that implements Serializable
Hello everyone,
Can someone please help me. I need to make a program that uses a class or servlet that implements Serializable and then use the values of the variables in servlets.
The first is using it to validate login. then changing the color of the background, header and footer of each servlet.
the variables in the Serialized file are all Strings for color, username, password, header text and footer text.
I tried using the applet tag to run the class in the servlet but it is not working.It's not working because you seem to be making random guesses what servlets, serialization and files are
-
Reading a properties file in a servlet and passing its contents to a JSP pa
Hi all,
I'm totally new to Servlet pgmg n JSP. Please can ne1 tell how to read a simple properties file (in a servlet) and pass its contents to a JSP page.Actually the reason is to fill a combo box in a JSP page with the contents of a properties file.If calling a servlet for the same is d best way to do that, plz can ne1 tell me :
1> whether to override the doPost method in the servlet in which to read d file using FileInputStream
2> Putting the contents in an array and then how to pass this array to the JSP page.
Thanks,
deepthy.I'm using a properties file to let my web application know what the name of the database is. I'm using an abstract class GeneralDao which will be extended by all the DAO's (Data Access Objects or java classes containing SQL statements).
Here's the code :
protected Connection getDatabaseConnection()
throws Melding
Connection dbconn = null;
ResourceBundle resBundle;
try
Class.forName("com.mysql.jdbc.Driver").newInstance();
resBundle = ResourceBundle.getBundle("gcoConfig");
String dbConnectie = resBundle.getString("databaseconnection");
gcoLogger.debug("lezen databaseconnection in resourceBundle " );
dbconn = DriverManager.getConnection(dbConnectie);
} catch (InstantiationException exc)The ResourceBundle is used to read the properties file, named gcoConfig.properties.
With the getString() command I read the content of the string named databaseconnection.
The gcoConfig.properties file is placed inside the folder C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\gco\WEB-INF\classes
The GeneralDao is placed in the folder C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\gco\WEB-INF\classes\org\gertcuppens\cluifDao.
So this class is placed some folder below the WEB-INF\classes folder of gcoConfig.properties.
And the content of the properties file is just one line :
databaseconnection=jdbc:mysql://localhost/cluif
If you want to let the JSP know what's inside the properties file, wrap the content in a Javabean, put it in the request or even the session and pass the control to the JSP. -
How to include a jsp file in servlets and javabeans
Hi to all..I have a jsp file which contains some database connections and I would like to include in that file in my servlets and javabeans.What coding can i use?Can show me sample coding.
Hi to all..I have created a javabean storing the
database connections. How do i include and call that
bean in my servlet and javabeans?Can pls show me some
sample coding?I am new to servlets and beans.The same way you do with normal Java Classes. If you are new to Java, I suggest you go to http://java.sun.com/docs/books/tutorial/index.html and look through the first couple of tutorials.
As a note, it is best to put all your objects into packages, especially if you use JDK 1.4 or higher. -
Servlet Applet object communication problem???!!!
Hy folks,
I need to validate the ability of complex Servlet Applet communication an run into my first pb right at the beginning of my tests. I need to have around 200 Applet clients connect to my servlet and communicate by ObjectInput and ObjectOutput streams. So I wrote a simple Servlet accepting HTTP POST connections that return a Java object. When the java Applet get instantiated, the Object Stream communication workes fine. But when the Applet tries to communicate with the servlet after that, I can not create another communication session with that Servlet, instead I get a 405 Method not allowed exception.
Summarized:
- Applet init() instantiate URLConnection with Servlet and request Java object (opening ObjectInput and Output Stream, after receaving object, cloasing streams).
- When I press a "get More" button on my Applet, I am not able to instantiate a new URLConnection with my servler because of that 405 exception, WHY???
Here my Servlet code:
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
ObjectInputStream inputFromApplet = null;
ArrayList transmitContent = null;
PrintWriter out = null;
BufferedReader inTest = null;
try{
inputFromApplet = new ObjectInputStream(request.getInputStream());
transmitContent = (ArrayList) inputFromApplet.readObject();
inputFromApplet.close();
ArrayList toReturn = new ArrayList();
toReturn.add("One");
toReturn.add("Two");
toReturn.add("Three");
sendAnsweredList(response, toReturn);
catch(Exception e){}
public void sendAnsweredList(HttpServletResponse response, ArrayList returnObject){
ObjectOutputStream outputToApplet;
try{
outputToApplet = new ObjectOutputStream(response.getOutputStream());
outputToApplet.writeObject(returnObject);
outputToApplet.flush();
outputToApplet.close();
catch (IOException e){
e.printStackTrace();
}Here my Applet code:
public void init() {
moreStuff.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
requestMore();
try{
studentDBservlet = new URL("http://localhost/DBHandlerServlet");
servletConnection = studentDBservlet.openConnection();
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches(false);
servletConnection.setDoOutput(true);
servletConnection.setDoInput(true);
ObjectOutputStream outputToApplet;
outputToApplet = new ObjectOutputStream(servletConnection.getOutputStream());
outputToApplet.writeObject(new ArrayList());
outputToApplet.flush();
outputToApplet.close();
ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
ArrayList studentVector = (ArrayList) inputFromServlet.readObject();
area.setText("Success!\n");
for (int i = 0; i<studentVector.size(); i++) {
area.append(studentVector.get(i).toString()+"\n");
inputFromServlet.close();
outputToApplet.close();
catch(Exception e){
area = new JTextArea();
area.setText("An error occured!!!\n");
area.append(e.getMessage());
getContentPane().add(new JScrollPane(area), BorderLayout.CENTER);
getContentPane().add(moreStuff, BorderLayout.SOUTH);
private void requestMore(){
try{
studentDBservlet = new URL("http://localhost/DBHandlerServlet");
servletConnection = studentDBservlet.openConnection();
ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
ArrayList studentVector = (ArrayList) inputFromServlet.readObject();
area.setText("Success2!\n");
for (int i = 0; i<studentVector.size(); i++) {
area.append(studentVector.get(i).toString()+"\n");
catch(Exception e){
area.setText("An error occured2!!!\n");
area.append(e.getMessage());
}Can someone help me solv this issue please, this is my first Applet Servlet work so far so I have no idea on how to solve this issue.Sorry folks, just found my error. Forgot about the ObjectInputStream waiting on the Servlet side, so of course had a dead look...
Sorry! -
I'm developing web application with OAS
4.0.8.1 and JDeveloper 3.0 and I want to call
JSP from servlet using "RequestDispatcher".
I downloaded JSP for OAS from www.olab.com.
In the Release note, there is a description
about RequestDispatcher, but I cannot
understand about details.
In what configuration can I use servlet and
JSP together with RequestDispatcher. Anyone
scceeded about that?
nullwan (guest) wrote:
: Hi everyone,
: I am using OAS 4.0.8 on Solaris 2.6. After viewing servlet
: and JSP samples, I am kind of confuse whether OAS supports the
: following options
: 1. JSP
: 2. servlet chaining
: 3. running JDeveloper DB Servlet wizard
: (oracle.jdeveloper.servlet.*) and Java Business Objects
: (oracle.jbo.rt.cs)
: Thank you for your time.
I found a white paper 408newfead.pdf, that says under "Future
Directions" that it will add jsp support. I read somewhere (I
can't remember where exactly :( ) that said 4.0.8.1 would
support
JSPs. I don't know if this release is out yet.
I wish Oracle would get with the times and put out a product that
is consistent with the technology they are touting as the
future.
Having us download Suns server to run servlets and JSP is
ridiculous for the worlds second largest software company!
null -
I have a named workspace which is created at startup of the server
within a starup class.
When the startup method is called, I instantiate and put an object
called FooObject in the workspace.
Then, in a servlet, called Dispatcher, in the service method, I
retrieved my named workspace and the object
FooObject which is in this workspace. At this time, I have a
ClassCastException.
To give you more details about my configuration, here is my directory
configuration:
weblogic
|----------- serverclasses
|------------- startupObject
|------------- FooObject
|----------- servletclasses
|------------- myServlet
|------------- FooObject (which is exactly
the same of the serverclasses one)
Do you have any ideas ? The idea is to instantiate a given object at the
startup of the web server and to retrieve
these objects within servlets and JSPs.
Regards.
Alexandre Aubry
Consultant
Fi System, The Web Agency
http://www.fisystem.fr
mailto:[email protected]
Phone: +33 1 55 04 03 03 Fax: +33 1 55 04 03 04
Do you have Service Pack 6. SP6 is supposed to fix this problem
"Jon Armstrong" <[email protected]> wrote in message
news:[email protected]...
> Mark/All,
>
> As a recent member of the list, this is the only reference/post that
seemed that
> it might be related to the problem I'm seeing.
>
> I have a servlet that runs fine if I register it through the standard WLS
httpd
> servlet mechanism:
>
> weblogic.httpd.register.XE=appl.X.EServlet
> weblogic.httpd.servlet.classpath=\
> /weblogic/myserver/public_html/XE/myclasses.jar;\
> ... etc.
>
> If I attempt to deploy the servlet as a WebApp:
>
> weblogic.httpd.webApp.XE=/C:/XE
>
> Where: C:/XE contains
>
> WEB-INF/web.xml
> WEB-INF/lib/myclasses.jar (contains: appl.X.EServlet)
> WEB-INF/lib/...
> ...etc.
>
> I get the following ClassCast Exception when invoking the servlet:
>
> Fri Nov 10 15:14:08 EST 2000:<E> <ServletContext-XE> Error casting
servlet:
> appl.X.EServlet java.lang.ClassCastException: appl.X.EServlet
> at
>
weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java
:382)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.ja
va:349)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
a:338)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:16
4)
> at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:99)
>
> at
>
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java:742)
>
> at
>
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java:686)
>
> at
>
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
Manager.java:247)
>
> at
weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
> at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
> Fri Nov 10 15:14:08 EST 2000:<E> <ServletContext-XE> Servlet failed with
> Exception
> javax.servlet.ServletException: Servlet class: appl.X.EServlet does not
> implement javax.servlet.Servlet
> at
>
weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java
:385)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.ja
va:349)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
a:338)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:16
4)
> at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:99)
>
> at
>
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java:742)
>
> at
>
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java:686)
>
> at
>
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
Manager.java:247)
>
> at
weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
> at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
> This class doesn't <implement> Servlet. It <extends> a class which
eventually
> <extends> HttpServlet... which should suffice, much like the typical
HelloWorld
> sample servlets.
>
> I have to remove the WEB-INF directory and register this as a standard
httpd
> servlet to get weblogic to run it properly.
> This servlet deploys fine with Jakarta-Tomcat as a WebApp and the same
web.xml
> file. I can post that, if need be. I assume the classloader is somehow
> confused.
>
> Is this the same problem discussed below? If so, there's no reference to
the
> version of WLS that will address this issue.
>
> I'm currently using WLS 5.1. <Fri Nov 10 13:48:48 EST 2000:<I>
<WebLogicServer>
> ************ WebLogic Server (5.1.0 04/03/2000 17:13:23 #66825)>
>
> Has this been fixed or is there a workaround that allows WebApp deployment
to
> succeed? I really would like to stay away from as much web/app server
specific
> configuration as possible before taking this into the field.
>
> Jon
>
> Mark Griffith wrote:
>
> > Alexandre:
> >
> > Although byte for byte the FooObject is the same, according to the VM
they
> > are different class. This is because a class's type distinctiveness is
> > based not only its interfaces,methods,data members etc but ALSO on its
> > classloader. There is a different classloader for the
> > serversclasses_FooObject and the servletclasses_FooObject so they are
> > considered different, so you get a CCE.
> >
>
> etc...
>
> >
> > This will be handled more elegantly in our next major release Spring
2000,
> > however note (and prepare by designing accordingly) the solution is to
allow
> > the Servlet to interact with interfaces not actual classes and these
> > interfaces can be stuffed into system/server loaded classes such as
> > workspaces and httpsessions, thus preventing CCE's.
> >
> > Cheers
> > Mark G
> >
> > Alexandre Aubry wrote:
> >
> > > I have a named workspace which is created at startup of the server
> > > within a starup class.
> > > When the startup method is called, I instantiate and put an object
> > > called FooObject in the workspace.
> > >
> > > Then, in a servlet, called Dispatcher, in the service method, I
> > > retrieved my named workspace and the object
> > > FooObject which is in this workspace. At this time, I have a
> > > ClassCastException.
> > >
> > > To give you more details about my configuration, here is my directory
> > > configuration:
> > > weblogic
> > > |----------- serverclasses
> > > |------------- startupObject
> > > |------------- FooObject
> > > |----------- servletclasses
> > > |------------- myServlet
> > > |------------- FooObject (which is
exactly
> > > the same of the serverclasses one)
> > >
> > > Do you have any ideas ? The idea is to instantiate a given object at
the
> > > startup of the web server and to retrieve
> > > these objects within servlets and JSPs.
> > >
> > > Regards.
> > >
> > > --
> > > Alexandre Aubry
> > > Consultant
> > > Fi System, The Web Agency
>
> ---
> Jon M. Armstrong
> Senior Systems Consultant
> Xelus, Inc.
>
> EMail: [email protected]
> Phone: 716-419-3155
> Fax: 716-248-9199
>
> Visit us online: http://www.xelus.com
>
>
Maybe you are looking for
-
Brand New iPod Touch - It's stuck and not being recognized by iTunes
I just got a new iPod Touch for a gift. I plugged it in and it needed to update software to 4.0. I allowed it to download and install and left the computer alone. Came back and it is currently stuck showing the screen with the USB and the iTunes symb
-
Cross-reference auto-page numers?
Can anyone tell me why i cannot get cross-references to work with automatic page numbering? Is there some fundamental error i am making? I have the master files setup with auto-page numbering based on 'current page.' All of my pages are numbere
-
Airport or airport extreme?
Hey all, I am finally joining the 21st century and want to install a wireless card on my G4 Powerbook. How do I know which type of AirPort it's compatible with? I checked the lists of compatible Macs in the support section but none of the types of co
-
Trouble with AirTunes - conflicting channel noise?
Hi there I have just bought an Airport Express with AirTunes. The device works great - but thus far I have only been able to successfully play music on the network it creates - I haven't been able to use WDS or get it to join a network and still stre
-
Are there any fixes/workarounds for the screen-scrambling bug in version 1.2 yet?