JAXB and ClassCastException

Hi all,
When I try to unmarshal a XML document, I get a ClassCastException. I've listed the details below. I've also searched the forums on this one but can't seem to find any answer (maybe I've missed it somewhere). I appreciate any help or hints anyone can offer.
XMLSchema: OrganizationalUnit.xsd
JAXB Generated classes: OrganizationalUnit.java, OrganizationalUnitType.java etc.
UnmarshallingCode:
JAXBContext jc = JAXBContext.newInstance("com.myproject.unitinfo");
Unmarshaller unmarshaller = jc.createUnmarshaller();
unmarshaller.setValidating(true);
String filename = JOptionPane.showInputDialog("Filename:");
OrganizationalUnit unit = (OrganizationalUnit)unmarshaller.unmarshal(new FileInputStream( filename ) );
System.out.println("Participant ID:" + unit.getUnitID() );The above code generates the following error:
ClassCastException caught.
com.iwise.process.jaxb.unitinfo.impl.OrganizationalUnitImpl
java.lang.ClassCastException: com.iwise.process.jaxb.unitinfo.impl.OrganizationalUnitImpl
     at com.iwise.process.test.TestClient.saveParticipant(TestClient.java:58)
     at com.iwise.process.test.TestClient.main(TestClient.java:33)
TIA, Claire

What was wrong with your package structure? I'm running into a similar problem where one XML doc/schema combo parses great, but another throws the java.lang.ClassCastException.

Similar Messages

  • Install JAXB and JAXP only

    Hi,
    We want to use the funtion of JAXB and JAXP
    but do not want to use the whole java web service
    Can the JAXB and JAXP work separately on JDK1.2/JDK1.3.1
    Jacinle

    The Jaxb directory in jwsdp-1.2 dir has the JAXB implementation.
    The Jaxp directory in jwsdp-1.2 dir has the JAXP implementation.

  • Does BEA WLS 7.0 or 8.1 support JAXB and JAXR?

    Hello
    Does BEA WLS 7.0 or 8.1 support JAXB and JAXR?
    Thanks

    Hi a,
    The short answer is no B or R yet, but stay tuned.
    The somewhat longer story is that we are very much engaged with this
    emerging binding standard to be used inconjuction with and beyond the
    built-in types specified in JAX-RPC 1.1, it should be seen as a
    compelling story for J2EE if JAXB could be used as a mechanism for
    extending type mapping and offer a vendor neutral way to deal with user
    defined types and to easily utilize user types that are developed for
    XML applications in web services.
    Concerning JAXR, I've experimented with SUN's RI using our UDDI server
    and it works fine. As to the arguable merits of JAXR, all I can say is
    that it is part of J2EE 1.4.
    HTHs,
    Bruce
    a wrote:
    >
    Hello
    Does BEA WLS 7.0 or 8.1 support JAXB and JAXR?
    Thanks

  • NegativeArraySizeException and ClassCastException

    Guys,could someone give me a scenario where NegativeArraySizeException and ClassCastException are thrown???

    int myArraySize = -1;
    int[] myArray = new int[myArraySize];
    Object someObject = "foo";
    Integer anInteger = (Integer) someObject;

  • Apache axis, JAX-RPC, JAXR, JAXM, JAX-WS, JAXB, and Metro

    Are all of the following the different APIs for creating web service applicaton?
    Apache axis,
    JAX-RPC,
    JAXR,
    JAXM,
    JAX-WS,
    JAXB, and
    Metro
    --If so, which one(s) are most widely used?
    --If not, what are the differences among them?
    Thanks
    Scott

    I think your are looking for a full web services framework.
    Apache axis --> Is a WS framework. implements jax-rpc. Provides some features on its own
    JAX-RPC --> Is a WS framework specification. Your application servers/axis implement this.
    JAXR --> not an web-service api, rather a web-service registry access api
    JAXM --> Is an api for xml messaging. Your framework provider may use this.
    JAX-WS --> Is jax-rpc 2.0. Your application server provider will give implementation for this. Otherwise you can use xfire/metro as the implementation. Chose this over jax-rpc.
    JAXB, --> Is used for xml-java binding. Jax-ws uses this. But not specific to jax-ws..
    Metro --> Reference implementation for jax-ws.
    All in all jax-rpc, jax-ws and axis2 are three options. go for jax-ws if you do not have any other constraints.As for selcting implementation of jax-ws, if you are working on an app-server (and not on a simple servlet container or without a server), server vendor will provide that. Otherwise look for xfire or metro.

  • WSAD 5, xerces, datasource and classcastexception issue

    I am running into an issue trying to run my code once I upgraded from WDAD 5.0 to WSAD 5.01. I am getting the error below when I try and connect to my DataSource. This all was working fine before I upgraded. It looks like an issue with the xerces.jar file because if I take out the JAXP stuff in the xerces.jar file I work fine. But I need the JAXP stuff because I am doing messaging. Anyone have any ideas?
    [5/22/03 7:02:59:848 CDT] 2ec4c80 SystemOut O 2003.05.22 07:02:59.848--ServerSession(426724481)--Thread[asyncDelivery0,5,main]--Connection(47762586)--TopLink, version:TopLink - 9.0.3 (Build 423)
    2003.05.22 07:02:59.848--ServerSession(426724481)--Thread[asyncDelivery0,5,main]--Connection(47762586)--connecting(DatabaseLogin(
         platform => DB2Platform
         user name => "ou79ecm"
         datasource name => "jdbc/DB239DataSource"
    [5/22/03 7:03:00:118 CDT] 2ec4c80 ConnectionFac I J2CA0122I: Resource reference jdbc/DB239DataSource could not be located, so default values of the following are used: [Resource-ref settings]
         res-auth: 1 (APPLICATION)
         res-isolation-level: 0 (TRANSACTION_NONE)
         res-sharing-scope: true (SHAREABLE)
         res-resolution-control: 999 (undefined)
    [Other attributes]
    isCMP1_x: false (not CMP1.x)
    isJMS: false (not JMS)
    [5/22/03 7:03:01:160 CDT] 2ec4c80 ConnectionFac E J2CA0009E: An exception occurred while trying to instantiate the ManagedConnectionFactory class com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource jdbc/DB239DataSource : java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
         at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
         at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
         at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
         at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
         at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
         at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
         at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
         at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
         at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
         at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
         at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
         at javax.naming.InitialContext.lookup(InitialContext.java:363)
         at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
         at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
         at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
         at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
         at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
         at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
         at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
         at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
         at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
         at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
         at java.lang.Thread.run(Thread.java:513)
    [5/22/03 7:03:01:310 CDT] 2ec4c80 ConnectionFac A J2CA0013I: An exception occurred while trying to create ManagedConnectionFactory for DB239DataSource : java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
         at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
         at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
         at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
         at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
         at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
         at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
         at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
         at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
         at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
         at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
         at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
         at javax.naming.InitialContext.lookup(InitialContext.java:363)
         at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
         at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
         at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
         at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
         at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
         at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
         at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
         at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
         at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
         at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
         at java.lang.Thread.run(Thread.java:513)
    [5/22/03 7:03:01:340 CDT] 2ec4c80 Helpers W NMSV0605W: A Reference object looked up from the context "localhost/nodes/localhost/servers/server1" with the name "jdbc/DB239DataSource" was sent to the JNDI Naming Manager and an exception resulted. Reference data follows:
    Reference Factory Class Name: com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl
    Reference Factory Class Location URLs: <null>
    Reference Class Name: DB239DataSource
    Type: connectorName
    Content: DB239DataSource
    Type: classpath
    Content: C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/lib/rsadapter.rar
    Type: FactoryJndiName
    Content: jdbc/DB239DataSource
    Address Type: dd
    AddressContents: ffffffac ffffffed 0 5 73 72 0 25 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 52 65 73 6f 75 72 63 65 ...
    Address Type: poolProps
    AddressContents: ffffffac ffffffed 0 5 73 72 0 27 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 43 6f 6e 6e 65 63 74 6f ...
    Address Type: configProps
    AddressContents: ffffffac ffffffed 0 5 73 72 0 23 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 43 6f 6e 6e 65 63 74 6f ...
    Address Type: dsProps
    AddressContents: ffffffac ffffffed 0 5 73 72 0 14 6a 61 76 61 2e 75 74 69 6c 2e 50 72 6f 70 65 72 74 69 65 73 39 12 ffffffd0 7a ...
    Address Type: mcfProps
    AddressContents: ffffffac ffffffed 0 5 73 72 0 2d 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 4d 61 6e 61 67 65 64 43 ...
    Address Type: mbeanProps
    AddressContents: ffffffac ffffffed 0 5 73 72 0 1a 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 4d 42 65 61 6e 50 72 6f ...
    Exception data follows:
    java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
         at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
         at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
         at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
         at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
         at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
         at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
         at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
         at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
         at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
         at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
         at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
         at javax.naming.InitialContext.lookup(InitialContext.java:363)
         at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
         at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
         at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
         at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
         at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
         at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
         at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
         at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
         at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
         at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
         at java.lang.Thread.run(Thread.java:513)
    [5/22/03 7:03:01:891 CDT] 2ec4c80 Helpers W NMSV0610I: A NamingException is being thrown from a javax.naming.Context implementation. Details follow:
    Context implementation: com.ibm.ws.naming.jndicos.CNContextImpl
    Context method: lookup
    Context name: localhost/nodes/localhost/servers/server1
    Target name: jdbc/DB239DataSource
    Other data:
    Exception stack trace: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. Root exception is java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
         at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
         at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
         at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
         at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
         at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
         at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
         at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
         at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
         at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
         at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
         at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
         at javax.naming.InitialContext.lookup(InitialContext.java:363)
         at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
         at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
         at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
         at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
         at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
         at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
         at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
         at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
         at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
         at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
         at java.lang.Thread.run(Thread.java:513)
    2003.05.22 07:03:02.111--ServerSession(426724481)--Thread[asyncDelivery0,5,main]--EXCEPTION [TOPLINK-7060] (TopLink - 9.0.3 (Build 423)): oracle.toplink.exceptions.ValidationException
    EXCEPTION DESCRIPTION: Cannot acquire data source [jdbc/DB239DataSource].
    INTERNAL EXCEPTION: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl]LOCAL EXCEPTION STACK:
    EXCEPTION [TOPLINK-7060] (TopLink - 9.0.3 (Build 423)): oracle.toplink.exceptions.ValidationException
    EXCEPTION DESCRIPTION: Cannot acquire data source [jdbc/DB239DataSource].
    INTERNAL EXCEPTION: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl]
         at oracle.toplink.exceptions.ValidationException.cannotAcquireDataSource(Unknown Source)
         at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
         at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
         at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
         at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
         at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
         at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
         at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
         at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
         at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
         at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
         at java.lang.Thread.run(Thread.java:513)
    INTERNAL EXCEPTION STACK:
    com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. Root exception is java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
         at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
         at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
         at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
         at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
         at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
         at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
         at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
         at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
         at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
         at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
         at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
         at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
         at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
         at javax.naming.InitialContext.lookup(InitialContext.java:363)
         at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
         at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
         at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
         at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
         at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
         at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
         at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
         at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
         at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
         at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
         at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
         at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
         at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
         at java.lang.Thread.run(Thread.java:513)

    This looks like a classPath issue.check ur runtime
    class path and make sure xerces is before any other
    parser(xml4j /oracleParser)
    vasanth

  • JAXB and JDK 1.3.1.x

    Where can I get a download of the JAXB stuff to work with JDK 1.3.1.x?
    I downloaded the latest WSDP 1.2 and it works great, but it requires JDK 1.4.x. Unfortunately, our Production envrionment is moving to Weblogic Server 7.x which doesn't support JDK 1.4.x.
    Thanks for your help.

    Well. I finall found the archive url. It's http://java.sun.com/webservices/archive.html.

  • Marshalling with JaxB and HyperJaxb

    Hi guys,
    Can you guys help me based on what is happening below? What I don't
    understand is that HyperJaxB inserts the data fine. I only have
    this problem when pulling it out.
    In the schema, the element type is stated with minoccurs=0. It is true, that sometimes the data may or may not be present. I have also added nillable="true" to the XSD, but this doesn't seem to make a difference.
    Doing some more research on the problem, I discovered that it is
    because some of the XML types in my schema are optional. They occur
    in some documents and not others of the same type.
    Thanks,
    I am getting a null pointer exception as shown below:
    java.lang.NullPointerException
         at org.midwestiso.markets.markets.xml.impl.runtime.Util.getUserFriendlyTypeName(Util.java:71)
         at org.midwestiso.markets.markets.xml.impl.runtime.Util.handleTypeMismatchError(Util.java:56)
         at org.midwestiso.markets.markets.xml.impl.MKTDETTYPTypeImpl.serializeURIs(MKTDETTYPTypeImpl.java:137)
         at org.midwestiso.markets.markets.xml.impl.runtime.SAXMarshaller.childAsURIs(SAXMarshaller.java:419)
         at org.midwestiso.markets.markets.xml.impl.DASTLMTTypeImpl.serializeBody(DASTLMTTypeImpl.java:251)
         at org.midwestiso.markets.markets.xml.impl.DASTLMTImpl.serializeBody(DASTLMTImpl.java:50)
         at org.midwestiso.markets.markets.xml.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
         at org.midwestiso.markets.markets.xml.impl.runtime.MarshallerImpl.write(MarshallerImpl.java:171)
         at org.midwestiso.markets.markets.xml.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:144)
         at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:66)
         at com.transalta.miso.model.factory.SettlementTypeFactory.retrieveSettlements(SettlementTypeFactory.java:254)
         at com.transalta.miso.model.system.WebScrapeHandler.execute(WebScrapeHandler.java:146)
         at org.quartz.core.JobRunShell.run(JobRunShell.java:191)
         at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)

    JAXB does not support xs:any

  • PROBLEMS JAXB and XML-schema

    Hello,
    I think my problem is not directly related to JAXB but to my understanding of schema-files.
    I defined a schema like that:
    <xsd:complexType name="BSR">
    <xsd:sequence>
    <xsd:element name="VERB" type="VERB"/>
    <xsd:element name="NOUN" type="NOUN"/>
    <xsd:element name="REVISION" type="REVISION"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="VERB">
    <xsd:simpleContent>
    <xsd:extension base="xsd:string">
    <xsd:attribute name="value" fixed="ACKNOWLEDGE"/>
    </xsd:extension>
    </xsd:simpleContent>
    </xsd:complexType>
    <xsd:complexType name="NOUN">
    <xsd:simpleContent>
    <xsd:extension base="xsd:string">
    <xsd:attribute name="value" fixed="PO"/>
    </xsd:extension>
    </xsd:simpleContent>
    </xsd:complexType>
    <xsd:complexType name="REVISION">
    <xsd:simpleContent>
    <xsd:extension base="xsd:string">
    <xsd:attribute name="value" fixed="003"/>
    </xsd:extension>
    </xsd:simpleContent>
    </xsd:complexType>
    When I tried to compile that schema via JAXB I got the following error:
    [ERROR] A property with the same name "value" is generated from more than one schema component line 31 of ACKNOWLEDGE_PO_003.xsd
    [ERROR] (Relevant to above error) another one is generated from this schema component. line 14 of datatypes.xsd
    [...] and so on!
    How do I manage to use that attribute "value" in several elements???
    Is there a possibility to declare the attribute once an refer to it, like to an type?
    Please help, I could not find anythig in docu.
    thanX chris

    hallo again,
    i tried that, but the point is, if i remove the declaration of the attribute called "value" it works fine.
    <xsd:element name="BSR">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="VERB"/>
                        <xsd:element ref="NOUN"/>
                        <xsd:element ref="REVISION"/>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="VERB">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="NOUN">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="REVISION">
              <xsd:complexType>
                   <xsd:simpleContent>
                        <xsd:extension base="xsd:string">
                        </xsd:extension>
                   </xsd:simpleContent>
              </xsd:complexType>
         </xsd:element>
    I can compile it that way! but i need these attributes called "value" as you see them above....
    so i think i worked out, that the problem is not in the "BSR"-tag, but the 3-times occurrence of the attribute "value".

  • XML (un)marshalling with JAXB and "any" blocks

    I have 2 very simple XSD schema's.
    SchemaA.xsd:
    [request]-------[element_A] is xs:string
    |__(ANY)
    SchemaB.xsd:
    [body]--------[element_B] is xs:string
    The any block says that there can follow any type of xml after the element_a.
    In the xsd it is coded as: <xs:any />
    I compiled both schema's with jaxb, using this command line:
    xjc SchemaA.xsd -p test.request
    xjc SchemaB.xsd -p test.body -use-runtime test.request.impl.runtime
    I created the following code :
    test.request.ObjectFactory of1 = new test.request.ObjectFactory();
    test.body.ObjectFactory of2 = new test.body.ObjectFactory();
    Request r = of1.createRequest();
    r.setElementA("testing, element one");
    Body b = of2.createBody();
    b.setElementB("testing, element two");
    r.setAny(b);
    Marshaller m = of1.createMarshaller();
    m.marshal(r,System.out);
    And the result is what I expected:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <request><element_a>testing, element one</element_a><body><element_b>testing, element two</element_b></body></request>
    JAXB added the xml from the second schema to the first.
    Ok, so far so good. Now I'm trying to do it the other way around, I want to unmarshall that XML to objects again:
    String xml <- contains the outputted xml from the marshall (as pasted a few lines above)
    Unmarshaller um = of1.createUnmarshaller();
    Request r2 = (Request)um.unmarshal(new ByteArrayInputStream(xml.getBytes()));
    System.err.println(r2.getElementA());
    System.err.println(r2.getAny());
    The output:
    testing, element one
    null
    now, the first message is good. The second is not however...why is the "getAny" null ? I can't figure this one out. In the best possible case it should return an object that can be cast to "Body" .
    In the worst case it should just return the "<Body> ...." xml as string. But not null ...
    Any help on this is appreciated !

    JAXB does not support xs:any

  • Jaxb and xsd problem

    Hi,
    I am trying to compile a set of generated jaxb classes from the xsd defined below. During compilation I get an error stating "Nested type GuestCountType hides an enclosing type". Does anyone see a problem with my xsd file. Appreciate any help with this problem
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:complexType name="GuestCountType">
              <xs:sequence>
                   <xs:element name="GuestCount" maxOccurs="99">
                        <xs:complexType>
                             <xs:attributeGroup ref="GuestCountGroup"/>
                        </xs:complexType>
                   </xs:element>
              </xs:sequence>
              <xs:attribute name="IsPerRoom" type="xs:boolean" use="optional"/>
         </xs:complexType>
         <xs:complexType name="RoomStayCandidateType">
              <xs:sequence>
                   <xs:element name="GuestCounts" type="GuestCountType" minOccurs="0"/>
              </xs:sequence>
         </xs:complexType>
         <xs:attributeGroup name="GuestCountGroup"/>
    </xs:schema>

    Refer to section
    E.2 Not Required XML Schema
    concepts
    "A JAXB implementation is not required to support the following XML Schema
    concepts for this version of the specification. A JAXB implementation may
    choose to support these features in an implementation dependent manner."
    E.2.2 Not supported while manipulating the XML
    content
    Schema component: wildcard
    (any)
    how can i know if an xml element with xsi:nil="true" (unmarshal)
    and set xsi:nil="true" for an element (marshal) ?
    According to the JAXB 1.0 specification:
    If {nillable} is "true", the methods setNil() and isNil() are
    generated.

  • NamingException and ClassCastException during jndi lookup

    Hi,
    I am trying to access the SAP database(MaxDb)using JNDI lookup in WebDynpro simple java project.
    But, during lookup I am getting the following error
    com.sap.engine.services.jndi.persistent.exceptions.NamingException: Exception during lookup operation of object with name : jdbc/VSLOOKUP , can not resolve object reference [Root exception is java.lang.ClassCastException]
         at com.sap.engine.services.jndi.implclient.ClientContext.lookup(ClientContext.java:469)
         at com.sap.engine.services.jndi.implclient.ClientContext.lookup(ClientContext.java:558)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at com.vitalspring.healthbenefits.dbaccess.DBAccessHelper.main(DBAccessHelper.java:51)
    Caused by: java.lang.ClassCastException
         at com.sap.engine.services.connector.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:149)
         at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301)
         at com.sap.engine.services.jndi.implclient.ClientContext.lookup(ClientContext.java:466)
         ... 3 more
    Can anybody throw some light on it?
    Because, it's urgent for my project.
    I would appreciate any kind of help in this regard.
    Thanks & Regards,
    Rambabu Kancharla

    Hello Anilkumar,
    Sorry for delay in reply as I was on out of work and didn't get chance to check the SDN forums.
    I was able to do it in latest version sneak preview 11.
    I think the problem with the version.
    Thanks,
    Rambabu

  • JAXB and JDK 1.1

    Hi,
    is it possible to use JAXB with JDK 1.1?
    Is the source code available to change the collection imports?
    Thanks
    Guenther

    Sorry, but the List class is in java.util since 1.2.
    I have tried to use it with JDK 1.2.2, and it fails because the RI try to use some classes from the sun JDK (com.sun... classes) that are not yet there in the JDK 1.2.2. (Or that are different).
    The same occurs with JDK 1.3.0.
    So even if you don't take into account the problem mentionned by jlongmsn, the RI will not work with JDK 1.1.

  • Servlets and Workspaces (AND ClassCastExceptions)

     

              I have a similiar situation but am not getting a ClassCastException but rather a
              NullPointerException when I try
              to use a contained object in my stored object.
              I do this in the server:
              WorkspaceServicesDef workspaceServices = services.workspace();
              WorkspaceDef defaultWS = workspaceServices.getWorkspace();
              WorkspaceDef dataWS = defaultWS.getWorkspace("DATA_WORKSPACE",
              WorkspaceDef.CREATE,
              WorkspaceDef.SCOPE_SERVER);
              dataWS.store(cMSKey, ms);
              and this in the JSP page:
              // Get the default T3Client Workspace
              WorkspaceDef defaultWS = t3.services.workspace().getWorkspace();
              // Attach to the system subWorkspace already created
              WorkspaceDef myDataWS = defaultWS.getWorkspace("DATA_WORKSPACE",
              WorkspaceDef.ATTACH,
              WorkspaceDef.SCOPE_SERVER);
              MimicServer ms = (MimicServer) myDataWS.fetch("MimicServer");
              Questions:
              1)Must I make the Object I want to store in the WorkSpace Serializable?? The
              Documentation says it can just be
              a Java Object??
              2) In my JSP page I get a good Object reference, but its contents are null
              (Probably because I didn't implement write() and read()).
              Thanks,
              matt obrien
              [email protected]
              Mark Griffith wrote:
              > Alexandre:
              >
              > Although byte for byte the FooObject is the same, according to the VM they
              > are different class. This is because a class's type distinctiveness is
              > based not only its interfaces,methods,data members etc but ALSO on its
              > classloader. There is a different classloader for the
              > serversclasses_FooObject and the servletclasses_FooObject so they are
              > considered different, so you get a CCE.
              >
              > Problem is that the servletclasses directory is designed to solve the
              > problem of reloading servlet classes and objects they used when modified
              > without having to restart the server. But this introduces the problem
              > discussed above. The only solution currently is to put the FooObject only in
              > one place or another. Unfortunately if you want a class in servletclasses
              > to interact classes loaded by the system/server classloader you cannot put
              > the class in the servletclasses without getting a CCE on reload of the
              > servlet in servletclasses. In this case you must put the class only in the
              > serverclasses directory. And this means of course you can only reload the
              > FooObject in the serverclasses directory if you bounce the server. (the
              > default java classloading behavior).
              >
              > This will be handled more elegantly in our next major release Spring 2000,
              > however note (and prepare by designing accordingly) the solution is to allow
              > the Servlet to interact with interfaces not actual classes and these
              > interfaces can be stuffed into system/server loaded classes such as
              > workspaces and httpsessions, thus preventing CCE's.
              >
              > Cheers
              > Mark G
              >
              > Alexandre Aubry wrote:
              >
              > > I have a named workspace which is created at startup of the server
              > > within a starup class.
              > > When the startup method is called, I instantiate and put an object
              > > called FooObject in the workspace.
              > >
              > > Then, in a servlet, called Dispatcher, in the service method, I
              > > retrieved my named workspace and the object
              > > FooObject which is in this workspace. At this time, I have a
              > > ClassCastException.
              > >
              > > To give you more details about my configuration, here is my directory
              > > configuration:
              > > weblogic
              > > |----------- serverclasses
              > > |------------- startupObject
              > > |------------- FooObject
              > > |----------- servletclasses
              > > |------------- myServlet
              > > |------------- FooObject (which is exactly
              > > the same of the serverclasses one)
              > >
              > > Do you have any ideas ? The idea is to instantiate a given object at the
              > > startup of the web server and to retrieve
              > > these objects within servlets and JSPs.
              > >
              > > Regards.
              > >
              > > --
              > > Alexandre Aubry
              > > Consultant
              > > Fi System, The Web Agency
              > > http://www.fisystem.fr
              > > mailto:[email protected]
              > > Phone: +33 1 55 04 03 03 Fax: +33 1 55 04 03 04
              >
              > --
              > =====================================================
              > Reply to the newsgroup. Don't reply to this mail
              > alias. This is used only for answering posts on
              > WebLogic Newsgroups.
              > =====================================================
              

  • Serialization and ClassCastException

    hi all,
    I have a a class like this:
    import java.io.Serializable;
    import java.util.ArrayList;
    public class Fact implements Serializable {
         private String name;
         private ArrayList al=new ArrayList();
         public Fact(String _name) {
              name=_name;
              al.add("Pippo");
              al.add("Pluto");
              al.add("Papero");
         public String getName() {
              return name;
         public ArrayList getList() {
              return al;
    and I want to serialize objects of it in a mySQL database table. the table has two field: 'name', a varchar(20) used as a key and 'object', a blob field to store Java objects.
    this is my code to put object in the table (it seems to work fine):
    public boolean putFact(Fact fact) { // inserts a new fact in the db
              Fact result=null;
              try {
                   PreparedStatement pstmt=conn.prepareStatement("INSERT INTO facts VALUES (?, ?)");
                   pstmt.setString(1, fact.getName());
                   pstmt.setObject(2, fact);
                   pstmt.executeUpdate();
                   pstmt.close();
              } catch (SQLException ex) {
                   System.out.println(ex.toString());
                   return false;
              return true;
    this code musts get an object from the table:
         public Fact getFact(String factName) {
              Fact result=null;
              try {
                   Statement stmt=conn.createStatement();
                   ResultSet rs=stmt.executeQuery("SELECT object FROM facts WHERE name='"+factName+"'");
                   while (rs.next()) {
                        result=(Fact)rs.getObject(1);
                   rs.close();
              stmt.close();
              } catch (SQLException ex) {
                   System.out.println(ex.toString());
                   return null;
         return result;
    on the 7th line of the getFact method I have a ClassCastException: why?
    in addition, if I remove the ArrayList element from the Fact class, my code works fine.
    any help?
    thanks a lot. :)

    first of all, thanks for your support, sylviae. :)
    well, I used your syntax
    (System.err.println(anObject.getClass());) and the
    result is "class Fact": so, the serialization process
    seems to be right.
    then, I tried to change the field from BLOB to
    MEDIUMBLOB type, and now it works! so, I suppose that
    the BLOB type was not able to manage a Fact object.That doesn't really make much sense. If in the revised code you were getting the exception on the line that casts anObject to be a Fact object, then I'd start to wonder about ClassLoader issues. Still, given that you've got it working, you're probably not concerrned about the exact cause.
    >
    in the end, can you suggest me a way to generate SQL
    statements, if mine has the error you said?Use the prepareStatement mechanism as you did for the insert statement, and associate the value with the "?" parameter. I know this looks more clumsy, and is certainly more code, but it is much safer. It's also capable of a more effecient execution because the underlying implementation can note that it's already parsed the statement and avoid having to do it again.
    Sylvia.

Maybe you are looking for

  • Reg asset balances

    Hello All, I want to know the field names and tablenames used in asset balances report in tcode(s_alr_87011967). Pls help its urgent Thnks, Vibha

  • Condition Type :  VPRS  is duplicated in Billing

    When i create Sales Order, i add condition type VPRS. but when i create billing, condition type VPRS got twice. First line is  zero. VPRS     Cost                                              0.00 VPRS     Cost                                        

  • Selection of BOM with Production version

    Hello friends, I have Finish product say A with two alt. BOM and Production Version 1 & 2 i have semi-finish product say B  with two alt. BOM 1 and 2 in the BOM of the Product A Now when i create PIR in MD61 for product A with production version 2 se

  • Opening a directory window on App Server?

    I have a directory on my application server where Oracle Reports creates output files and I would like to have a button on a 10g form that opens this directory window. Anyone know how to do this?

  • Change hostname in SUNOS 5.10

    What file I need to edit if I change the hostname in SUN OS 5.10???