JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   On Github   Forums 
June 03, 2023, 04:55:09 PM *
Welcome,
Please login or register.

Login with username, password and session length
Advanced search  
News: New users, please read this message. Thank you!
  Home Help Search Login Register  
Pages: [1]   Go Down

Author Topic: java.io.NotSerializableException  (Read 7444 times)

Abhilash K

  • JPPF Grand Master
  • ****
  • Posts: 64
java.io.NotSerializableException
« on: December 13, 2006, 05:57:57 AM »

Hii,

      I tried to connect to a URL from my client and tried to extract information from it.  Thing is that I can display the contents in node termila but its working continuously and the task is not finishing up.  The log file erros are as follows.
-------------------------------------------------------------------------
2006-12-13 10:00:34,921 [INFO ][org.jppf.node.NodeLauncher.main(63)]: starting node
2006-12-13 10:00:59,406 [ERROR][org.jppf.server.node.JPPFNode.run(152)]: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream
java.io.NotSerializableException: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream
   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
   at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
   at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
   at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
   at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
   at org.jppf.utils.ObjectSerializerImpl.serialize(ObjectSerializerImpl.java:55)
   at org.jppf.utils.SerializationHelperImpl.writeNextObject(SerializationHelperImpl.java:174)
   at org.jppf.server.node.JPPFNode.writeResults(JPPFNode.java:373)
   at org.jppf.server.node.JPPFNode.perform(JPPFNode.java:198)
   at org.jppf.server.node.JPPFNode.run(JPPFNode.java:143)
   at org.jppf.node.NodeLauncher.main(NodeLauncher.java:71)

----------------------------------------------------------
pls get me a solution for the same.

           my taks code is as follows.
----------------------------------------------------------
package sample.hello;

import org.jppf.server.protocol.JPPFTask;
import java.net.*;
import java.io.*;

public class FileDownloadTestTask extends JPPFTask
{   
   URL url;
   InputStream is;
   String str=null;
   
   public FileDownloadTestTask(URL url) throws MalformedURLException{
      this.url=url;
      System.out.println("Constructing Task... ");
      System.out.println("First : "+url.getPort());
   }
   public void run(){
      try{
            int c,k=0;
           is=url.openStream();
         char[] ch=new char[is.available()];
         if(is.available()>0){
            int i=is.available();
            while(((c=is.read())!= -1)&&(--i > 0)){
               ch[k++]=(char)c;
            }
         }
         // BufferedReader br=new BufferedReader(new InputStreamReader(is));
           // str=br.readLine();
         str=new String(ch);
           System.out.println(str);
         
            }
            catch(Exception e){
              e.printStackTrace();
            }
      }
   
   public Object getResult(){
       return str;
    }
}
----------------------------------------------------------------
 pls get me a solution.

regds - abhilash
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2272
    • JPPF Web site
java.io.NotSerializableException
« Reply #1 on: December 13, 2006, 03:34:17 PM »

Hell Abhilash,

The problem comes from the input stream that you declared as an instance variable in your task:
Code: [Select]
InputStream is;
In the JDK, streams are not serializable. So you need to make it transient:
Code: [Select]
transient inputStream is;
This way, JPPF won't try to serialize/deserialize it when you submit the task or when its results are sent back.

-Laurent
Logged

Abhilash K

  • JPPF Grand Master
  • ****
  • Posts: 64
Thanx
« Reply #2 on: December 19, 2006, 11:00:56 AM »

Hii Laurent,

         Thanks for the information.  now its working fine.  thanks a lot.

regds,
         abhilash
Logged
Pages: [1]   Go Up
 
JPPF Powered by SMF 2.0 RC5 | SMF © 2006–2011, Simple Machines LLC Get JPPF at SourceForge.net. Fast, secure and Free Open Source software downloads