Casting an (deserialized) Object as a (custom) subclass.

Haigh,
I'm having trouble casting objects as their subclass.
I'll explain, i have a class that fetches a stored serialized object from a Database.
i can store the objects no problem.
ex. oodb.store(new Machine());
// machine being my custom class that stores information on the running machine (OS,JVM,ip and MAC address etc.)
then when i want to retrive the object
it should work with the method getObjectByID(int idOfObject) which returns an Object
ex. oodb.getObjecyByID(7)
then i create a new instance of machine
Machine computer = (Machine) oodb.getObjectByID(7);
but i get an error saying i cant cast Object (java.lang.Object) as a Machine (ie.iconicaelixia.objects.Machine to be exact)
It worked before!
well a variation of it worked, then i changed the testing class to suit another test.
i've tried the if(Object intanceOf Machine) method aswell, but it never returned true. Eventhough the binary read of the stored object clearly states it is.
Also, on the topic of serialized objects in a database, would it be more effective if my store/fetch methods stored/fetched Class(es) instead of Object(s)?
If so, how would i return a Class?
For Reference here is my Store/Fetch Methods:
public void storeObject(String ClassType,Object ObjectToStore,String indexableInfo)
          try
               indexableInfo = indexableInfo + "$ObjCreated="+new Date().toString();
               if(ClassType==null)
                    ClassType = ObjectToStore.getClass().getName();
               int oID = getAvailableID();
               PreparedStatement ps = nasc.nasc().prepareStatement("Insert into iserv.objects Set OID = ?,Class = ?, Object = ?,Indexable = ? ");
               ps.setInt(1,oID);
               ps.setString(2,ClassType);
               ps.setObject(3,ObjectToStore);
               ps.setString(4,indexableInfo);
               ps.execute();
               ps = null;
          catch (SQLException sqle)
               sqle.printStackTrace();
     public Object getObjectByID(int ObjectID)
          Object rO = null;
          try
               PreparedStatement ps = nasc.nasc().prepareStatement("SELECT OID, OBJECT from iServ.Objects WHERE OID = "+ObjectID);
               ResultSet rs = ps.executeQuery();
               rs.next();
               rO = rs.getObject("OBJECT");
               LastRetrvID = rs.getInt("OID");
               rs.close();
               ps = null;
          catch (SQLException sqle)
               sqle.printStackTrace();
          return rO;
     }Gurbh Míle síle as aon cabhair!

Okay, I'll ask the obvious question:
Why are you trying to store serialized objects? Why not use the usual approach to a relational database, break down the information into attributes and store them in appropriate fields?

Similar Messages

  • Can i Bind more than one Model object to the Custom controller or not

    Hi All, I trying to bind more than one model object to the custom controller, Both the model objects contains same attribute name called ( output). Both model objects created on to top of the BAPI. So when i bind first model object to the custom controller will work fine. When i am trying to bind the second model object to the same controller. This second model object also having the same attribute name called "output" . So it is giving an error of "Duplicate context element "Detail". Rename or uncheck duplicate elements.
    can i assign more than one model object to the single controller or not?
    But in the reference document, it has given that , we can create model object with more than one bapi.So in this case if both the bapis contains any element with the same name will also be problem. Any body give me the solution.
    Initially we have created one custom controller for each model object. But later i realized that, why con't we use same controller for all the model object. Because, the custom controller context is the public context. this context shared across all the view controllers.
    The concept which I am trying to do is right or wrong?

    Hi Vishal,
    of course, you can bind one controler to many models. When the same name occours you can simply RENAME binded node in controler.
    Regards
    Bogdan

  • [java.nio] StreamCorruptedException when deserializing objects

    Hello everybody!
    I made a messaging (chat) program using java.io where all the client-server communication is done by serializing small objects. Now I would like to covert the server side to the NIO concept and I'm already struck. I successfully pass objects to the client and the client deserializes them, but only the first one! When it try to read the second it fails with a StreamCorruptedException.
    Here�s a sample (testing) code. In the server run() method I first serialize a string, then get its byte array from ByteArrayOutputStream and in the loop periodically send this byte array through the channel. On the client side I just read the deserialized object.
    Server run():
    public void run() {
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                oos.writeObject("abcdefgh");
                byte[] objectArr = baos.toByteArray();
                baos.close();
                oos.close();
                ByteBuffer buff = ByteBuffer.allocate(objectArr.length);
                buff.put(objectArr);
                buff.flip();
                while(true) {
                    selector.select();
                    Set keys = selector.selectedKeys();
                    for (Object o : keys) {
                        SelectionKey key = (SelectionKey)o;
                        if (key.isAcceptable()) {
                            ServerSocketChannel server = (ServerSocketChannel) key.channel();
                            clientChannel = server.accept();
                            if (clientChannel == null)
                                continue;
                            clientChannel.configureBlocking(false);
                            SelectionKey clientKey = clientChannel.register(selector, SelectionKey.OP_WRITE);
                        } else if (key.isWritable()) {
                            SocketChannel client = (SocketChannel) key.channel();
                            if (buff.hasRemaining()) {
                                client.write(buff);
                            } else {
                                buff.clear();
                                buff.put(objectArr);
                                buff.flip();
                    try {
                        Thread.currentThread().sleep(2000);
                    } catch (InterruptedException e) {
                        return;
            } catch (IOException e) {
                e.printStackTrace();
        }Client run():
    public void run() {
            try {
                soc = new Socket("localhost", 4000);
                ObjectInputStream ois = new ObjectInputStream(soc.getInputStream());
                while(true) {
                    Object d = ois.readObject();
                    System.out.println("data = " + d.toString());
            } catch (Exception ex) {
                ex.printStackTrace();
        }At the second read I get a StreamCorruptedException.
    Apart from this I would like some hints in how to implement the application with NIO. For example how can I tell the objects apart on the client side � should I send every time a byte array before the object, which tells the length of the next coming object? This is probably not a 100% bulletproof solution and presents additional data transfer?
    Than you in advance!

    OK, I found a solution but I don't like it, because I don't understand it.
    The ObjectOutputStream adds a header (4 bytes) to the stream - if I send the array with those four bytes I get an StreamCorruptedException. If I send the array without the header I also get a StreamCorruptedException: "invalid stream header".
    If I reconstruct the object, by calling ObjectOutputStream.writeObject() and get it's byte array from ByteArrayOutputStream.toByteArray(), every time I have to fill the ByteBuffer, then it works.
    Here's the modified sending block, for the above example:
    } else if (key.isWritable()) {
                            SocketChannel client = (SocketChannel) key.channel();
                            if (buff.hasRemaining()) {
                                client.write(buff);
                            } else {
                                //* ---- added code ---------
                                baos.reset();
                                oos.writeObject("abcdefgh");
                                objectArr = baos.toByteArray();
                                buff.clear();
                                buff.put(objectArr);
                                buff.flip();
                        }   I really don't understand why I have to write the object in the object stream every time. I used ObjectOS and ByteArrayOS, to get the object byte array and then I thought I could forget about those streams and use this array to fill the ByteBuffer. What changes if I send the object through this process with every iteration (and how this harms speed - it's like sending everything twice)? If someone would explain this to me I would appreciate it much.

  • Services for object for a custom document

    Hi everyone,
    We have a custom transaction to create a custom document called enquiry. Upon saving, the document number will be generated and stored in a table. I would like to add the functionality of Services for Object in the transaction to be able to attach documents to the enquiry. I would like to ask if it is possible to create a business object for this custom document to be able to utilize the Services for Object functionality.
    Thanks!
    Eric

    you can choose to create BO for this or simply have a another identifier for this object and youc an use class OT to upload documents to BDS.
    all you need is call of this FM whicih will automatically put the icon for GOS
    SWU_OBJECT_PUBLISH
    alternatively you can use class cl_gos_manager
    Raja

  • Get / Cast a Java Object

    Does anybody know how to get (or Cast) a Java Object returned from a Java method call ?
    Example:
    <cfset someList = object1.method1(someString, JavaCast("float",someNumber),...)>
    This method returns a list of Java object of type "Object2". ie. it returns List<Object2>
    Now I attempted to loop thru each objects from the returned list, and invoke some method on them, using code similar to below,
    <cfset var="#someList[index]#"/>
    but ColdFusion does not seem to understand the object "var" as Java "Object2". Is there any way I can cast the "var" to "Object2"?
    Thanks in advance.
    Xiaoling

    "var" is a reserved keyword! You can initialize variables with "var" in the beginning of a component, but do not use it as a variables name:
    <cfset var someVar = "#someList[index]#">

  • Casting timezone class object to Simpletimezone class object

    When i try to cast timezone class object to a simpletimezone object it throws "java.lang.classcastexception" when i use J2re 1.4.2_06 while in J2re1.3 it works fine .
    I am unable to understand this , can anybody help me out in this regard.
    thanks
    Lokesh

    I agree with all
    but try this out
    SimpleTimeZone stz = (SimpleTimeZone)
    ne) TimeZone.getTimeZone(id);Nothing in the specification says that
    TimeZone.getTimeZone(id) returns an object that is a
    SimpleTimeZone only that it is a TimeZone. It might
    happen to also be a SimpleTimeZone but nothing in the
    specifications says that it is.
    Above statement throws classcast exception in
    in jre1.4.2 but not in Jre1.3 and lower versions
    ........ remember TimeZone is base class and
    SimpleTimeZone is sub class.If this is correct then in 1.3 it just happens to
    return SimpleTimeZone object but nothing in the spec
    says you can rely on this. You are relying on an
    undocumented feature! Always a bad idea.
    So wht has changed in the 2 runtimeenvironments.
    Retorical?Hi,
    sabre150 thanx a lot , u are right in earlier versions TimeZone.getTimeZone(id) was returning SimpleTimeZone object but in J2re 1.4.2 it returns sun.util.calendar.ZoneInfo object and hence the class cast exception was happening.
    AND BELLYRIPPER , u were theoretically right , i was asking something that was happening in practical , so u better try out things and then come up with reasoning rather than just repeating theoretical things and expecting others to accept them blindly.
    Anyway thanx a lot for the help.

  • Properly binding an object to a custom component.

    I am apparently not doing this. What am I missing to properly
    bind an
    object from a repeater looping over an array of object to the
    custom
    component called in the repeater?
    <mx:Repeater
    id="dayCells"
    dataProvider="{days}"
    startingIndex="{weekRows.currentItem}"
    count="7">
    <mx:GridItem
    width="14%"
    borderColor="black"
    borderThickness="1"
    borderStyle="solid">
    <mx:Label
    text="{dayCells.currentItem.formatedDate}" />
    <ian:dayFormat2
    drawData="{dayCells.currentItem as drawDay}"
    test="{dayCells.currentItem.formatedDate}" />
    </mx:GridItem>
    </mx:Repeater>
    {days} is an array of drawDate.as objects returned with a
    remoteObject.
    I can correctly bind properties of these drawDate objects in
    the
    lable and the test property of the dayFormat2
    customComponent. But I
    can NOT correctly bind the entire object over to dayFormat2.
    What am I
    missing?
    My current version of dayFormat2.mxml, I have tried several
    alternatives
    for this file.
    ?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%">
    <mx:Script>
    <![CDATA[
    import drawDay;
    //Define public variables
    [Bindable]
    public var drawData:drawDay;
    [Bindable]
    public var test:String;
    ]]>
    </mx:Script>
    <mx:DateFormatter id="dayNum" formatString="DD" />
    <mx:HBox
    backgroundColor="0x002649"
    width="100%"
    horizontalAlign="right">
    <mx:Label
    text="{test}"
    color="white" />
    <mx:HBox
    backgroundColor="0xAF1E2D"
    horizontalAlign="center">
    <mx:Label
    text="{dayNum.format(drawData.date)}"
    color="white" />
    </mx:HBox>
    </mx:HBox>
    <mx:Label text="foobar" />
    </mx:VBox>
    The first label bound to the test String works correctly. The
    second
    label bound to the drawData drawDay object date property does
    not work
    correctly.
    What is the proper way to bind this object?

    I have struggled with this all day and made no headway. The
    only
    strange thing I get is with this line:
    <mx:Label text="{dayCells.currentItem.toString()}" />
    outputs [object Object]
    Not the expected string from this drawDay.as function.
    // toString()
    public function toString():String
    return "Date: " + formatedDate;
    Ian Skinner wrote:
    > I am apparently not doing this. What am I missing to
    properly bind an
    > object from a repeater looping over an array of object
    to the custom
    > component called in the repeater?
    >
    > <mx:Repeater
    > id="dayCells"
    > dataProvider="{days}"
    > startingIndex="{weekRows.currentItem}"
    > count="7">
    > <mx:GridItem
    > width="14%"
    > borderColor="black"
    > borderThickness="1"
    > borderStyle="solid">
    > <mx:Label
    > text="{dayCells.currentItem.formatedDate}" />
    > <ian:dayFormat2
    > drawData="{dayCells.currentItem as drawDay}"
    > test="{dayCells.currentItem.formatedDate}" />
    > </mx:GridItem>
    > </mx:Repeater>
    >
    > {days} is an array of drawDate.as objects returned with
    a remoteObject.
    > I can correctly bind properties of these drawDate
    objects in the lable
    > and the test property of the dayFormat2 customComponent.
    But I can NOT
    > correctly bind the entire object over to dayFormat2.
    What am I missing?
    >
    > My current version of dayFormat2.mxml, I have tried
    several alternatives
    > for this file.
    >
    > ?xml version="1.0" encoding="utf-8"?>
    > <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%">
    > <mx:Script>
    > <![CDATA[
    > import drawDay;
    >
    > //Define public variables
    > [Bindable]
    > public var drawData:drawDay;
    >
    > [Bindable]
    > public var test:String;
    > ]]>
    > </mx:Script>
    >
    > <mx:DateFormatter id="dayNum" formatString="DD" />
    >
    > <mx:HBox
    > backgroundColor="0x002649"
    > width="100%"
    > horizontalAlign="right">
    > <mx:Label
    > text="{test}"
    > color="white" />
    > <mx:HBox
    > backgroundColor="0xAF1E2D"
    > horizontalAlign="center">
    > <mx:Label
    > text="{dayNum.format(drawData.date)}"
    > color="white" />
    > </mx:HBox>
    > </mx:HBox>
    >
    > <mx:Label text="foobar" />
    > </mx:VBox>
    >
    > The first label bound to the test String works
    correctly. The second
    > label bound to the drawData drawDay object date property
    does not work
    > correctly.
    >
    > What is the proper way to bind this object?

  • Problems deserializing objects with Microsoft VM

    I am getting a 30 second delay when deserializing objects: using Java 1.1.8 ObjectOutputStream.defaultReadObject() causes a 30 second delay. This only happens on Internet Explorer using the Microsoft Virtual Machine.Any ideas what's causing this delay?

    HERE'S THE CODE ..
    URLConnection con = servlet.openConnection();
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setUseCaches(false);
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    ObjectOutputStream out = new ObjectOutputStream(SecurityToolkit.openOutputStream(con));
    int numObjects = objs.length;
    for (int x = 0; x < numObjects; x++) {
    out.writeObject(objs[x]);
    out.flush();
    out.close();
    InputStream inStream = SecurityToolkit.openInputStream(con);
    ObjectInputStream in = new ObjectInputStream(inStream);
    return in;
    So .. this is the ObjectInputStream returned and objects are read off this stream. But reading hangs for 30 seconds and then starts reading again.

  • JMS getObject() Error deserializing object for client

    I am using WL6.1 and having a problem deserializing an object for a
              client that doesn't have access to the corresponding implementation
              object in its CLASSPATH (it only deals with the interface). From
              previous posts, I read that upgrading to SP3 would fix this issue, but
              I am still having this problem on both Solaris and Windows using SP3.
              If I modify the client CLASSPATH to include the Server-side JAR file
              that contains the implementation class, I don't have the problem and I
              can successfully perform getObject() and deserialize the object. The
              following is the code for the client:
              public void onMessage(Message msg)
              String msgText;
              if(msg instanceof ObjectMessage)
              try
              ObjectMessage objMsg = (ObjectMessage) msg;
              ActivityCreationEvent msgEvent =
              (ActivityCreationEvent) objMsg.getObject();
              System.out.println("Got a creation event");
              catch(Exception ex)
              System.out.println("Error getting JMS message:" + ex);
              ex.printStackTrace();
              the following is the code for the server:
              objMsg = tSess.createObjectMessage(null);
              ActivityCreationEvent createEvent=new ActivityCreationEventImpl();
              objMsg.setObject(createEvent);
              tPublisher.publish(objMsg);
              and the following is the client stack trace:
              Error getting JMS message:weblogic.jms.common.JMSException: Error
              deserializing object
              weblogic.jms.common.JMSException: Error deserializing object
              at weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.java:141)
              at com.test.producer.tck.CreateProducerByValue.onMessage(CreateProducerByValue.java:566)
              at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:1865)
              at weblogic.jms.client.JMSSession.execute(JMSSession.java:1819)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              at weblogic.kernel.Kernel.execute(Kernel.java:257)
              at weblogic.kernel.Kernel.execute(Kernel.java:269)
              ----------- Linked Exception -----------
              at weblogic.jms.client.JMSSession.pushMessage(JMSSession.java:1733)
              at weblogic.jms.client.JMSSession.invoke(JMSSession.java:2075)
              at weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.java:510)
              at weblogic.jms.dispatcher.DispatcherImpl.dispatchAsync(DispatcherImpl.java:149)
              at weblogic.jms.dispatcher.DispatcherImpl.dispatchOneWay(DispatcherImpl.java:429)
              at weblogic.jms.dispatcher.DispatcherImpl_WLSkel.invoke(Unknown
              Source)
              at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:305)
              at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:274)
              at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              java.lang.ClassNotFoundException:
              com.test.activity.ri.ActivityCreationEventImpl
              at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:183)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:281)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:190)
              at weblogic.jms.common.ObjectMessageImpl$ObjectInputStream2.resolveClass(ObjectMessageImpl.java:277)
              at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:913)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:361)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
              at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1181)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:381)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
              at weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.java:127)
              at com.test.producer.tck.CreateProducerByValue.onMessage(CreateProducerByValue.java:566)
              at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:1865)
              at weblogic.jms.client.JMSSession.execute(JMSSession.java:1819)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              at weblogic.kernel.Kernel.execute(Kernel.java:257)
              at weblogic.kernel.Kernel.execute(Kernel.java:269)
              at weblogic.jms.client.JMSSession.pushMessage(JMSSession.java:1733)
              at weblogic.jms.client.JMSSession.invoke(JMSSession.java:2075)
              at weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.java:510)
              at weblogic.jms.dispatcher.DispatcherImpl.dispatchAsync(DispatcherImpl.java:149)
              at weblogic.jms.dispatcher.DispatcherImpl.dispatchOneWay(DispatcherImpl.java:429)
              at weblogic.jms.dispatcher.DispatcherImpl_WLSkel.invoke(Unknown
              Source)
              at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:305)
              at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:274)
              at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              The client doesn't need to have access to the implementation class for
              any other aspect of the code, and I would like to keep it that way.
              Does anyone have information as to the cause of the problem and a
              solution?
              Thanks in advance
              

    Hi James,
              Just having the interface is not sufficient, as the JVM must be able to
              find the implementation class of an object in order to unserialize it - this is not a WebLogic
              thing, it is a java thing. Either package the required class in the .ear that contains
              the MDB or put it in your classpath.
              Tom
              James J wrote:
              > I am using WL6.1 and having a problem deserializing an object for a
              > client that doesn't have access to the corresponding implementation
              > object in its CLASSPATH (it only deals with the interface). From
              > previous posts, I read that upgrading to SP3 would fix this issue, but
              > I am still having this problem on both Solaris and Windows using SP3.
              > If I modify the client CLASSPATH to include the Server-side JAR file
              > that contains the implementation class, I don't have the problem and I
              > can successfully perform getObject() and deserialize the object. The
              > following is the code for the client:
              >
              > public void onMessage(Message msg)
              > {
              > String msgText;
              >
              > if(msg instanceof ObjectMessage)
              > {
              > try
              > {
              > ObjectMessage objMsg = (ObjectMessage) msg;
              > ActivityCreationEvent msgEvent =
              > (ActivityCreationEvent) objMsg.getObject();
              > System.out.println("Got a creation event");
              > }
              > catch(Exception ex)
              > {
              > System.out.println("Error getting JMS message:" + ex);
              > ex.printStackTrace();
              > }
              > }
              > }
              >
              > the following is the code for the server:
              >
              > objMsg = tSess.createObjectMessage(null);
              > ActivityCreationEvent createEvent=new ActivityCreationEventImpl();
              > objMsg.setObject(createEvent);
              > tPublisher.publish(objMsg);
              >
              > and the following is the client stack trace:
              >
              > Error getting JMS message:weblogic.jms.common.JMSException: Error
              > deserializing object
              > weblogic.jms.common.JMSException: Error deserializing object
              > at weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.java:141)
              > at com.test.producer.tck.CreateProducerByValue.onMessage(CreateProducerByValue.java:566)
              > at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:1865)
              > at weblogic.jms.client.JMSSession.execute(JMSSession.java:1819)
              > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              > at weblogic.kernel.Kernel.execute(Kernel.java:257)
              > at weblogic.kernel.Kernel.execute(Kernel.java:269)
              > ----------- Linked Exception -----------
              > at weblogic.jms.client.JMSSession.pushMessage(JMSSession.java:1733)
              > at weblogic.jms.client.JMSSession.invoke(JMSSession.java:2075)
              > at weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.java:510)
              > at weblogic.jms.dispatcher.DispatcherImpl.dispatchAsync(DispatcherImpl.java:149)
              > at weblogic.jms.dispatcher.DispatcherImpl.dispatchOneWay(DispatcherImpl.java:429)
              > at weblogic.jms.dispatcher.DispatcherImpl_WLSkel.invoke(Unknown
              > Source)
              > at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:305)
              > at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:274)
              > at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
              > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              > java.lang.ClassNotFoundException:
              > com.test.activity.ri.ActivityCreationEventImpl
              > at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
              > at java.security.AccessController.doPrivileged(Native Method)
              > at java.net.URLClassLoader.findClass(URLClassLoader.java:183)
              > at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
              > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:281)
              > at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
              > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
              > at java.lang.Class.forName0(Native Method)
              > at java.lang.Class.forName(Class.java:190)
              > at weblogic.jms.common.ObjectMessageImpl$ObjectInputStream2.resolveClass(ObjectMessageImpl.java:277)
              > at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:913)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java:361)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
              > at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1181)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java:381)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
              > at weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.java:127)
              > at com.test.producer.tck.CreateProducerByValue.onMessage(CreateProducerByValue.java:566)
              > at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:1865)
              > at weblogic.jms.client.JMSSession.execute(JMSSession.java:1819)
              > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              > at weblogic.kernel.Kernel.execute(Kernel.java:257)
              > at weblogic.kernel.Kernel.execute(Kernel.java:269)
              > at weblogic.jms.client.JMSSession.pushMessage(JMSSession.java:1733)
              > at weblogic.jms.client.JMSSession.invoke(JMSSession.java:2075)
              > at weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.java:510)
              > at weblogic.jms.dispatcher.DispatcherImpl.dispatchAsync(DispatcherImpl.java:149)
              > at weblogic.jms.dispatcher.DispatcherImpl.dispatchOneWay(DispatcherImpl.java:429)
              > at weblogic.jms.dispatcher.DispatcherImpl_WLSkel.invoke(Unknown
              > Source)
              > at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:305)
              > at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:274)
              > at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
              > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >
              > The client doesn't need to have access to the implementation class for
              > any other aspect of the code, and I would like to keep it that way.
              > Does anyone have information as to the cause of the problem and a
              > solution?
              >
              > Thanks in advance
              

  • Error deserializing object

    Hi all,
    I am posting a serializable object as message to MDB Queue and trying to deserialize it in onMessage() method. But, getting below error
    "Exception in onMessage weblogic.jms.common.JMSException: Error deserializing object"
    Here is my onMessage method. Please help me !!!
    public void onMessage(Message msg) {
         ProcessQuery prQuery = null;          
         try {
              ObjectMessage message = (ObjectMessage) msg;
              ProcessQuery pQ = (ProcessQuery) message.getObject();
              prQuery = pQ.execute();
         catch(JMSException ex) {
              System.out.println("Exception in onMessage " + ex);
              ex.printStackTrace();
    ProcessQuery is a serializable object.
    Thanks in advance,
    Anitha

    Hi all,
    I am posting a serializable object as message to MDB Queue and trying to deserialize it in onMessage() method. But, getting below error
    "Exception in onMessage weblogic.jms.common.JMSException: Error deserializing object"
    Here is my onMessage method. Please help me !!!
    public void onMessage(Message msg) {
         ProcessQuery prQuery = null;          
         try {
              ObjectMessage message = (ObjectMessage) msg;
              ProcessQuery pQ = (ProcessQuery) message.getObject();
              prQuery = pQ.execute();
         catch(JMSException ex) {
              System.out.println("Exception in onMessage " + ex);
              ex.printStackTrace();
    ProcessQuery is a serializable object.
    Thanks in advance,
    Anitha

  • Exception while casting int[] to Object[],why?

    if(params.getClass().isArray()) this.params = (Object[])params;
    else this.params = new Object[]{params};
    Now I transfer int[] as "params",and ClassCastException is thrown while casting params to Object[].Since I'm using JDK5.0,why does this happen(the array has been initialized)?

    But how to retrieve every element of this
    Object(Array)? Which type should you cast it to?int[] obviously. Or forget about casting and simply create an Integer[] yourself. a for loop isn't that difficult to write.
    Are you aware that arrays are objects? That's why java doesn't autobox an int[].
    By the way, you should look at these lines of code again:
    if(params.getClass().isArray())
    this.params = (Object[])params;
    else this.params = new Object[]{params};

  • Cast a generic object

    Hi how do you cast a generic object.
    For example I have a class GenericModel which can be either a movie or a director however when I wish to print out any awards that either a director or a movie has, I need to cast a generic variable (gM) to either a movie or a director something like this ...
    try {
    GenericModel d = (Director) gM;
    } if that fails do this{
    GenericModel m = (Movie) gM;
    }catch (Exception e){
    Or any other way that works.
    most appreciated

    Huh? I don't see why you necessarily need to cast anything and certainly not to base types such as Director or Movie.
    Also, the "try and if it fails try something else' pattern can be grossly inefficient.
    I wish to print out any awards that either a director or a movie hasThen your Director and Movie objects both need a printAwards() method; they also need to be sub-classes of a common class (or implement a common interface) that has all the behaviors you want to be in common.
    If that common class is GenericModel, then you would merely do:
      gM.printAwards();If that common class is something else, lets call it FilmObject, then you would need to cast your gM object to execute printAwards(), as so:
    if ( gM instanceof FilmObject )
      ( (FilmObject) gM).printAward();
    }This is really more of a basic Java issue that has nothing to do with JDBC or transactions; if you have followup questions, please ask them in another forum, not here.

  • EOFException when deserializing object in if statement

    Hi,
    I'm a java newbie and I've got a program in which I've got an method to open a serialized file.
    I am running into problems when determining the class of the object to be deserialized.
    When the code is as such everything works fine:
        ObjectInputStream ois;
        protected void open() {
            int returnVal = fc.showOpenDialog(this);
         if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                try {
                 ois = new ObjectInputStream(new FileInputStream(file));     
              frameSeqA72 = (SeqA72) ois.readObject();
              getContentPane().add(frameSeqA72);
              frameSeqA72.setVisible(true);
              ois.close();                                                                                                           
             catch (IOException ioe) {ioe.printStackTrace();}
             catch (ClassNotFoundException cnfe) {}     
        }For some reason I don't understand everything changes when I use an if statement in the code as follows:
        ObjectInputStream ois;
        protected void open() {
            int returnVal = fc.showOpenDialog(this);
         if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                try {
                 ois = new ObjectInputStream(new FileInputStream(file));     
              if (ois.readObject() instanceof SeqA72) {
                  frameSeqA72 = (SeqA72) ois.readObject();
                  getContentPane().add(frameSeqA72);
                  frameSeqA72.setVisible(true);
                  ois.close();                                                    
             catch (IOException ioe) {ioe.printStackTrace();}
             catch (ClassNotFoundException cnfe) {}     
        }An EOFException is thrown when this method is called -
    "EOFException at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1267)..."
    My serialized objects are of different classes so I want to determine the class before casting...so Im using "if (ois.readObject() instanceof SeqA72)".
    Why would the first version work and the second throw an exception?
    Am I going about this in a bad way?
    Casey

    You're calling readObject twice, so it's trying to read two objects.
    Read it once and save a reference in a variable. Use that variable, instead of calling readObject again.

  • Issue casting a HealthRecordItem (AppSpecificDataType) to my custom wrapper type

    I have a HealthVault application built using the 0.15.2016.4015 version of the HealthVault assemblies.
    Since the HealthVault platform has changed since then, causing issues with the Basic datatype, I decided to upgrade the assemblies to latest version - 2.1.0.0.
    Ever since I updated to this version, my application specific data type casting has stopped working.
    I have made sure that the code is as per the guidelines and answers mentioned at https://social.msdn.microsoft.com/Forums/en-US/e7c195c4-3bf3-473e-b8c6-d6d1a1b3cdc3/problem-casting-a-healthrecorditem-to-my-custom-wrapper-type.
    Here is the error message that I keep getting:
    Unable to cast object of type 'Microsoft.Health.ItemTypes.ApplicationSpecific' to type 'CustomNamespace.CustomHealthTypeWrapper'.
    I'm unable to proceed further with my application till this issue is resolved. 
    Any help is highly appreciated.

    Hi,
    Simple way to hide the columns from the Edit or New form is use the PowerShell command.
    $webUrl = Get-SPWeb http://<<servername>>/mysite
    $listName = $web.Lists["<<listName>>"]
    $columnName = $list.Fields["<<column name>>"]
    //If you want to hide the column from Edit Form then Change the ShowInEditForm property and update objects
    $columnName.ShowInEditForm = $false
    //If you want to hide the column from New Form then Change the ShowInNewForm property and update objects
    $columnName.ShowInNewForm=$false
    $columnName.Update()
    $listName.Update()
    $webUrl.Dispose()
    Each column has supports following properties, it can be controlled either using powershell or CSOM or JSOM or server object model.  Even you can controlled while creating the list definition using Visual studio by setting the following
    property.
    ShowInDisplayForm
    Gets or sets a Boolean value that specifies whether the field is displayed in the form for displaying list items.
    ShowInEditForm
    Gets or sets a Boolean value that specifies whether the field is displayed in the form that is used to edit list items.
    ShowInListSettings
    Gets or sets a Boolean value that specifies whether the field is displayed in the page for customizing list settings.
    ShowInNewForm
    Gets or sets a Boolean value that specifies whether the field is displayed in the form that is used to create list items.
    ShowInVersionHistory
    Gets or sets a Boolean value that specifies whether the field is displayed in the page for viewing list item versions.
    ShowInViewForms
    Gets or sets a Boolean value that specifies whether the field is displayed in pages that are used to view list data.
    Please mark it as answered, if your problem resolved or helpful.

  • How to cast an array object to array of string

    * Can someone please tell me why SECTION 3 causes a cast
    * exception?
    * What I am really trying to do is put Strings into a vector and
    * return them as an array of String with a line like:
    *     return (String[])myVector.toArray();
    * How to do this?
    * Thank You!
    public class CastArrayTest
         public static void main(String args[]){
              //SECTION 1: This works
              String[] fruits = {"apple", "banana"};
              Object[] objs = (Object[])fruits;
              String[] foods = (String[])objs;
              for (int i = 0 ; i < foods.length ; i++){
                   System.out.println(foods);
              //SECTION 2: this works too
              Object anObj = new Object();
              String aString = "ok";
              anObj = aString;
              String anotherString = (String)anObj;
              System.out.println("word for single obj is " + anotherString);
              //SECTION 3: this causes cast exception at line
              // String[] strings = (String[])stuff
              Object[] stuff = new Object[2];
              String a = "try";
              String b = "this";
              stuff[0] = a;
              stuff[1] = b;
              String[] strings = (String[])stuff;
              for (int x = 0 ; x < strings.length ; x++){
                   String s = strings[x];
                   System.out.println("the string is " + strings[x]);

    I understand all replies so far, but from my
    understanding, objects are passed by reference No, they're not. Rather, object references are passed by value.
    Object obj = new Object();
    String a = "pass me by reference";
    Object anotherObj = (Object)a; // this explicit cast is not necessary
    String anotherString = (String)anotherObj; // this cast works because the object in question is a String
    There's no passing in that code, so I'm not sure where that even came from. However, that works because it's all legal casting.
    works as I think it should, and does, and futhermore
    String[] cast to Obj[] cast to String[] works also...Because the object you're casting actually is a String[].
    so why not if Obj[] to String[] Because String[] is not a subclass of Object[]. That's just how the language is specified.
    futhermore if they are
    all string...Again, this has no bearing on the type of the array object.
    I saw hot to cast array to String[] and wondered if
    this is real cast or calls the toString method...It's a real cast.
    but most importantly, does this mean if I have a
    vector of Strings and want to get them as an array of
    strings, I have to loop through the Obj[] (or vector)
    and cast each to (String)...just to get them as an
    array of String[]....No, zparticle's code can do that.

Maybe you are looking for

  • Internal Domain names

    I know what a domain name is for the external web, but what forms of words are acceptable to OS X Server for an intranet? I don't want to have to pay to register a domain name acceptable to the rest of the web, I just want something meaningful for my

  • "iPod Service Error" plus other issues

    Hi, I hope someone can help me. My iPod is severely malfunctioning. Sometimes, when I turn it on, the screen pops up with a folder and exclamation point. Sometimes it pops up saying "Connect to iTunes to restore". And sometimes it works fine. I am tr

  • HT5312 I didn't purchase anything with my iTunes account because I forget security question's replies I want your helping. Sincerely

    I didn't purchase anything with my iTunes account because I forget security question's replies I want your helping. Sincerely 

  • Create materialized view as part of refresh group

    Hello, When I create a materialized view in 11g it automatically creates its own refresh group. How can I create the materialized group as part of an existing refresh group? (I know I can drop the individual refresh group and add the mview to the mai

  • Wordpress/CMS help...

    I'm trying to create a Content Management System for my latest site.. basically I have news to be updated all the time on this site, and would like to just use Wordpress as a CMS so all I need to do is post a new story, and it will become to the top