Serialization issue

I have an ArrayList that gets serialized and written to a file. I can then do the reverse and deserialize within the same program. I hit a scope problem when I ask a seperate java program to do the latter half of the above i.e. access the elements of the ArrayList. This is because the initial serialization involved an inner private static class that is only accessible within its outer class. This private static inner class is causing me grief because it needs to be referenced by other programs in order to access its primitive types. Any ideas on how i may re-engineer things? Below is a snippet.
public class outerClass {
// Data Structure to hold user input 
private static class StringHolder implements Serializable {
      private String str1;
      private String str2;
      private String str3;
      // constructor takes 3 strings
      private StringHolder(String str1, String str2, String str3) {
         this.str1 = str1;
         this.str2 = str2;
         this.str3 = str3;
}        // end of StringHolder class
}

Err, make the inner class public?
If you have existing serializations that you want to deserialize, you can't. If that makes them worthless, throw them away.

Similar Messages

  • [svn] 1543: Bug: BLZ-152-lcds custom Date serialization issue - need to add java.io. Externalizable as the first type tested in AMF writeObject() functions

    Revision: 1543
    Author: [email protected]
    Date: 2008-05-02 15:32:59 -0700 (Fri, 02 May 2008)
    Log Message:
    Bug: BLZ-152-lcds custom Date serialization issue - need to add java.io.Externalizable as the first type tested in AMF writeObject() functions
    QA: Yes - please check that the fix is working with AMF3 and AMFX and you can turn on/off the fix with the config option.
    Doc: No
    Checkintests: Pass
    Details: The problem in this case was that MyDate.as was serialized to MyDate.java on the server but on the way back, MyDate.java was serialized back to Date.as. As the bug suggests, added an Externalizable check in AMF writeObject functions. However, I didn't do this for AMF0Output as AMF0 does not support Externalizable. To be on the safe side, I also added legacy-externalizable option which is false by default but when it's true, it restores the current behavior.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/BLZ-152
    Modified Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/AbstractEndpoint.ja va
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/io/SerializationContext.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/io/amf/Amf3Output.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/io/amfx/AmfxOutput.java
    blazeds/branches/3.0.x/resources/config/services-config.xml

  • Pof Serialization issue

    Hi guys,
    I get an "unknown user type issue" for only one class defined in my pof-config-file. The rest are ok which is the part I can't get my head round.
    Log (showing config load)
    Everything seems to load ok. In fact, just to confirm, I messed up some tags in the xml file and I got problems. So it's finding the file ok.
    +010-06-30 11:35:11.965/1.212 Oracle Coherence GE 3.5.3/465 <D5> (thread=Cluster, member=n/a): Member 1 joined Service InvocationService with senior member 1+
    +2010-06-30 11:35:12.007/1.255 Oracle Coherence GE 3.5.3/465 <D5> (thread=Invocation:Management, member=2): Service Management joined the cluster with senior service member 1+
    +2010-06-30 11:35:12.267/1.514 Oracle Coherence GE 3.5.3/465 <Info> (thread=Cluster, member=2): Loading POF configuration from resource "file:/mnt/linux-share/zeus/Zeus-core/config/zeus-pof-config.xml"+
    +2010-06-30 11:35:12.268/1.515 Oracle Coherence GE 3.5.3/465 <Info> (thread=Cluster, member=2): Loading POF configuration from resource "jar:file:/mnt/linux-share/repository/com/tangsol/coherence/3.5.3/coherence-3.5.3.jar!/coherence-pof-config.xml"+
    +2010-06-30 11:35:12.283/1.530 Oracle Coherence GE 3.5.3/465 <D5> (thread=DistributedCache, member=2): Service DistributedCache joined the cluster with senior service member 1+
    +2010-06-30 11:35:12.338/1.585 Oracle Coherence GE 3.5.3/465 <D5> (thread=DistributedCache, member=2): Service DistributedCache: received ServiceConfigSync containing 2040 entries+
    Exception
    Exception in thread "main" java.lang.IllegalArgumentException: unknown user type: org.zeus.query.QueryInvocable
    at com.tangosol.io.pof.ConfigurablePofContext.getUserTypeIdentifier(ConfigurablePofContext.java:400)
    at com.tangosol.io.pof.ConfigurablePofContext.getUserTypeIdentifier(ConfigurablePofContext.java:389)
    at com.tangosol.io.pof.PofBufferWriter.writeObject(PofBufferWriter.java:1432)
    at com.tangosol.io.pof.ConfigurablePofContext.serialize(ConfigurablePofContext.java:338)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.Service.writeObject(Service.CDB:4)
    at com.tangosol.coherence.component.net.Message.writeObject(Message.CDB:1)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.InvocationService$InvocationRequest.write(InvocationService.CDB:3)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.packetProcessor.PacketPublisher.packetizeMessage(PacketPublisher.CDB:137)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.packetProcessor.PacketPublisher$InQueue.add(PacketPublisher.CDB:8)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.dispatchMessage(Grid.CDB:50)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.post(Grid.CDB:35)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.send(Grid.CDB:1)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.InvocationService.execute(InvocationService.CDB:31)
    at com.tangosol.coherence.component.util.safeService.SafeInvocationService.execute(SafeInvocationService.CDB:1)
    at org.ebtic.bpm.zeus.query.DistributedQueryProcessor.invokeQuery(DistributedQueryProcessor.java:133)
    at org.ebtic.bpm.zeus.query.DistributedQueryProcessor.query(DistributedQueryProcessor.java:95)
    at org.ebtic.bpm.zeus.query.DistributedQueryProcessor.main(DistributedQueryProcessor.java:56)
    My pof-config file looks like this:
    +<!DOCTYPE pof-config SYSTEM "pof-config.dtd">+
    +<pof-config>+
    +<user-type-list>+
    +<include>coherence-pof-config.xml</include>+
    +<user-type>+
    +<type-id>10001</type-id>+
    +<class-name>org.util.ZeusKey</class-name>+
    +</user-type>+
    +<user-type>+
    +<type-id>10002</type-id>+
    +<clas-name>org.query.QueryInvocable</clas-name>+
    +</user-type>+
    +<user-type>+
    +<type-id>10003</type-id>+
    +<class-name>org.sequencegenerator.ZeusSequenceGenerator$State</class-name>+
    +</user-type>+
    +</user-type-list>+
    +<allow-interfaces>true</allow-interfaces>+
    +<allow-subclasses>true</allow-subclasses>+
    +</pof-config>+
    Only the class QueryInvocable is causing a problem. ZeusKey and SequenceGenerator are working perfectly well.
    QueryInvocable looks like the following:
    public class QueryInvocable
    extends AbstractInvocable implements ExternalizableLite,
    PortableObject
    +{+
    private String m_sCacheName;
    private PartitionSet partitionSet;
    public QueryInvocable()
    +{+
    +}+
    public QueryInvocable(String sCacheName, PartitionSet partitions)
    +{+
    m_sCacheName = sCacheName;
    partitionSet = partitions;
    +}+
    +public PartitionSet getPartitionSet(){+
    return partitionSet;
    +}+
    +public String getCacheName(){+
    return m_sCacheName;
    +}+
    +public void setPartitionSet(PartitionSet pSet){+
    this.partitionSet = pSet;
    +}+
    +public void setCacheName(String name){+
    this.m_sCacheName = name;
    +}+
    +/**+
    +* {@inheritDoc}+
    +public void run(){+
    +try{+
    ZeusQueryProcessor client = new ZeusQueryProcessor("Distributed Query Processor", partitionSet);
    client.process();
    +}+
    +catch(Exception e){+
    System.err.println("Exception creating ZeusQueryProcessor.");
    e.printStackTrace();
    +}+
    +}+
    +public void readExternal(PofReader reader) throws IOException{+
    System.out.println("Reading in....");
    m_sCacheName = reader.readString(0);
    partitionSet = (PartitionSet) reader.readObject(1);
    +}+
    +public void writeExternal (PofWriter writer) throws IOException{+
    System.out.println("Writing out....");;
    writer.writeString(0, m_sCacheName);
    writer.writeObject(1, partitionSet);
    +}+
    +public void readExternal(DataInput in) throws IOException{+
    System.out.println("Reading in....");
    m_sCacheName = (String) ExternalizableHelper.readObject(in);
    partitionSet = (PartitionSet) ExternalizableHelper.readObject(in);
    +}+
    +public void writeExternal(DataOutput out) throws IOException{+
    System.out.println("Writing out....");;
    ExternalizableHelper.writeObject(out, m_sCacheName);
    ExternalizableHelper.writeObject(out, partitionSet);
    +}+
    +}+
    Edited by: user11218537 on 30-Jun-2010 00:54

    user11218537 wrote:
    Sorry, this was the result of my not-very-efficient attempt to anonymize my code posting. The package and class names do actually match.
    I may have "by accident" solved the problem but I am not sure since I have to test properly. It appears that if I define the PofSerialization stuff in the pof-context.xml, which is then referenced from my coherence-cache-config.xml, I should not set the tangosol.pof.enabled=true flag.
    I was basically trying to turn of pof so that I could test something else in my code but it appears that just by removing that flag in the cache-server.sh script (which I had added earlier), the problem disappeared and coherence is still using pof.
    What am I missing? Is this behaviour correct?If you remove the tangosol.pof.enabled flag from the Java properties, then POF by default will not be used.
    On the other hand if you still have POF configured for certain services with the <serializer> element referring to a PofContext implementation e.g. ConfigurablePofContext, then those services (and only those services) will use POF.
    Best regards,
    Robert

  • Serialization issue with Java 5 enum

    Hi,
    In one of my DTO class, i have used an enum as an instance variable. But I am getting a serialization error during RMI call.
    Caused by: org.omg.CORBA.MARSHAL: Mismatched serialization UIDs : Source (RepId RMI:com.nokia.oss.interfaces.usermanagement.dtos.UMStatusDTO:1191975053A2D5C1:0000000000000001) = 0000000000000001 whereas Target (RepId RMI:com.nokia.oss.interfaces.usermanagement.dtos.UMStatusDTO:7F5FECD5609C39F7:6318A841C6045391) = 6318A841C6045391  vmcid: IBM  minor code: 8B1  completed: No
         at com.ibm.rmi.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:467)
         at com.ibm.rmi.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:209)
         at com.ibm.rmi.iiop.CDRInputStream.read_value(CDRInputStream.java:1638)
         at com.ibm.rmi.util.ProxyUtil.copyObject(ProxyUtil.java:450)
         at com.ibm.rmi.util.ProxyUtil.invokeWithClassLoaders(ProxyUtil.java:754)
         at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java:1161)
         at $Proxy322.createUserProfiles(Unknown Source)
         at com.nokia.oss.interfaces.usermanagement.ejb.useradministration._UMUserAdministration_Stub.createUserProfiles(Unknown Source)
         at com.nokia.oss.tmf615.uamadapters.connectors.UMAPI$2$1.run(UMAPI.java:187)
         at com.nokia.oss.tmf615.uamadapters.connectors.UMAPI$2$1.run(UMAPI.java:186)
         at java.security.AccessController.doPrivileged(AccessController.java:246)
         at com.nokia.oss.tmf615.uamadapters.connectors.UMAPI$2.run(UMAPI.java:184)
         at com.nokia.oss.tmf615.uamadapters.connectors.UMAPI$2.run(UMAPI.java:182)
         at java.security.AccessController.doPrivileged(AccessController.java:279)
         at javax.security.auth.Subject.doAs(Subject.java:573)
         at com.ibm.websphere.security.auth.WSSubject.doAs(WSSubject.java:168)
         at com.nokia.oss.tmf615.uamadapters.connectors.UMAPI.createUserProfiles(UMAPI.java:179)
         at com.nokia.oss.tmf615.uamadapters.operations.impl.UserManagerImpl.createUserProfile(UserManagerImpl.java:148)
         at com.nokia.oss.tmf615.uamadapters.operations.impl.UserManagerImpl.createUser(UserManagerImpl.java:81)
         at com.nokia.oss.tmf615.requesthandler.factory.ManageUAMImpl.createUser(ManageUAMImpl.java:103)
         at com.nokia.oss.tmf615.requesthandler.operations.RequestProcessor.addUserRequest(RequestProcessor.java:342)
         at urn.oasis.names.tc.SPML._2._0.wsdl.SPMLRequestPortTypeImpl.spmlAddRequest(SPMLRequestPortTypeImpl.java:1028)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:618)
         at com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:246)
         at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
         at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
         at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
         at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
         at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
         at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
         at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129)
         at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160)
         at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:593)
         at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:533)
         at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3548)
         at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:269)
         at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:818)
         at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)
         at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:125)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
         at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
         at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
         at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
         at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
         at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
         at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
         at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:196)
         at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:751)
         at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:881)
         at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)My environment has WebSphere Application Server 6.1.
    Earlier, I had used serialVersionUID generated by Eclipse, but to debug I changed it to 1L. But still I am facing the same issue. Any help in solving this issue is greatly appreciated.
    Thanks.

    Caused by: org.omg.CORBA.MARSHAL: Mismatched serialization UIDs : Source (RepId RMI:com.nokia.oss.interfaces.usermanagement.dtos.UMStatusDTO:1191975053A2D5C1:0000000000000001) = 0000000000000001 whereas Target (RepId RMI:com.nokia.oss.interfaces.usermanagement.dtos.UMStatusDTO:7F5FECD5609C39F7:6318A841C6045391) = 6318A841C6045391  vmcid: IBM  minor code: 8B1  completed: NoEarlier, I had used serialVersionUID generated by Eclipse, but to debug I changed it to 1L.Why? To debug what? How would that help? This is exactly the problem that the exception message (above) is reporting. Change it back to 6318A841C6045391L.

  • POF Serializer issue

    I have a strange issue using a POF serializer where one of the fields of the class is not populated when the object is retrieved from the cache.
    The class looks like:
    public class RegionSerializer extends AbstractPersistentEntitySerializer<RegionImpl> {
         private static final int REGION_CODE = 11;
         private static final int NAME = 12;
         private static final int ID_REGION = 13;
         private static final int ID_CCY_RPT = 14;
         @Override
         protected RegionImpl createInstance() {
              return new RegionImpl();
         public void serialize(PofWriter out, Object o) throws IOException {
              RegionImpl obj = (RegionImpl) o;
              super.serialize(out, obj);
              out.writeObject(REGION_CODE, obj.getRegionCode());
              out.writeString(NAME, obj.getName());
              out.writeInt(ID_REGION, obj.getIdRegion());
              out.writeObject(ID_CCY_RPT, obj.getIdCcyRpt());
         public Object deserialize(PofReader in) throws IOException {
              RegionImpl obj = (RegionImpl) super.deserialize(in);
              obj.setRegionCode((RegionCode) in.readObject(REGION_CODE));
              obj.setName(in.readString(NAME));
              obj.setIdRegion(in.readInt(ID_REGION));
              obj.setIdCcyRpt((CurrencyCode) in.readObject(ID_CCY_RPT));
              return obj;
    }and the RegionCodeSerializer...
    public class RegionCodeSerializer implements PofSerializer{
         private static final int CODE = 11;
         public void serialize(PofWriter out, Object o) throws IOException {
              RegionCode obj = (RegionCode) o;
              out.writeString(CODE, obj.getCode());
         public Object deserialize(PofReader in) throws IOException {
              RegionCode obj = new RegionCode();
              obj.setCode(in.readString(CODE));
              return obj;
    }the output from the log after inserting and retrieving from the cache is
    06-Oct-2010 10:11:28,277 BST DEBUG refdata.RefDataServiceImpl main - Region count:4
    06-Oct-2010 10:11:28,277 BST INFO  cache.TestCacheStartUp main - REGION FROM DAO: RegionImpl[RegionImpl[objectId=5],regionCode=EMEA,name=LONDON]
    06-Oct-2010 10:11:28,277 BST INFO  cache.TestCacheStartUp main - REGION FROM DAO: RegionImpl[RegionImpl[objectId=6],regionCode=US,name=NEW YORK]
    06-Oct-2010 10:11:28,277 BST INFO  cache.TestCacheStartUp main - REGION FROM DAO: RegionImpl[RegionImpl[objectId=7],regionCode=APAC,name=TOKYO]
    06-Oct-2010 10:11:28,277 BST INFO  cache.TestCacheStartUp main - REGION FROM DAO: RegionImpl[RegionImpl[objectId=8],regionCode=NON_PYRAMID_DESKS,name=NON PYRAMID DESKS]
    06-Oct-2010 10:11:28,293 BST INFO  cache.TestCacheStartUp main - Is Cache empty?: false
    06-Oct-2010 10:11:28,293 BST INFO  cache.TestCacheStartUp main - Cache Size is: 4
    06-Oct-2010 10:11:28,324 BST INFO  cache.TestCacheStartUp main - REGION FROM CACHE: RegionImpl[RegionImpl[objectId=6],regionCode=US,name=<null>]
    06-Oct-2010 10:11:28,324 BST INFO  cache.TestCacheStartUp main - REGION FROM CACHE: RegionImpl[RegionImpl[objectId=7],regionCode=APAC,name=<null>]
    06-Oct-2010 10:11:28,324 BST INFO  cache.TestCacheStartUp main - REGION FROM CACHE: RegionImpl[RegionImpl[objectId=8],regionCode=NON_PYRAMID_DESKS,name=<null>]
    06-Oct-2010 10:11:28,324 BST INFO  cache.TestCacheStartUp main - REGION FROM CACHE: RegionImpl[RegionImpl[objectId=5],regionCode=EMEA,name=<null>]as can be seen from the output the name field is null after retrieving. It seems that the 3 remaining fields after regionCode are being ignored by the deserialize (or serialize method) in the serializer class above but I can't see why? Any ideas?

    Hi,
    You need to call read/writeRemainder() method at the end of serialization/deserialization to properly terminate reading/writing of a user type.
    Thanks,
    Wei

  • Serialization issue for ValueChangeEvent

    Hi,
    We have a bean registered in pageFlowScope. This bean has an instance variable of type ValueChangeEvent.
    At run time, we are seeing the below exception when the scope is seriazed:
    java.io.NotSerializableException: javax.faces.event.PhaseId
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
    at
    oracle.adfinternal.controller.state.SessionBasedScopeMap.writeScopeMap(SessionB
    asedScopeMap.java:122)
    ValueChangeEvent is Serializable. ValueChangeEvent extends FacesEvent which is Serializable.
    From http://myfaces.apache.org/core12/myfaces-api/apidocs/serialized-form.html#javax.faces.event.FacesEvent, FacesEvent has a Serializable Field _phaseId of type PhaseId. However, PhaseId is not Serializable.
    Is this a bug ?

    Hi,
    Thannks for the response.
    The bean implements Serializable. And the issue is caused by having an instance variable of type ValueChangeEvent.
    We are not able to serialize ValueChangeEvent object though it implements Serializable because the super class (FacesEvent) has a Serializable Field of type PhaseId which doesn't implement Serializable.

  • IDOC Serialization issue.

    Hi,
    I tried to do IDOC serialization using this blog
    /people/community.user/blog/2006/11/04/how-to-serialize-idoc-xml-messages-fed-into-xi
    But in this blog its says to create a queue processing rule using WE85 transaction.
    My system is not as WAS 6.40, so when i tried to run WE85 transaction, it says transaction doesn't exist. SAP system is of enterprise version 4.7 (WAS 6.2)  and it doesn't have WE85.
    What is an alternative to this and how to achieve IDOC serialization.
    Thanks,
    Swapna

    Hi,
    http://help.sap.com/saphelp_nw04/helpdata/en/bd/277264c3ddd44ea429af5e7d2c6e69/content.htm
    The link above which has detail help on serialization.hope this helps.Pls check whether this helps.
    Regards,
    Sharath

  • Serialization issue (probably?)

    Greetings fellow Java devs.
    I am fairly new to the subject of serialization. I am developing production code for a company and I need another pair of eyes to look at what I'm doing and help me figure it out. I have spent days debugging this god forsaken problem and it's just becoming a huge hindrance.
    I am trying to manage a LinkedList data structure with methods for "adding (inserting)" "removing" "setting" etc. There are two lists, a "LinkedList<WI_Item> watchList" and "LinkedList<WI_Item> ignoreList" of custom-Objects ("WI_Item" just a DS to hold info needed).
    The problem: The "System.outs" in the "remove" and "insert" methods work fine, as expected. The "watchList" and "ignoreList" LinkedLists update as expected. However, it seems that every other time a reference is made to those objects, they have "reset" to what they were when the file was originally read in by the constructor. In other words, the Objects appear to change for a short while, and then they go back to their original state.
    What am I doing wrong? Thanks for your help. I haven't got any energy to debug this anymore. :(
        public void removeFromWatch(WI_Item item){
            System.out.println("Old WatchList: " + watchList);
            watchList.remove(item);
            System.out.println("New WatchList: " + watchList);
            setWatchList(watchList);
            System.out.println("Same WatchList: " + watchList);
        public void removeFromIgnore(WI_Item item){
            System.out.println("Old IgnoreList: " + ignoreList);
            ignoreList.remove(item);
            System.out.println("New IgnoreList: " + ignoreList);
            setIgnoreList(ignoreList);
            System.out.println("Same IgnoreList: " + ignoreList);
        public void insertIntoWatch(WI_Item item){
            System.out.println("Old WatchList: " + watchList);
            watchList.add(item);
            System.out.println("New WatchList: " + watchList);
            setWatchList(watchList);
            System.out.println("Same WatchList: " + watchList);
        public void insertIntoIgnore(WI_Item item){
            System.out.println("Old ignoreList: " + ignoreList);
            ignoreList.add(item);
            System.out.println("New ignoreList: " + ignoreList);
            setIgnoreList(ignoreList);
            System.out.println("Same IgnoreList: " + ignoreList);I overrode the toString method for the "WI_Item" object so this displays as if it was printing a LinkedList of Strings (" [Item 1, Item 2, Item 3] ")
    And here are the two methods you will notice in that code (setWatchList, setIgnoreList) which handle the writing of the object.
        public void setWatchList(LinkedList<WI_Item> watchList){
            FileOutputStream fos = null;
            ObjectOutputStream watchOOS = null;
            try{
                fos = new FileOutputStream(watchListFile);
                watchOOS = new ObjectOutputStream(fos);
                watchOOS.writeObject(watchList);
                fos.close();
                watchOOS.close();
            } catch(Exception e){
                JOptionPane.showMessageDialog(new JFrame(),
                    "Error writing watch list " + e.getMessage(),
                    "Error writing watch list " + e.getMessage(),
                    JOptionPane.INFORMATION_MESSAGE);
        public void setIgnoreList(LinkedList<WI_Item> ignoreList){
            FileOutputStream fos = null;
            ObjectOutputStream ignoreOOS = null;
            try{
                fos = new FileOutputStream(ignoreListFile);
                ignoreOOS = new ObjectOutputStream(fos);
                ignoreOOS.writeObject(ignoreList);
                fos.close();
                ignoreOOS.close();
            } catch(Exception e){
                JOptionPane.showMessageDialog(new JFrame(),
                    "Error writing ignore list " + e.getMessage(),
                    "Error writing ignore list " + e.getMessage(),
                    JOptionPane.INFORMATION_MESSAGE);
        }The reading of the object (from the file) is done in the constructor, and only there. Whenever I need to "read" the list, I just return the LinkedLists.
        public LinkedList<WI_Item> getIgnoreList(){
            return ignoreList;
        public LinkedList<WI_Item> getWatchList(){
            return watchList;
        }Here is the constructor (which reads in the Objects once and only once):
        LinkedList<WI_Item> watchList;
        LinkedList<WI_Item> ignoreList;
        String watchListPath = "watchlist";
        String ignoreListPath = "ignorelist";
        InputStream ignoreListStream;
        InputStream watchListStream;
        File ignoreListFile;
        File watchListFile;
        URI ignoreListUri;
        URI watchListUri;
        ObjectInputStream ignoreOIS;
        ObjectInputStream watchOIS;
        public WatchIgnoreManager(){
            try{
                ignoreListStream = Main.class.getResourceAsStream(ignoreListPath);
                watchListStream = Main.class.getResourceAsStream(watchListPath);
                ignoreListUri = Main.class.getResource(ignoreListPath).toURI();
                watchListUri = Main.class.getResource(watchListPath).toURI();
                ignoreListFile = new File(ignoreListUri);
                watchListFile = new File(watchListUri);
                ignoreOIS = new ObjectInputStream(ignoreListStream);
                watchOIS = new ObjectInputStream(watchListStream);
                watchList = (LinkedList<WI_Item>)watchOIS.readObject();
                ignoreList = (LinkedList<WI_Item>)ignoreOIS.readObject();
            } catch(Exception e){
                e.printStackTrace();
                JOptionPane.showMessageDialog(new JFrame(),
                    "DataWriter Error " + e.getMessage(),
                    "DataWriter Error " + e.getMessage(),
                    JOptionPane.INFORMATION_MESSAGE);
            } finally {
                try{
                    ignoreListStream.close();
                    watchListStream.close();
                    ignoreOIS.close();
                    watchOIS.close();
                } catch(Exception e){
                    e.printStackTrace();
    ...

    Here is the full code for this class, if it helps.
    package firebirdprogram;
    /* imports edited out for space */
    public class WatchIgnoreManager {
        LinkedList<WI_Item> watchList;
        LinkedList<WI_Item> ignoreList;
        String watchListPath = "watchlist";
        String ignoreListPath = "ignorelist";
        InputStream ignoreListStream;
        InputStream watchListStream;
        File ignoreListFile;
        File watchListFile;
        URI ignoreListUri;
        URI watchListUri;
        ObjectInputStream ignoreOIS;
        ObjectInputStream watchOIS;
        public WatchIgnoreManager(){
            try{
                ignoreListStream = Main.class.getResourceAsStream(ignoreListPath);
                watchListStream = Main.class.getResourceAsStream(watchListPath);
                ignoreListUri = Main.class.getResource(ignoreListPath).toURI();
                watchListUri = Main.class.getResource(watchListPath).toURI();
                ignoreListFile = new File(ignoreListUri);
                watchListFile = new File(watchListUri);
                ignoreOIS = new ObjectInputStream(ignoreListStream);
                watchOIS = new ObjectInputStream(watchListStream);
                watchList = (LinkedList<WI_Item>)watchOIS.readObject();
                ignoreList = (LinkedList<WI_Item>)ignoreOIS.readObject();
                ignoreOIS.close();
                watchOIS.close();
                ignoreListStream.close();
                watchListStream.close();
            } catch(Exception e){
                e.printStackTrace();
                JOptionPane.showMessageDialog(new JFrame(),
                    "DataWriter Error " + e.getMessage(),
                    "DataWriter Error " + e.getMessage(),
                    JOptionPane.INFORMATION_MESSAGE);
        public void insertIntoWatch(String part_no, String description){
            insertIntoWatch(new WI_Item(part_no, description));
        public void insertIntoIgnore(String part_no, String description){
            insertIntoIgnore(new WI_Item(part_no, description));
        public void insertIntoWatch(WI_Item item){
            System.out.println("Old WatchList: " + watchList);
            watchList.add(item);
            System.out.println("New WatchList: " + watchList);
            setWatchList(watchList);
            System.out.println("Same WatchList: " + watchList);
        public void insertIntoIgnore(WI_Item item){
            System.out.println("Old ignoreList: " + ignoreList);
            ignoreList.add(item);
            System.out.println("New ignoreList: " + ignoreList);
            setIgnoreList(ignoreList);
            System.out.println("Same IgnoreList: " + ignoreList);
        public void removeFromWatch(String part_no){
            WI_Item itemToDelete = null;
            for(WI_Item item : getWatchList()){
                if(item.getPart_no().equals(part_no)){
                    itemToDelete = item;
            removeFromWatch(itemToDelete);
        public void removeFromIgnore(String part_no){
            WI_Item itemToDelete = null;
            for(WI_Item item : getIgnoreList()){
                if(item.getPart_no().equals(part_no)){
                    itemToDelete = item;
            removeFromIgnore(itemToDelete);
        public void removeFromWatch(WI_Item item){
            System.out.println("Old WatchList: " + getWatchPartNos());
            watchList.remove(item);
            System.out.println("New WatchList: " + getWatchPartNos());
            setWatchList(watchList);
            System.out.println("Same WatchList: " + getWatchPartNos());
        public void removeFromIgnore(WI_Item item){
            System.out.println("Old IgnoreList: " + getIgnorePartNos());
            ignoreList.remove(item);
            System.out.println("New IgnoreList: " + getIgnorePartNos());
            setIgnoreList(ignoreList);
            System.out.println("Same IgnoreList: " + getIgnorePartNos());
        public LinkedList<String> getWatchPartNos(){
            System.out.println("Get Watch Part Nos " + getWatchList());
            LinkedList<String> results = new LinkedList<String>();
            for(WI_Item item : getWatchList()){
                results.add(item.getPart_no());
            return results;
        public LinkedList<String> getIgnorePartNos(){
            System.out.println("Get Ignore Part Nos " + getIgnoreList());
            LinkedList<String> results = new LinkedList<String>();
            for(WI_Item item : getIgnoreList()){
                results.add(item.getPart_no());
            return results;
        public LinkedList<String> getBothPartNos(){
            LinkedList<String> results = new LinkedList<String>();
            for(String s : getWatchPartNos()){
                results.add(s);
            for(String s : getIgnorePartNos()){
                results.add(s);
            System.out.println("Returning " + results);
            return results;
        public LinkedList<WI_Item> getIgnoreList(){
            return ignoreList;
        public LinkedList<WI_Item> getWatchList(){
            return watchList;
        public LinkedList<WI_Item> getBoth(){
            LinkedList<WI_Item> both = new LinkedList<WI_Item>();
            for(WI_Item item : getWatchList()){
                both.add(item);
            for(WI_Item item : getIgnoreList()){
                both.add(item);
            return both;
        public void setWatchList(LinkedList<WI_Item> watchList){
            FileOutputStream fos = null;
            ObjectOutputStream watchOOS = null;
            try{
                fos = new FileOutputStream(watchListFile);
                watchOOS = new ObjectOutputStream(fos);
                watchOOS.writeObject(watchList);
                watchOOS.close();
                fos.close();
            } catch(Exception e){
                JOptionPane.showMessageDialog(new JFrame(),
                    "Error writing watch list " + e.getMessage(),
                    "Error writing watch list " + e.getMessage(),
                    JOptionPane.INFORMATION_MESSAGE);
        public void setIgnoreList(LinkedList<WI_Item> ignoreList){
            FileOutputStream fos = null;
            ObjectOutputStream ignoreOOS = null;
            try{
                fos = new FileOutputStream(ignoreListFile);
                ignoreOOS = new ObjectOutputStream(fos);
                ignoreOOS.writeObject(ignoreList);
                ignoreOOS.close();
                fos.close();
            } catch(Exception e){
                JOptionPane.showMessageDialog(new JFrame(),
                    "Error writing ignore list " + e.getMessage(),
                    "Error writing ignore list " + e.getMessage(),
                    JOptionPane.INFORMATION_MESSAGE);
    }

  • POF Serialization Issue (HashMap)

    Hi.
    It looks like the following use, produced EOFException error in java serialization.
    I couldn't find any clear documentation regarding whether readMap (java) should be paired to readDictionary (.net) for pof, but currently by using a type pair of Dictionary<String, Double> in .NET side and HashMap<String, Double> in java we started getting the error below.
    Is it a wrong use? Should Hashtable be used instead? Or some other collection? Please advise.
    Error: An exception occurred while decoding a Message for Service=Proxy:ExtendTcpProxyService:TcpAcceptor received from: TcpConnection(Id={CUT}, Open=true, Member(Id=0, Timestamp=3981-11-15 06:40:05.166, Address=10.111.12.147:0, MachineId=0, Location={CUT}, Role=.NET RTC client), {CUT}): java.io.EOFException
         at com.tangosol.io.nio.ByteBufferReadBuffer$ByteBufferInput.readByte(ByteBufferReadBuffer.java:340)
         at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readUnsignedByte(AbstractReadBuffer.java:435)
         at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readPackedInt(AbstractReadBuffer.java:560)
         at com.tangosol.io.MultiBufferReadBuffer$MultiBufferInput.readPackedInt(MultiBufferReadBuffer.java:683)
         at com.tangosol.io.pof.PofBufferReader.readAsUniformObject(PofBufferReader.java:3344)
         at com.tangosol.io.pof.PofBufferReader.readMap(PofBufferReader.java:2537)
    Java Pof where it occurs:
    writer.writeMap(40, getMyDict());
    setMyDict((HashMap<String, Double>)reader.readMap(40, new HashMap<String, Double>()));
         public HashMap<String, Double> getMyDict() {
              return myDict;
         public void setMyDict(HashMap<String, Double> MyDict) {
              this.myDict = MyDict;
    .NET Pof:
    writer.WriteDictionary<String, Double>(40, MyDict);
    MyDict = ((Dictionary<String, Double>)reader.ReadDictionary<String, Double>(40, new Dictionary<String, Double>()));
    public Dictionary<String, Double> MyDict
    get { return myDict; }
    set { myDict = value; }
    Notes: If it helps, 40 is the last pof index on that object. The error appears sometime, not constantly based on data.

    AntonZ wrote:
    Hi.
    It looks like the following use, produced EOFException error in java serialization.
    I couldn't find any clear documentation regarding whether readMap (java) should be paired to readDictionary (.net) for pof, but currently by using a type pair of Dictionary<String, Double> in .NET side and HashMap<String, Double> in java we started getting the error below.
    Is it a wrong use? Should Hashtable be used instead? Or some other collection? Please advise.
    Error: An exception occurred while decoding a Message for Service=Proxy:ExtendTcpProxyService:TcpAcceptor received from: TcpConnection(Id={CUT}, Open=true, Member(Id=0, Timestamp=3981-11-15 06:40:05.166, Address=10.111.12.147:0, MachineId=0, Location={CUT}, Role=.NET RTC client), {CUT}): java.io.EOFException
         at com.tangosol.io.nio.ByteBufferReadBuffer$ByteBufferInput.readByte(ByteBufferReadBuffer.java:340)
         at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readUnsignedByte(AbstractReadBuffer.java:435)
         at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readPackedInt(AbstractReadBuffer.java:560)
         at com.tangosol.io.MultiBufferReadBuffer$MultiBufferInput.readPackedInt(MultiBufferReadBuffer.java:683)
         at com.tangosol.io.pof.PofBufferReader.readAsUniformObject(PofBufferReader.java:3344)
         at com.tangosol.io.pof.PofBufferReader.readMap(PofBufferReader.java:2537)
    Java Pof where it occurs:
    writer.writeMap(40, getMyDict());
    setMyDict((HashMap<String, Double>)reader.readMap(40, new HashMap<String, Double>()));
         public HashMap<String, Double> getMyDict() {
              return myDict;
         public void setMyDict(HashMap<String, Double> MyDict) {
              this.myDict = MyDict;
    .NET Pof:
    writer.WriteDictionary<String, Double>(40, MyDict);
    MyDict = ((Dictionary<String, Double>)reader.ReadDictionary<String, Double>(40, new Dictionary<String, Double>()));
    public Dictionary<String, Double> MyDict
    get { return myDict; }
    set { myDict = value; }
    Notes: If it helps, 40 is the last pof index on that object. The error appears sometime, not constantly based on data.How is the class containing the map serialized? Is it a PortableObject or do you use a PofSerializer for serializing it? If you use a PofSerializer, please verify that you did not forget the writeRemainder / readRemainder calls from the end of the serialize/deserialize methods.
    Best regards,
    Robert

  • Type Safe enum with Serializable issue

    The following code is copied from www.javapractices.com
    public final class SimpleSuit {
      public static final SimpleSuit CLUBS = new SimpleSuit ("Clubs");
      public static final SimpleSuit DIAMONDS = new SimpleSuit ("Diamonds");
      public static final SimpleSuit HEARTS = new SimpleSuit ("Hearts");
      public static final SimpleSuit SPADES = new SimpleSuit ("Spades");
      public String toString() {
        return fName;
      private final String fName;
      private SimpleSuit(String aName) {
        fName = aName;
    }It is known to be typesafe and able to perform object equality.
    Eg:
    SimpleSuit s = SimpleSuit.SPADES;
    if (s == SimpleSuit.SPASES)
    ..Thus, it is simple and fast enough by object equality comparison.
    But if I implement SimpleSuit with java.io.Serializable and send it over the network, of course that would become a totally new objects, therefore I can't usr object equality anymore. Any solution to make it work over Serialization?
    Thanks,
    Jax

    A serializable class may provide a 'readResolve' method. This is used to "designate a replacement when an instance of it is read".
    A common approach with enums is to provide a unique identifier (e.g, a string name, or integer id). The enum class can then provide a readResolve method which determines the correct replacement instance based on this id.
    An example of this is also available on the javapractices site you mentioned:
    http://www.javapractices.com/Topic1.cjp

  • The Problem in serialization.

    The serialization issue is a trivial one at the moment. However the threat of a version change is imminent considering the next release of JDK 6 "Mustang" may have considerable improvements especially on the Swing side. Therefore, I strongly encourage you to write your own code to persist the tree data into a file. Such a logic is much preferable as it will over-come the issues with serialization.
    The main problem with a version change is that every serializable class uses a special random number stored in a private static field called serialVersionUID. So when the serializable class is serialized, this number is also persisted to the serialized form.
    When the object is de-serialized, the number is also deserialized. Java checks the de-serialized number against the serialVersionUID field of the class and verifies if the two match. If they do, it means that the deserialized data is in the right format of the class. If they differ, a InvalidClassException is thrown. Every new version of the class changes this unique number. Hence an object serialized with an older version of the class will not be allowed to be de-serialized by a new version of that class and vice-versa.
    This mechanism allows developers to version their new releases and ensures that serialization and deserialization operations remain consistent across multiple-versions and prevent invalid state of the object.

    The serialization issue is a trivial one at the moment. However the threat of a version change is imminent considering the next release of JDK 6 "Mustang" may have considerable improvements especially on the Swing side.Don't make statements like this unless you know what you're talking about. Do you know that Sun's JDK release policies prevent them from doing that in the middle of a release? and that they haven't done such a thing in 13 years? Do you have any actual evidence that they are going to change serialVersionUIDs in the middle of a release?
    Therefore, I strongly encourage you to write your own code to persist the tree data into a file.
    I would strongly encourage developers not to use Serialization on Swing objects at all, which curiously enough is what the Javadoc has been saying for ten years. You should use java.beans.XMLEncoder for this. That's what it is for.
    Such a logic is much preferable as it will over-come the issues with serialization.Home-grown code is never preferable to what is provided in the JDK.
    The main problem with a version change is that every serializable class uses a special random number stored in a private static field called serialVersionUID.That's not a 'problem'. That's part of the solution.
    Every new version of the class changes this unique number.Only if you don't declare your own static final long serialVersionUID.
    This mechanism allows developers to version their new releases and ensures that serialization and deserialization operations remain consistent across multiple-versions and prevent invalid state of the object.Exactly. I suggest you read the Versioning section of the Serialization specification before posting again on this topic, and also read up on Long Term Persistence in Java Beans. You have much of this information back to front, and you don't appear to have heard of either defining your own serialVersionUID or Long Term Persistence.
    And your claim that Sun will change serialVersionUIDs in the middle of Java release 6 is just ludicrous.

  • ReportEngine (XI-R3.1) is not Serializable and fails on a wbelogic cluster

    In our J2EE web-application we store <b><code>com.businessobjects.rebean.wi.ReportEngines</code></b> in the <b><code>HttpSession</code></b> as recommended.
    <br>From this instance we retrieve the appropriate report "<b><code>ReportEngine</code></b>" instance based on the storeagetoken.
    <br>We retrieve the ReportEngine instance by:
    <br>
    <br><b><code>ReportEngine reportEngine = reportEngines.getServiceFromStorageToken(strEntry);</code></b>     
    <br>
    <br>The above works in a non-clustered single application server environment (weblogic-10).
    <br>
    <br>But in a cluster, if the storage-token and "ReportEngines" are created in one Node, then we get a <b><code>null</code></b> when we try retrieving the <b><code>ReportEngine</code></b> in another node.
    <br>
    <br>We dug in and discovered out that while  "<b><code>ReportEngines</code></b>" implements Serializable  "<b><code>ReportEngine</code></b>" does not implement the same.
    <br>
    <br>We noticed that the .NET SDK implementation of "<b><code>ReportEngine</code></b>" is serializable though (unlike Java).
    <br>
    <br>Does anyone know of any patch for the above.
    <br>
    <br>We have worked around by serializing the <b><code>DocumentInstance</code></b>in the DB and retrieve this using teh storage-token itself as a key.
    <br>Obviously, we use this route only as a workaround (only when we encounter a <b><code>null</code></b> <b><code>ReportEngine</code></b>,due the cluster node switches).
    <br>
    <br>----
    <br>There are other ways to get it to work without our workaround. One is by getting the load-balancer to retain the same weblogic node all thru the user-session (and in this case it works), but he cannot use that kind of a setup in our production environment.
    <br>We have to have the loadbalancer distributing requests to all nodes in the cluster regadless to the session.
    <br>--
    <br>
    <br>Would be glad to know of a SDK-patch for the above serialization issue.
    Edited by: savincent on Aug 11, 2010 9:56 PM
    Edited by: savincent on Aug 11, 2010 10:24 PM

    There's no patch for that in the XI 3.1 and previous product line.
    Your workaround sounds nice, i.e., sticky sessions for the session, and retrieve from token for failover.  When retrieving from the storage token, it serializes the report back from the WebI Report Server.
    Sincerely,
    Ted Ueda

  • Bug in Java objects not serializable

    I plan to use the latest version TopLink 10.1.3.1.0 with Oracle Database 10g (10.2.x).
    Do I still have to use the “Type Conversion” mapping as I had to do in order to address the reported non-serializable bug exiting in TopLink (9.0.4.5). See the link for the bug description:
    http://www.oracle.com/technology/documentation/1012_solaris/relnotes.1012/relnotes/toplink.htm#CEGEBDEG
    My Java object instance variable is defined as java.sql.Timestamp and the corresponding data type on the Oracle DB is defined as TIMESTAMP(6). Can I use the direct-to-field mapping from now on with new TopLink 10.1.3.1.0 without the serializable issue? If I still have to use the Type Conversion mapping, please help provide some detail about the mapping.
    Many thanks for any help.

    From what I can understand from your reply, I can use the direct-to-field mapping for Java class attribute of java.sql.Timestamp to the Oracle DB 10.2.x data type of TIMESTAMP(6) without any issue of not serializable. Please confirm. Many thanks!
    By the way, I am having the same issue (Java objects not serializable) with Oracle DB 10.1.x when I use the direct-to-field mapping. It seems to me that this is more than the Oracle 9i JDBC driver.
    If I have to do this with TopLink 10.1.3.1.0 + Oracle 10.2.x, I plan to use the Type Conversion with:
    Java class attribute: java.sql.Timestamp
    DB data type: oracle.sql.TIMESTAMP
    Is this the proper way to do it? Please confirm.

  • Serialializing non serializable objects

    Hi guys,
    I have to serialize (and then send through socket) a class which implements java.io.Serializable. This class also has some reference with other classes, which should be serialized togheter.
    But when I run the main class (which only serializes) , java.io.NotSerializableException is thrown.
    How do I recognize if a class is effectively serializable?
    How do I serialize too even with non-serializable objects?
    (I need all these objects)
    note : In the class I have only put the marker "implements java.io.Serializable",should I have to do somenthing else?
    Thank You for your great help!

    Hi guys,
    I have to serialize (and then send through socket)a
    class which implements java.io.Serializable. This
    class also has some reference with other classes,
    which should be serialized togheter.
    But when I run the main class (which onlyserializes)
    , java.io.NotSerializableException is thrown.
    How do I recognize if a class is effectively
    serializable?
    How do I serialize too even with non-serializable
    objects?
    (I need all these objects)
    note : In the class I have only put the marker
    "implements java.io.Serializable",should I have todo
    somenthing else?
    Thank You for your great help!I wish there was a utility that could inspect a
    Class, traverse its containment tree and flag
    serializability issues. This could be more powerful
    if generics are used.
    To solve your problem besides the marker, implement
    methods writeObject and readObject and serializing
    the contained object that is not serializable by
    hand. For example if your class is X which contains Y
    that is not serializable then you need to serialize
    fields Y in X.writeObject and construct a Y object in
    X.readObject:
    class Y { // not serializable and you cannot modify
    it
    int i;
    int j;
    Y(int i, int j)
    class X implements Serializable {
    String xyz;
    Y y;
    private void writeObject(ObjectOutputStream out)
    throws IOException{
    out.writeObject(xyz);
    out.writeInt(y.getI());
    out.writeInt(y.getJ());
    private void readObject(ObjectInputStream in)
    throws IOException{
    xyz = (String) in.readObject();
    int i = in.readInt();
    int j = in.readInt();
    y = new Y(i, j);Remember to maintain the same order in readObject and
    writeObject.
    Hi guys,
    I have to serialize (and then send through socket)a
    class which implements java.io.Serializable. This
    class also has some reference with other classes,
    which should be serialized togheter.
    But when I run the main class (which onlyserializes)
    , java.io.NotSerializableException is thrown.
    How do I recognize if a class is effectively
    serializable?
    How do I serialize too even with non-serializable
    objects?
    (I need all these objects)
    note : In the class I have only put the marker
    "implements java.io.Serializable",should I have todo
    somenthing else?
    Thank You for your great help!I wish there was a utility that could inspect a
    Class, traverse its containment tree and flag
    serializability issues. This could be more powerful
    if generics are used.
    To solve your problem besides the marker, implement
    methods writeObject and readObject and serializing
    the contained object that is not serializable by
    hand. For example if your class is X which contains Y
    that is not serializable then you need to serialize
    fields Y in X.writeObject and construct a Y object in
    X.readObject:
    class Y { // not serializable and you cannot modify
    it
    int i;
    int j;
    Y(int i, int j)
    class X implements Serializable {
    String xyz;
    Y y;
    private void writeObject(ObjectOutputStream out)
    throws IOException{
    out.writeObject(xyz);
    out.writeInt(y.getI());
    out.writeInt(y.getJ());
    private void readObject(ObjectInputStream in)
    throws IOException{
    xyz = (String) in.readObject();
    int i = in.readInt();
    int j = in.readInt();
    y = new Y(i, j);Remember to maintain the same order in readObject and
    writeObject.

  • EJB/RMI collaboration & design issue

    Hi there,
    I am in the process of migrating a JSP/servlet application to EJB. In
    the current version of the application, I have a Log class which is used
    to output trace & debugging information. One instance of this class is
    instanciated at the application startup and stored in a singleton which
    is referenced all over the application.
    Because I want my application to be distributed and fail-over ready,
    I've decided to move this Log class and a couple of other technical
    services to RMI. When the application starts-up, I instanciate the RMI
    Log class and everytime I use an EJB, I want to pass him the RMI Log
    class interface. But this does not seem to work, I receive a Marshall
    exception.
    What are the different design patterns to make my EJBs aware of my RMI
    classes ?
    Thanks,
    Stephane

    Thanks Joe,
    When I insert the JNDI Log lookup in the EJB instanciation code, it works but
    I want to avoid every EJB instanciation to lookup for the Log service in
    order to make the code faster. That's why I want to look it up only once when
    the application is starting, and after that, to pass the reference of the
    interface to every EJB that I am instanciating. I tried to create a proxy
    class around my Log RMI service, but I still get a Marshal Error when I pass
    the Log interface as a parameter to my EJB:
    java.rmi.MarshalException: CORBA MARSHAL 0[Could not cast logInterface of
    class test.LogServiceProxy to org.omg.CORBA.Object]
    at test._PO_Stub.setLog(_PO_Stub.java:1100)
    at test.CApplication.test(CApplication.java:443)
    at test.CApplication.initApplication(CApplication.java:88)
    at test.InitApp.doGet(InitApp.java:39)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:715)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
    at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155)
    at com.sun.web.core.InvokerServlet.service(InvokerServlet.java:168)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
    at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155)
    at com.sun.web.core.Context.handleRequest(Context.java:414)
    at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:139)
    Is it impossible to pass an interface as a parameter through RMI ? Is it a
    serialization issue ?
    Joe Weder wrote:
    Stephane,
    I added a service like yours to our WL Server. I use a Startup class to
    instantiate the RMI instance and then add it to the JNDI environment. Now
    your beans can lookup the service.
    context.bind(ClientServicesFactory.JNDI_REGNAME, new
    ClientServicesFactoryImpl());
    In doing so I discovered that I had to use java's rmi compiler and
    weblogic's rmi compiler to make the RMI objects accessible to my bean
    instances from within the running server. Maybe this will solve the
    marshalling problem (it sounds familiar).
    rmic -v1.2 -verbose
    com.icsaward.award.common.clientservices.ClientServicesFactoryImpl
    java weblogic.rmic
    com.icsaward.award.common.clientservices.ClientServicesFactoryImpl
    Hope that helps.
    Stephane Louet wrote in message <[email protected]>...
    Hi there,
    I am in the process of migrating a JSP/servlet application to EJB. In
    the current version of the application, I have a Log class which is used
    to output trace & debugging information. One instance of this class is
    instanciated at the application startup and stored in a singleton which
    is referenced all over the application.
    Because I want my application to be distributed and fail-over ready,
    I've decided to move this Log class and a couple of other technical
    services to RMI. When the application starts-up, I instanciate the RMI
    Log class and everytime I use an EJB, I want to pass him the RMI Log
    class interface. But this does not seem to work, I receive a Marshall
    exception.
    What are the different design patterns to make my EJBs aware of my RMI
    classes ?
    Thanks,
    Stephane

Maybe you are looking for

  • Unable to record internal audio with RecordMyDesktop

    In order to record sound and video from my desktop, I installed RecordMyDesktop (https://wiki.archlinux.org/index.php/RecordMyDesktop) and followed the instructions from post #4 and #6 on a thread about "Recording internal audio with alsa and recordm

  • Function Module for CO-PA document creation

    Hi, we need to crate the CO-PA document through program. Is there any funcion module/BAPI available for the same? Scenario here is... We are restricting CO-PA document not to be created at the time of invoice creation. Later some point of time in the

  • Mini HDMI port

    Hi. I have Lenovo yoga thinkpad 12 and suddenly mini HDMI port sopped work. I'm not albe now to duplicate screen to projector. I tried to check bios or control panel, but with no succes. I looked on official graphic driver, but I can't install new dr

  • Can't download music to iPhone

    I'm unable to download music on to my iPhone. I got it back in December and had it hooked up to a different computer. I ended up getting rid of that one so I'm trying to hook it up to a new computer. Went okay. I have previously had an older ipod set

  • Serial number I provided is valid, but a qualifying product is not found on my computer?

    Just purchased Adobe XL Standard, and it is saying the serial number I provided is valid, but a qualifying product is not found on my computer?