db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wessam Abd Rabo" <wessam.abdr...@gmail.com>
Subject Fwd: ClassCastException and ClassLoaders
Date Wed, 26 Sep 2007 11:13:06 GMT
Hi,

On running a nb module, I get a ClassCastException with the following stack
trace:

java.lang.ClassCastException: com.sun.xml.stream.ZephyrParserFactory cannot
be cast to javax.xml.stream.XMLInputFactory
        at javax.xml.stream.XMLInputFactory.newInstance (
XMLInputFactory.java:136)
        at org.apache.ddlutils.io.DatabaseIO.getXMLInputFactory(
DatabaseIO.java:240)
        at org.apache.ddlutils.io.DatabaseIO.read(DatabaseIO.java:207)
        at org.apache.ddlutils.io.DatabaseIO.read (DatabaseIO.java:171)
        at org.netbeans.newddlmod.newdbTopComponent.jButton1MouseClicked(
newdbTopComponent.java:72)
        at org.netbeans.newddlmod.newdbTopComponent.access$000(
newdbTopComponent.java :19)
        at org.netbeans.newddlmod.newdbTopComponent$1.mouseClicked(
newdbTopComponent.java:46)
        at java.awt.AWTEventMulticaster.mouseClicked(
AWTEventMulticaster.java:253)
        at java.awt.Component.processMouseEvent (Component.java:6041)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
        at java.awt.Component.processEvent(Component.java:5803)
        at java.awt.Container.processEvent(Container.java :2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4410)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java
:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java
:3995)
        at java.awt.LightweightDispatcher.dispatchEvent (Container.java
:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2429)
        at java.awt.Component.dispatchEvent(Component.java :4240)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(
EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter (
EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(
EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java
:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java
:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

My module has the following dependencies:

-commons beanutils
-commons codec
-commons collections
-commons dbcp
-commons digester
-commons lang
-commons loggings
-commons pool
-dom4j 1.4
-jakarta oro 2.0.8
-log4j 1.2.8
-stax api 1.0.1
-wstx asl 3.0.2
-derby client
-ant
-xercesImp

What i know about this issue is that if classloader A loads Class X and
Classloader B loads classY, then even if Y is assignable to X at the source
code level, it fails, because the classes are in different *classloaders*.
so although the ZephyrParserFactory is an implementation of the
XMLInputFactory they are both loaded from different class loaders (perhaps
the ZephyrParserFactory is bundled with a separate StAX API JAR). If two
identical classes are loaded from different class loaders they are NOT the
same class, so it will cause a class cast exception.

Can anyone suggest a solution to this problem

Thanks

Wessam

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message