org.apache.xerces.impl.dv.xs.ListDV$ListData cannot be cast to [Ljava.lang.Object;

247 views
Skip to first unread message

Matthew Kerle

unread,
May 15, 2009, 1:20:01 AM5/15/09
to java...@googlegroups.com
hi guys,

I'm not looking for an answer to a question, I'm just posting this here as a good place for google to find, as when I encountered this problem the only decent hit on google was this forum, and it wasn't very helpful (as neither is this, but maybe it will help someone somewhere...). However if anyone has any insight as to *why* the problem causes the observed error, and why the answer fixes the problem, then I would much appreciate it!!!

The problem is that I recently added a commons library developed internally to my project. unit tests continued to run fine from the IDE (IDEA 7, I'd generated the module file from the pom using mvn idea:idea), but running unit tests from the command line using mvn failed catastrophically with the below stacktrace, with the totally cryptic "org.apache.xerces.impl.dv.xs.ListDV$ListData cannot be cast to [Ljava.lang.Object;" as the error...

here's the dep element for the offending module:
    <dependency>
        <groupId>au.gov.dha.common</groupId>
        <artifactId>common-core</artifactId>
        <version>1.2.1-SNAPSHOT</version>
        <scope>compile</scop
    </dependency>

Obviously the idea that any Java instance can't be cast to a java.lang.Object is ludicrous, and implies a classloader problem, but thats bad voodoo and I don't like trying to debug those problems...

playing around with various things I discovered that if I changed the scope of the dependency to "provided" then the exception magically transformed into a "java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder" on one of the beans out of the common module. this lead me into an education of the wonders of the hatred of some apache admins for log4j, their demand for commons-logging, and the later creation of SLF4J to take some of the pain out of commons-logging (oh God the pain!).

So now my problem was that although the slf4j-api dependency was transitively propagated from the common-core module, the slf4j impl StaticLoggerBinder wasn't, so adding slf4j-jcl as a test-scoped dependency (deploying to JBoss which already has an impl provided) fixed that, and now everything happy!!! I still have no idea what caused the original error, any ideas? eg - why would mvn or perhaps Spring classloaders combine in such a way that Xerces gets confused?

Java's so easy, I don't know why more people don't do it!

On the plus side, in this whole process I discovered that you can remotely debug unit tests under mvn, just add the voodoo incantation " -Dmaven.surefire.debug" to the command line, and attach your favorite IDE and you can debug through the unit tests as they run under mvn, it's awesome!!

also, does anyone know how to tell the Sun JVM not to eat the extra lines on the stacktrace? eg turn "... 48 more" into 48 lines of actual stacktrace?

extra cudos to ClassCastException for not filling in it's stacktrace and leaving no hint as to what line caused the exception, leaving this humble developer to have to set breakpoints in it's constructor and sneak a peek at the stack through the debugger.

hope this isn't Too Long...


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'refListSessionFactory' defined in class path resource [au/gov/dha/common/reflist/impl/hibernate/reflist-hibernate-beans.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not parse mapping document in input stream
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1302)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:263)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:170)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:184)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:424)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:105)
    at au.gov.dha.builder.AbstractSpringBuilder.<init>(AbstractSpringBuilder.java:47)
    at au.gov.dha.recon.ReconBuilder.<init>(ReconBuilder.java:48)
    at au.gov.dha.recon.excludes.TestUtils.init(TestUtils.java:33)
    at au.gov.dha.recon.ReconBuilderTest.testSpringConfig(ReconBuilderTest.java:40)
Caused by: org.hibernate.MappingException: Could not parse mapping document in input stream
    at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:735)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:633)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1333)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1299)
    ... 44 more
Caused by: org.dom4j.DocumentException: org.apache.xerces.impl.dv.xs.ListDV$ListData cannot be cast to [Ljava.lang.Object; Nested exception: org.apache.xerces.impl.dv.xs.ListDV$ListData cannot be cast to [Ljava.lang.Object;
    at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:725)
    ... 48 more



Hidden Classcast Exception munched by SAXReader: (no line numbers... :-( )
      at java.lang.ClassCastException.<init>(ClassCastException.java:39)
      at org.apache.xerces.impl.xs.XMLSchemaLoader.processExternalHints(Unknown Source:-1)
      at org.apache.xerces.impl.xs.XMLSchemaValidator.reset(Unknown Source:-1)
      at org.apache.xerces.parsers.BasicParserConfiguration.reset(Unknown Source:-1)
      at org.apache.xerces.parsers.DTDConfiguration.reset(Unknown Source:-1)
      at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source:-1)
      at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source:-1)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source:-1)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source:-1)
      at org.dom4j.io.SAXReader.read(SAXReader.java:465)
      at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:725)
      at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:633)
      at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1,333)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1,299)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
      at java.security.AccessController.doPrivileged(AccessController.java:-1)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:263)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:170)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:184)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:424)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
      at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:105)
      at au.gov.dha.builder.AbstractSpringBuilder.<init>(AbstractSpringBuilder.java:47)
      at au.gov.dha.recon.ReconBuilder.<init>(ReconBuilder.java:48)
      at au.gov.dha.recon.excludes.TestUtils.init(TestUtils.java:33)
      at au.gov.dha.recon.ReconBuilderTest.testSpringConfig(ReconBuilderTest.java:40)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at junit.framework.TestCase.runTest(TestCase.java:164)
      at junit.framework.TestCase.runBare(TestCase.java:130)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:120)
      at junit.framework.TestSuite.runTest(TestSuite.java:230)
      at junit.framework.TestSuite.run(TestSuite.java:225)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
      at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1,009)

Christian Catchpole

unread,
May 15, 2009, 1:50:08 AM5/15/09
to The Java Posse
Note the [ on the start of that signature. It means array. :) it's
trying to cast to an Object[], not an Object. :)

Matthew Kerle

unread,
May 18, 2009, 5:01:03 AM5/18/09
to java...@googlegroups.com
ahhhh... Doh! thank you Christian, that makes more sense now! I still have no idea why playing with maven scopes would produce that bug but it's fixed for me now and on google for the next poor monkey who hits it so back to work for me!

also, my post is now top of google results for that error, mission accomplished!

2009/5/15 Christian Catchpole <chri...@catchpole.net>
Reply all
Reply to author
Forward
0 new messages