Serialize or not?

Hi I am new to jsp & java. I am slightly confused about how to go about using my database with my jsp app. Should I store all information in the database, initialize the objects everytime they are called & use them or store my objects as serialized objects in the database. Which would be a better approach.
Also how do I pass multiple parameters to a beans getProperty accessor function

It depends on the requirement for the data use, doesn't it?
The admin types around here just want data in their production DBs.

Similar Messages

  • Remote distributed scheme with custom serializer does not work

    HI,
    I have a remote scheme invoked through TcpExtend which is distributed-scheme. Now if I have a custom serializer attached the first node in the cluster comes up without a problem but not the second one onwards. It gives the following exception...
    2010-11-01 18:17:27.302/21.532 Oracle Coherence EE 3.6.0.1 <Error> (thread=Distr
    ibutedCache:extend-service, member=2): The service "extend-service" is configure
    d to use serializer <our package>.JavaSerialisation@562
    78964, which appears to be different from the serializer used by Member(Id=1, Ti
    mestamp=2010-11-01 18:14:35.066, Address=192.168.113.56:8088, MachineId=6456, Lo
    cation=site:oursite.corp,machine:mg-ldn-d0002,process:540, Role=Exe4jRuntimeWi
    nLauncher).
    java.io.IOException: invalid type: 119
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.g
    rid.PartitionedService$PartitionConfig.readObject(PartitionedService.CDB:25)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.g
    rid.PartitionedService$MemberWelcome.read(PartitionedService.CDB:20)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.G
    rid.deserializeMessage(Grid.CDB:42)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.G
    rid.onNotify(Grid.CDB:31)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.g
    rid.PartitionedService.onNotify(PartitionedService.CDB:3)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.g
    rid.partitionedService.PartitionedCache.onNotify(PartitionedCache.CDB:3)
    at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
    at java.lang.Thread.run(Thread.java:619)
    Stopping the extend-service service.
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.G
    rid.start(Grid.CDB:6)2010-11-01 18:17:27.302/21.532 Oracle Coherence EE 3.6.0.1
    <D5> (thread=DistributedCache:extend-service, member=2): Service extend-service
    left the cluster

    Config file contents follow...
    The server config - <cache-config>
    <caching-scheme-mapping>
    <cache-mapping>
    <cache-name>client-request-cache</cache-name>
    <scheme-name>extend-scheme</scheme-name>
    </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
    <proxy-scheme>
    <service-name>ExtendTcpProxyService</service-name>
    <acceptor-config>
    <tcp-acceptor>
    <local-address>
              <address>localhost</address>
              <port>9098</port>
    </local-address>
    </tcp-acceptor>
    <serializer>
    <class-name>test.JavaSerialisation</class-name>
    </serializer>
    </acceptor-config>
    </proxy-scheme>
    <distributed-scheme>
    <scheme-name>extend-scheme</scheme-name>
    <service-name>extend-service</service-name>
    <serializer>
    <class-name>test.JavaSerialisation</class-name>
    </serializer>
    <backing-map-scheme>
    <local-scheme/>
    </backing-map-scheme>
    <autostart>false</autostart>
    </distributed-scheme>
    </caching-schemes>
    </cache-config>
    Client - config is as follows
    <cache-config>
    <caching-scheme-mapping>
    <cache-mapping>
    <cache-name>client-request-cache</cache-name>
    <scheme-name>client-extend-scheme</scheme-name>
    </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
    <remote-cache-scheme>
    <scheme-name>client-extend-scheme</scheme-name>
    <service-name>ExtendTcpCacheService</service-name>
    <initiator-config>
    <tcp-initiator>
    <remote-addresses>
    <socket-address>
                   <address>localhost</address>
                   <port>9099</port>
              </socket-address>
    </remote-addresses>
                   <connect-timeout>5s</connect-timeout>
    </tcp-initiator>
    <outgoing-message-handler>
    <!-- If server has not responded by 100s, then will time out -->
    <request-timeout>100s</request-timeout>
    </outgoing-message-handler>
    <serializer>
    <instance>
    <class-name>test.JavaSerialisation</class-name>
    </instance>
    </serializer>
    </initiator-config>
    </remote-cache-scheme>
    </caching-schemes>
    </cache-config>
    Edited by: 807718 on 08-Nov-2010 10:14
    Edited by: 807718 on 08-Nov-2010 10:15

  • XSQL-022 error on using FOP - serializer class not found; urgent!

    Hi all,
    currently using XDK 9.2.0.1.0. On trying to invoke Apache FOP serializer I just get the following error message:
    XSQL-022: Cannot load serializer class oracle.xml.xsql.serializers.fopserializer
    and I really don't know why....
    Running XSQL Servlet within Tomcat 4 Engine, but error pops up using both, Tomcat way and/or just the commandline invoker xsql.bat.
    Generally XSQL Servlet is working correctly.
    My classpath setting contains:
    xmlparserv2.jar; batik.jar; classes12.jar; fop.jar; fopserializer.jar; oraclexsql.jar; sax2.jar; xalan-2.0.0.jar; xalanj1compat.jar; xerces-1.2.3.jar; xschema.jar; XSQLConfig.jar; xsu12.jar
    The serializer being redefined in XSQLConfig is just:
    <serializer>
    <name>FOP203</name>
    <class>oracle.xml.xsql.serializers.fopserializer</class>
    </serializer>
    This is because of using FOP 0.20.3, so having my own serializer class due to API change in FOP 0.20.x; my fopserializer is looking like that:
    package oracle.xml.xsql.serializers;
    import org.w3c.dom.Document;
    import java.io.PrintWriter;
    import oracle.xml.xsql.*;
    import org.apache.fop.messaging.MessageHandler;
    import org.apache.fop.apps.*;
    import java.io.*;
    // FOP 0.20.3 Serializer implementation for XSQL
    public class fopserializer implements XSQLDocumentSerializer
    private static final String PDFMIME="application/pdf";
    public void serialize(Document doc, XSQLPageRequest req) throws Throwable
    try
    Driver FOPDriver = new Driver();
    FOPDriver.setRenderer(FOPDriver.RENDER_PDF);
    MessageHandler.setOutputMethod(MessageHandler.NONE);
    FOPDriver.setupDefaultMappings();
    req.setContentType(PDFMIME);
    FOPDriver.setOutputStream(req.getOutputStream());
    FOPDriver.render(doc);
    catch (Exception e)
    e.printStackTrace(System.err);
    In my XSQL file I'm using the following PI:
    <?xml-stylesheet type="text/xsl" href="listemps.fo" serializer="FOP203"?>
    Any suggestions what is wrong in here ?
    Can't use the original xsqlserializer.jar either - same error.
    Thanks in advance
    Jochen

    Hi Jochen,
    I'm working with Tomcat 4.0.3, FOP 20.0.3 and XDK 9.2.0.1.0, too.
    I've copied all the jar-files into tomcat/common/lib. I think that you can't use the MessageHandler in fop20.0.3. I'm using the following serializer:
    package diva.xml.xsql.serializers;
    import org.w3c.dom.Document;
    import java.io.PrintWriter;
    import oracle.xml.xsql.*;
    import org.apache.fop.apps.*;
    import org.apache.log.*;
    import org.apache.log.format.*;
    import org.apache.log.output.io.*;
    import org.apache.avalon.*;
    import java.io.*;
    public class XSQLFOP203Serializer implements XSQLDocumentSerializer {
    private static final String PDFMIME = "application/pdf";
    private static final String CONFPATH = "/usr/local/fop/conf/userconfig.xml";
    public void serialize(Document doc, XSQLPageRequest env) throws Throwable {
    try {
    // Open user config file
    File userConfigFile = new File(CONFPATH);
    Options options = new Options(userConfigFile);
    // First make sure we can load the driver
    Driver FOPDriver = new Driver();
    // Setup logging
    Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
    PatternFormatter formatter = new PatternFormatter("[%{priority}]: %{message}\n%{throwable}" );
    LogTarget target = null;
    target = new StreamTarget(System.out, formatter);
    hierarchy.setDefaultLogTarget(target);
    Logger log = hierarchy.getLoggerFor("fop");
    log.setPriority(Priority.INFO);
    FOPDriver.setLogger(log);
    // Then set the content type before getting the reader/
    env.setContentType(PDFMIME);
    FOPDriver.setRenderer(FOPDriver.RENDER_PDF);
    FOPDriver.setOutputStream(env.getOutputStream());
    FOPDriver.render(doc);
    catch (Exception e) {
    // Cannot write PDF output for the error anyway.
    // So maybe this stack trace will be useful info
    e.printStackTrace(System.err);
    Hope this helps
    Uwe

  • Document in xml - Not serializable? Well, I need to cache it.

    Can anyone tell me how can I serialize DOM Document.
    When we try to put it in cache, cache complains that it
    is not serializable (I believe ElementImpl is not Serializable).
    In javadoc it shows serializable form for this Element, but when I look in the source it does not implements Serializable (and none of its parent interfaces).
    My question is this?
    Does anyone know how to serialize Document.
    (I do need to Serialize Document, not XML.In my case it
    is too expensive to parse XML every time I come back
    from cache)
    How do I use Serializable form of one class or interface?
    Thank You.
    Edmon

    Sorry about not being very helpful earlier. The number of people who submit JDC forum questions without reading even the elementary intro docs is rather staggering, IMHO. Here is something more detailed:
    (a) "Serialized form" of a class as found in javadoc has little to do with whether or not the class has been declared as Serializable by the implementor.
    (b) what matters to Java serialization is whether the object in question is runtime-Serializable. In your particular case, org.w3c.dom.Document is an interface and it was not declared as Serializable by W3C. Perhaps justifiably so, because that imposes unfair requirements on parser implementors [seeing that not everybody is expected to want to serialize a DOM tree the way you do].
    However, a particular parser implementation is free to make its Document implementation class as Serializable. If that is the case, writeObject(obj) will succeed even if "obj" variable is of Document [not Serializable] type but happens to point to a Serializable implementation class.
    But, if you rely on this behavior you are locking yourself into that particular parser implementation. Should you choose a different XML parser in the future you will see serialization errors at runtime. With things like JAXP and a variety of XML parsers available this perhaps is not the way to go.
    Things would have been different if Document was declared to implement Serializable. Then all XML parsers would have had a standard behavior for the DOM trees they produced, regardless of implementation details. This is not the case, though.
    Vlad.

  • Serialization not working in one way

    I tried to serialize a String object from and to an applet. The servlet to applet communication is working properly. But applet to servlet serialization is not working, but no exceptions are thrown. Please help me. Thank you very much.(I have given the complete source code bellow)
    =================================
    APPLET SOURCE CODE
    =================================
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class TestApplet extends Applet {
    Button send = new Button();
    Button receive = new Button();
    TextArea textarea = new TextArea();
    BorderLayout borderLayout1 = new BorderLayout();
    public void init() {
    send.setLabel("send");
    send.addActionListener(new Send_Listener());
    receive.setLabel("receive");
    receive.addActionListener(new Receive_Listener());
    this.setLayout(borderLayout1);
    this.add(send, BorderLayout.NORTH);
    this.add(textarea, BorderLayout.CENTER);
    this.add(receive, BorderLayout.SOUTH);
    void sendObject(){
    try{
    URL url = new URL(getCodeBase(), "/servlets/testservlet");
    URLConnection servletConnection = url.openConnection();
    servletConnection.setDoInput(true);
    servletConnection.setDoOutput(true);
    servletConnection.setUseCaches (false);
    servletConnection.setDefaultUseCaches (false);
    servletConnection.setRequestProperty ("Content-Type", "application/octet-stream");
    ObjectOutputStream outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());
    outputToServlet.writeObject("some string here");
    outputToServlet.flush();
    outputToServlet.close();
    textarea.append("aplet has send the object to the servlet\n");
    }catch(Exception e){
    textarea.append("EXCEPTION THROWN IN THE APPLET IN SENDOBJECT\n");
    void getObject(){
    try{
    URL url =new URL(getCodeBase(), "/servlets/testservlet");
    URLConnection servletConnection = url.openConnection();
    servletConnection.setUseCaches (false);
    servletConnection.setDefaultUseCaches(false);
    ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
    String aString=(String)inputFromServlet.readObject();
    textarea.append(aString+"\n");
    textarea.append("aplet has received the object from the servlet\n");
    }catch(Exception e){
    textarea.setText("EXCEPTION THROWN IN THE APPLET IN GETOBJECT\n");
    class Send_Listener implements ActionListener{
    public void actionPerformed(java.awt.event.ActionEvent e){
    sendObject();
    class Receive_Listener implements ActionListener{
    public void actionPerformed(java.awt.event.ActionEvent e){
    getObject();
    ===================================
    SERVLET SOURCE CODE
    ===================================
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class TestServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try
    ObjectOutputStream outputToApplet = new ObjectOutputStream(response.getOutputStream());
    String aString= (String) request.getSession().getAttribute("ID");
    outputToApplet.writeObject("this is the string object: "+aString);
    outputToApplet.flush();
    outputToApplet.close();
    System.out.println("object send to applet:"+aString+"\n");
    catch (IOException e)
    System.out.println("EXCEPTION IN DOGET\n");
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    try {
    ObjectInputStream inputFromApplet = new ObjectInputStream(request.getInputStream());
    String aString = (String) inputFromApplet.readObject();
    request.getSession().setAttribute("ID", aString);
    inputFromApplet.close();
    System.out.println("object received from applet:"+aString+"\n");
    catch(Exception e)
    System.out.println("EXCEPTION IN DOPOST\n");

    There are some things in Java which can't be serialized. When contained within a higher-level class such as Buttons. A button can be associated with an Action Listener. Now, you can serialize a button; however you can't serialize an action listener - for what should be to you obvious reasons. This is NOT an error and so there is no need to throw an exception when serializing the button.
    Basically: Applet sends servlet button, but not listener.

  • Default to Java Serialization in case Pof Serialization not defined

    Is this possible to do, i.e. essentially if for a certain class Pof serialization is not defined, use the Java serialization instead?
    Or to turn it around, is it possible to define pof serialization only for certain classes in a distributed cache and use Java serialization for the rest?

    Hi,
    the problem for this is that Java serialization is not aware of POF (or for that matter even ExternalizableLite), so if you have a Java-serialized class which has a member which is supposed to be POF-serializable, it in fact will not be serialized with POF, because Java serialization will not delegate to POF.
    So it is very hard to mix the two together. You can do it for top-level objects by providing a special PofSerializer instance for the non-POF class which serializes to byte array and you write the byte array as a POF attribute, but it is not possible for POF-aware objects contained within a non-POF aware object to be POF serialized.
    Also, if you attempt to do this, then you can kiss goodbye to platform independence. You must use Java on both ends and have all the libraries which the classes used in the state want to pull in.
    Best regards,
    Robert

  • Import org.apache.xml.serialize.*;

    .java:66: package org.apache.xml.serialize does not exist
    import org.apache.xml.serialize.*;
    ^
    i am getting this error while running a java program, which i downloaded from a open source.
    i am using J Creator.
    i suppose i need to add a class path or package.
    can anybody tell me how to do this.
    and where can i find that package.
    if i can't find that in my system, where can i get it on net.

    .java:66: package org.apache.xml.serialize does notThe org.apache.xml.serialize.* package is part of Xerces:
    http://xml.apache.org/xerces-j/
    http://xml.apache.org/xerces2-j/index.html

  • How to add elements to a list of Long Serializable

    I am currently writing a set of generic DAOs with generic signatures such as DAO<PK extends Serializable> (you've all seen the pattern).
    I am using Hibernate to persist to the database whose method is;
    public Serializable save(Object object)
    However, I am working in batches to save groups of Objects at a time & would like to save the returned Serializable types from this method to a list.
    List< ? extends Serializable> someList = new ArrayList< Long >
    for ( loop 0..n ) {
    someList.add( save( objectToPersist ) );
    This will not even compile as the IDE gives the error;
    The method add(capture-of ? extends Serializable) in the type List<capture-of ? extends Serializable> is not applicable for the arguments (Serializable)
    Ive obviously got the wrong end of the stick somewhere but I thought List<? extends Serializable> was a subclass of Collection<?> etc.
    Or am I trying to subclass a super type...
    Apologies for a stupid question as Ive just started using Generics & I've got the Tiger 5 book to read this weekend so Im sure itll make sense by then, but this is confusing me.
    Thanks

    As a side note
            List<? extends Serializable> someList = new ArrayList< Long >();
            someList.add(null);  //works
            someList.add(new Long(21));  //wont compilehttp://www.javabeat.net/articles/33-generics-in-java-50-3.html
    http://www.javabeat.net/articles/33-generics-in-java-50-4.html
    Came across these links discussing why the above wont compile

  • How to Convert Externalizable objec to Serializable at Run Time

    Urgent Help needed ...
    Original Problem
    We are using Externalizable object through the system .We keep track of versioning with field in each object ...
    This version is common software version...
    We change that version every two or three week ...
    suppose for
    My software Version is 2
    and suppose if someone add a new field to any object we put a checking in readExternal to not read that field is the version is less than 2
    Now the problem is say
    1)We make a version 2 on June 10
    2)Some one save a object on June 11
    3)Some one add a new field in any object and put the checking of Version 2
    4)Now object saved in step 2 cannot be read once step 3 is performed...
    How do we solve this issue ?
    We do not intend to add the class Version in each class at this stage. ...
    Issue 2
    Other issue related to issue 1 itself
    We plan to convern the object to xml using some technology of Xstream
    Now issue 1 can be solved atlease if my all the object were of type Serializable and NOT EXTERNALIZABLE
    So my Second Question is is there a way to convert a Externalizable object to Serialiable object just for my purpose when i m converting to xml and vice versa .....
    Basicallly I want a way to remove that EXTERNALIZABLE Interface from class at run time WITHOUT CHANGING ANY CLASS SOURCE CODE ...../
    Guy Your help is very appreiciated to solve this two issue
    Message was edited by:
    palanmahesh

    It seem i have not properly explained to you guys my
    problem
    I cannot change the code of existing object which are
    Externalizable..
    Nor can i solve the versioning issue That block of
    source code i cannot touch
    all i want is somehow convert the object so that they
    are not instance of Externalizable Well it seems pretty hopeless then doesn't it.
    My advice? Give up. You seem pretty lost and when people respond by basically saying they can't solve the problem in any reasonable way then it's pretty much a lost cause.
    Good luck with your hopeless task. I see nothing but upset in your future.

  • Date serialization

    Hi
    I have found interesing (??) problem with Date object serialization. Date object serialized on Sun JVM can't be correctly deserialized on IBM JVM !!
    Try run this example on Sun JVM.
    import java.io.*;
    import java.util.Date;
    public class Write {
         public static void main(String[] args) throws IOException {
              Date date = new Date(45,8,1);
              System.out.println("JVM Vendor ["+System.getProperty("java.vm.vendor")+"] Version ["+System.getProperty("java.vm.version")+"]");
              System.out.println("Date ["+date+"], Date time ["+date.getTime()+"]");
              System.out.println("Date timeZoneOffset:"+date.getTimezoneOffset());
              //Serialize date
              ByteArrayOutputStream bout = new ByteArrayOutputStream();
              ObjectOutputStream ous = new ObjectOutputStream(bout);
              ous.writeObject(date);
              ous.flush();
              //write to file
              File outFile = new File("date.bin");
              FileOutputStream fous = new FileOutputStream(outFile);
              fous.write(bout.toByteArray());
              fous.close();
    }Result should be:
    JVM Vendor [Sun Microsystems Inc.] Version [1.4.2_05-b04]
    Date [Sat Sep 01 00:00:00 CEST 1945], Date time [-767930400000]
    Date timeZoneOffset:-120
    And serialized date object should be written into date.bin file.
    Next run this code on IBM JVM:
    import java.io.*;
    import java.util.Date;
    public class Read {
         public static void main(String[] args) throws Exception {
              File inFile = new File("date.bin");
              FileInputStream fis = new FileInputStream(inFile);
              ObjectInputStream ois;
              ois = new ObjectInputStream(fis);
              Date date = (Date) ois.readObject();
              ois.close();
              fis.close();
              System.out.println("JVM Vendor ["+System.getProperty("java.vm.vendor")+"] Version ["+System.getProperty("java.vm.version")+"]");
              System.out.println("Date ["+date+"], Date time ["+date.getTime()+"]");
              System.out.println("Date timeZoneOffset:"+date.getTimezoneOffset());
    }On my IBM JVM result is:
    JVM Vendor [IBM Corporation] Version [1.4.1]
    Date [Fri Aug 31 23:00:00 CET 1945], Date time [-767930400000]
    Date timeZoneOffset:-60
    Why deserialized date object has different value then before serialization??
    Magic date is 1945-09-16, if I set date after - everytjing is ok, if I set date before - something is wrong.

    Hi
    I have found interesing (??) problem with Date object
    serialization. Date object serialized on Sun JVM
    can't be correctly deserialized on IBM JVM !!So what, serialization was not meant to be portable accross JVM implementations.

  • 1.4.2 and 1.5 serialization portability

    Hello,
    I came across the problem of reading class previously serialized w/ jdk 1.4.2_02 using jdk 1.5.
    I have embedded object database and everything works fine with the jdk1.4. The problem is happening when I am trying to run the program with jre 1.5 . (the program is compiled with jdk 1.4.2)
    OS is Windows2000.
    Any suggestions? Did anybody encounter this type of the problem?
    Thank for your help.
    Leo
    The exception is happening in the following method:
    //fields
    public BTreePageHeader m_header;
    public long [] m_key; // array of key values
    public long [] m_recPtr; // record pointers
    public long [] m_link; // links to other pages
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
    // read back key information
    m_header = (BTreePageHeader)in.readObject();
    // read link arrays
    m_key = (long [])in.readObject(); // *********here is exception with JDK1.5************
    m_recPtr = (long [])in.readObject();
    m_link = (long [])in.readObject();
    Following is the exception:
    java.io.StreamCorruptedException
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1600)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1290)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
    at tfcomp.core.Store.Db.BTreePage.readExternal(BTreePage.java:102)
    at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
    at tfcomp.core.Store.Db.ObjectDatabaseFile.readObject(ObjectDatabaseFile.java:390)

    Hi mlk,
    It is not a Bean; I am using internal object database that is based in RandomAccessFile and serialization of the objects.
    I am a bit confused with the statement that serialization is not portable between versions - is there more detailed analysis of that somethere...? this is a major problem for me. It was my understanding that as long as one uses Externilizable or/and putting serialVersionUID, there should not be any problem and backwards compatibility is supported. If this is not true - all Object databases have a problem
    If anybody has experiense with this or can direct me information related to this problem I would much appreciate your help.
    Best regards,
    Leo

  • Using JAXB 2.0 as the Java Serializer for WSIF bindings

    Hello All:
    I am trying to invoke a Java Class from a BPEL process (using native WSIF Java Binding) using JAXB 2.0 as the Java Serializer. However it seems that Oracle already has an older verion of JAXB on the classpath which results in an exception during the serialization (could not find jaxb.properties in the package ...). Can you guys tell me how to pick up the newer version of the JAXB library. I have added the required jar files as a shared library. How can the classloading behaviour be altered to accomodate this?
    Does 10.1.3.4 take care of this? I have 10.1.3.3 currently

    Hi,
    Did you ever solve this issue? I'm having the same problem with toplink and hibernate jars....
    Regards,
    Zaloa

  • SerialVersionUID's not matching

    Hi, here's my exception:
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.io.InvalidClassException: com.tsc.model.courts.County; local class incompatible: stream classdesc serialVersionUID = -2433655832140195139, local class serialVersionUID = -5449895978211640294
    at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
    at sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
    at com.inteflux.Session.SessionManager_Stub.putObject(Unknown Source)
    at com.inteflux.Session.SessionControlBean.putValue(SessionControlBean.java:116)
    at com.tsc.action.AbstractUserAction.putSessionValue(AbstractUserAction.java:69)
    at com.tsc.action.agent.TimedBookOrderAction.payment(TimedBookOrderAction.java:172)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:353)
    at com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:208)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:182)
    at com.tsc.interceptor.webwork.HibernateInterceptor.intercept(HibernateInterceptor.java:35)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor.intercept(DefaultWorkflowInterceptor.java:117)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.webwork.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:171)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:146)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:32)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:94)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:180)
    at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:119)
    at com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(DispatcherUtils.java:233)
    at com.opensymphony.webwork.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:198)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.io.InvalidClassException: com.tsc.model.courts.County; local class incompatible: stream classdesc serialVersionUID = -2433655832140195139, local class serialVersionUID = -5449895978211640294
    at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
    at sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.InvalidClassException: com.tsc.model.courts.County; local class incompatible: stream classdesc serialVersionUID = -2433655832140195139, local class serialVersionUID = -5449895978211640294
    at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
    at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
    at java.io.ObjectInputStream.readClassDesc(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
    at java.io.ObjectInputStream.readSerialData(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source)
    Now I know that means that the two version of the class are different but I don't see how. The class is only located in one place on the server, so how is it possible that it's different? Any help would be appreciated because I'm at a loss as to what to do or even how to search for the problem.
    I have tried to set the UID manually, but that didn't help. I also am using netbeans and deleted the old classfiles to force it to recreate them again and that didn't work either.
    I'm using a session bean to put a class in the session. The error is being generated by a class variable that is within the main class to be serialized. Not sure if maybe that has something to do with it.

    Now I know that means that the two version of the
    class are different but I don't see how.
    The class is only located in one place on the server,
    so how is it possible that it's different?Did you modify the source file for that class at some point?
    Basically, if you never explicitly specified a "serialVersionUID"
    in the Java source code, then every time you compile it,
    the Java compiler will assign a serialVersionUID for you,
    based on the fields you have in your class.
    So that's very fragile: if you modify the source file for that class,
    then suddenly the UID may change, and you won't be able
    to deserialize a object that you previously serialized.
    The lesson: for every serializable class,
    you should explicitly give it a UID.
    It doesn't matter what value you choose. Can be 0.
    As long as you choose a value, then the compiler
    won't change it back and forth.
    As for your particular recovery: it seems you have some
    serialized objects that you want to read back.
    Did you change the fields between last time and this time?
    If you didn't, then just find out what UID value was chosen by the compiler.
    Then you write that UID into your source file and recompile.
    That should allow you to read-back your old objects.
    (But if you've added or removed a field since the last time,
    then clearly the default serialization should NOT work.
    You would need to read about "readResolve" and
    other advanced methods for how to deserialize
    an out-of-date file)

  • Singleton serialization and weblogic - help!

    hi everyone,
    I'm trying to serialize a singleton cache object we're using for our (intranet)
    website running on weblogic 6.1. I've made sure the singleton class
    implements serializable, and i've also put the following method in the
    singleton class (ChartCache.java):
    private Object readResolve()
    return theInstance; //which is of type ChartCache
    By the way I'm using jdk 1.3. I've trawled the web and can't find anything to help me yet...
    Basically I've written a jsp to get the current instance of the cache
    and serialize it to a file. When I invoke another jsp i want it to
    reinflate the object and place it back into the weblogic jvm so it can
    once again be accessed as a singleton by all classes in the webapp. At
    the moment its just not working - the cache object will eventually
    take over half an hour to create (huge database processing going on)
    so I want the option, if weblogic falls over, to reinstantiate the
    cache without having to rebuild it from scratch. The cache will only
    be refreshed once a day.
    I'll c&p my jsp code below...
    ======================= restoreCache.jsp
    <%@ page import = "java.util.*" %>
    <%@ page import = "java.io.*" %>
    <%@ page import = "com.drkw.agencylending.website.chartcache.*" %>
    <%@ page import = "com.drkw.agencylending.log.Logger" %>
    <%
    ChartCache theCache = null;
    try
    String filename = "chartCache.dat";
    FileInputStream fis = new FileInputStream(filename);
    ObjectInputStream in = new ObjectInputStream(fis);
    theCache = (ChartCache)in.readObject();
    in.close();
    catch(Exception e)
    Logger.log(e);
    %>
    Resurrected chart cache from file.
    ======================= saveCache.jsp
    <%@ page import = "java.util.*" %>
    <%@ page import = "java.io.*" %>
    <%@ page import = "com.drkw.agencylending.website.chartcache.*" %>
    <%@ page import = "com.drkw.agencylending.log.Logger" %>
    <%
    ChartCache theCache = ChartCache.getInstance();
    String fileName = "chartCache.dat";
    try
    FileOutputStream fos = new FileOutputStream(fileName);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(theCache);
    oos.flush();
    oos.close();
    catch(Exception e)
    Logger.log(e);
    %>
    Wrote cache object to file.
    ============================
    At the moment, a file is getting written but it seems suspiciously
    small (73 bytes!) for what is a very large object. When I try to load
    it up again, I get no errors but when I call ChartCache.getInstance()
    (my singleton) it recreates the cache rather than using the one I've
    reinflated. BTW I don't need to worry about server clustering/JNDI to
    ensure I have a truly singleton instance - there will only ever be one
    JVM to worry about.
    Any help greatly appreciated!

    solved the problem using another technique. Rather
    than serialize the entire singleton object, I just
    serialized the hashmap (the only bit I really care
    about). Then in the private constructor, the class
    checks a database flag to see whether the singleton
    was created today - if not, I refresh the cache,
    otherwise load in the serialized hashmap and set that
    as my class member. No complicated jndi/ejb registry
    needed to get around it..!singleton serialization is not recommended in ejb enviroment, it will cause problems. in what you are doing, it is far better to persist the data values in a database.
    just for the sake of writing a serializable sington: in addition to what you do in a regular object, you would first check to see if this obj has been serialized, if it is, deserialize it and return this one. you would have to write your own method to do serialization, making sure you have only one place to serialize it, and let the object know where the file is.

  • What r the methods present in serialization

    In one of my interview i have faced this question.
    I said that serialization is a marker interface, it does't contain any methods.
    But the interviewing person said then How can you know the object is serialized. and also he said some write and read methods are present in serializable interface
    I am confused about this.
    Can any one help regarding this?
    Also I want to know How can the object know whether it is serializable or remote or some thing else whn we implement the marker interface.

    In one of my interview i have faced this question.
    I said that serialization is a marker interface, it
    does't contain any methods.You were correct.
    But the interviewing person said then How can you
    know the object is serialized.How can who know? The object itself can know if it implements some of the readObject/writeObject/writeReplace/readResolve methods defined in the Serialization specification (not the Serializable interface).
    and also he said some write and read methods are present in serializable
    interfaceIf that's exactly what he said, he was wrong: see the Javadoc for the Serializable interface. If he said they're available during serialization he is correct, see above.
    I am confused about this.I think your interviewer was too.
    Also I want to know How can the object know whether
    it is serializable or remote or some thing else whn
    we implement the marker interface.The object itself can know via self-introspection using Reflection: it can see whether it implements Serializable and/or Remote. Why it would want to do this I don't know.

Maybe you are looking for