XStream

Exception thrown by CGLIB converter duting initialization of XStream

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.2.2
  • Fix Version/s: None
  • Component/s: Converters
  • Labels:
    None
  • JDK version and platform:
    JDK 1.6_03, WinXP,

Description

exception that thrown:
Exception in thread "pool-2-thread-1" java.lang.ExceptionInInitializerError
at com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.canConvert(CGLIBEnhancedConverter.java:59)
at com.thoughtworks.xstream.core.DefaultConverterLookup.registerConverter(DefaultConverterLookup.java:58)
at com.thoughtworks.xstream.XStream.registerConverter(XStream.java:1033)
at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter(XStream.java:663)
at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:646)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:375)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:301)
at com.nolio.platform.server.dataservices.logic.packages.loaders.ApplicationLoader.loadApplicationsFromFile(ApplicationLoader.java:43)
at com.nolio.platform.server.dataservices.logic.packages.loaders.PackageLoader.loadPackage(PackageLoader.java:79)
at com.nolio.platform.server.dataservices.logic.packages.loaders.PackageLoader.loadPackage(PackageLoader.java:44)
at com.nolio.platform.server.dataservices.logic.packages.loaders.PackageLoader.loadFromFileObject(PackageLoader.java:36)
at com.nolio.platform.server.dataservices.logic.packages.PackagesScanner.run(PackagesScanner.java:130)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassCastException: net.sf.cglib.proxy.Enhancer$EnhancerKey$$KeyFactoryByCGLIB$$7fb24d72 cannot be cast to net.sf.cglib.core.KeyFactory
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
... 15 more

don't know if this relevant: thrown inside of WebApp running in embedded Jetty 6

Activity

Hide
Joerg Schaible added a comment -

Hi Mirron,

I am closing this as "Cannot Reproduce", since the problem does not seem to be XStream related in first place. Have a look at the stack trace, the ClassCastException is thrown somewhere deep down in the sources of CGLIB, XStream simply tries to call a method of a class available in CGLIB. However, it seems that you have some incompatible versions of CGLIB in the class path, this ClassCastException is a typical symptom. Please have a look at the libs Jetty is loading at startup and look into your own dependencies.

If you have further questions, please ask on the user's list.

  • Jörg
Show
Joerg Schaible added a comment - Hi Mirron, I am closing this as "Cannot Reproduce", since the problem does not seem to be XStream related in first place. Have a look at the stack trace, the ClassCastException is thrown somewhere deep down in the sources of CGLIB, XStream simply tries to call a method of a class available in CGLIB. However, it seems that you have some incompatible versions of CGLIB in the class path, this ClassCastException is a typical symptom. Please have a look at the libs Jetty is loading at startup and look into your own dependencies. If you have further questions, please ask on the user's list.
  • Jörg
Hide
Joerg Schaible added a comment -

Closed after no further comment has been given.

Show
Joerg Schaible added a comment - Closed after no further comment has been given.
Hide
Brill Pappin added a comment -

I'm having the exact same trouble.

it looks like its inside cglib but its related to something xstream is doing.

my stack trace follows:

jvm 1 | java.lang.ExceptionInInitializerError
jvm 1 | at com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.canConvert(CGLIBEnhancedConverter.java:67)
jvm 1 | at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:60)
jvm 1 | at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:65)
jvm 1 | at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:59)
jvm 1 | at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:142)
jvm 1 | at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)
jvm 1 | at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:931)
jvm 1 | at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:917)
jvm 1 | at com.thoughtworks.xstream.XStream.fromXML(XStream.java:861)
jvm 1 | at com.emineollc.config.ConfigManager.read(ConfigManager.java:55)
jvm 1 | at com.emineollc.model.hibernate.PersistenceManager.getEntityManagerFactory(PersistenceManager.java:46)
jvm 1 | at com.emineollc.model.hibernate.PersistenceManager.getEntityManager(PersistenceManager.java:71)
jvm 1 | at com.emineollc.model.hibernate.PersistenceManager.executeLoader(PersistenceManager.java:148)
jvm 1 | at com.emineollc.model.hibernate.Loader.load(Loader.java:9)
jvm 1 | at com.emineollc.webadmin.wicket.WicketApplication.migrate(WicketApplication.java:83)
jvm 1 | at com.emineollc.webadmin.wicket.WicketApplication.init(WicketApplication.java:29)
jvm 1 | at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:561)
jvm 1 | at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:99)
jvm 1 | at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
jvm 1 | at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:594)
jvm 1 | at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
jvm 1 | at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
jvm 1 | at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
jvm 1 | at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
jvm 1 | at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
jvm 1 | at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
jvm 1 | at org.mortbay.jetty.Server.doStart(Server.java:220)
jvm 1 | at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
jvm 1 | at com.emineollc.webadmin.AdminServer.startupService(AdminServer.java:29)
jvm 1 | at com.emineollc.Launcher.start(Launcher.java:61)
jvm 1 | at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788)
jvm 1 | Caused by: java.lang.ClassCastException: net.sf.cglib.proxy.Enhancer$EnhancerKey$$KeyFactoryByCGLIB$$7fb24d72 cannot be cast to net.sf.cglib.core.KeyFactory
jvm 1 | at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
jvm 1 | at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
jvm 1 | at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
jvm 1 | at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
jvm 1 | at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
jvm 1 | ... 31 more

Show
Brill Pappin added a comment - I'm having the exact same trouble. it looks like its inside cglib but its related to something xstream is doing. my stack trace follows: jvm 1 | java.lang.ExceptionInInitializerError jvm 1 | at com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.canConvert(CGLIBEnhancedConverter.java:67) jvm 1 | at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:60) jvm 1 | at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:65) jvm 1 | at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:59) jvm 1 | at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:142) jvm 1 | at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33) jvm 1 | at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:931) jvm 1 | at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:917) jvm 1 | at com.thoughtworks.xstream.XStream.fromXML(XStream.java:861) jvm 1 | at com.emineollc.config.ConfigManager.read(ConfigManager.java:55) jvm 1 | at com.emineollc.model.hibernate.PersistenceManager.getEntityManagerFactory(PersistenceManager.java:46) jvm 1 | at com.emineollc.model.hibernate.PersistenceManager.getEntityManager(PersistenceManager.java:71) jvm 1 | at com.emineollc.model.hibernate.PersistenceManager.executeLoader(PersistenceManager.java:148) jvm 1 | at com.emineollc.model.hibernate.Loader.load(Loader.java:9) jvm 1 | at com.emineollc.webadmin.wicket.WicketApplication.migrate(WicketApplication.java:83) jvm 1 | at com.emineollc.webadmin.wicket.WicketApplication.init(WicketApplication.java:29) jvm 1 | at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:561) jvm 1 | at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:99) jvm 1 | at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40) jvm 1 | at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:594) jvm 1 | at org.mortbay.jetty.servlet.Context.startContext(Context.java:139) jvm 1 | at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218) jvm 1 | at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500) jvm 1 | at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) jvm 1 | at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40) jvm 1 | at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117) jvm 1 | at org.mortbay.jetty.Server.doStart(Server.java:220) jvm 1 | at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40) jvm 1 | at com.emineollc.webadmin.AdminServer.startupService(AdminServer.java:29) jvm 1 | at com.emineollc.Launcher.start(Launcher.java:61) jvm 1 | at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788) jvm 1 | Caused by: java.lang.ClassCastException: net.sf.cglib.proxy.Enhancer$EnhancerKey$$KeyFactoryByCGLIB$$7fb24d72 cannot be cast to net.sf.cglib.core.KeyFactory jvm 1 | at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145) jvm 1 | at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117) jvm 1 | at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108) jvm 1 | at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104) jvm 1 | at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69) jvm 1 | ... 31 more
Hide
r351574nc3 added a comment -

I don't want to reopen this because I can sense there is some tension here, but I have encountered this again in a special instance that I think XStream should account for. In multithreaded scenarios with separate classloaders, this issue can occur where registering a converter a cross classloaders will cause this exact issue. It is not always a classpath issue because it is possible to load these remotely.

Generally speaking, it is a classloader issue that where a workaround can be found by correcting the classpath. It is a workaround because this is not a solution since it only works in one specific scenario. It does not correct the other scenarios. The overall problem is just hidden from the developer at that point though because the classloader issue still exists.

I am using xstream 1.2.2 and I have only been able to solve this by proxying xstream. I work on a maven project where the version is fixed, so I cannot simply upgrade. Is this classloader issue fixed in later versions of xstream? If it is, maybe I can use that point to convince an upgrade. Maintaining a proxy is pretty difficult.

Show
r351574nc3 added a comment - I don't want to reopen this because I can sense there is some tension here, but I have encountered this again in a special instance that I think XStream should account for. In multithreaded scenarios with separate classloaders, this issue can occur where registering a converter a cross classloaders will cause this exact issue. It is not always a classpath issue because it is possible to load these remotely. Generally speaking, it is a classloader issue that where a workaround can be found by correcting the classpath. It is a workaround because this is not a solution since it only works in one specific scenario. It does not correct the other scenarios. The overall problem is just hidden from the developer at that point though because the classloader issue still exists. I am using xstream 1.2.2 and I have only been able to solve this by proxying xstream. I work on a maven project where the version is fixed, so I cannot simply upgrade. Is this classloader issue fixed in later versions of xstream? If it is, maybe I can use that point to convince an upgrade. Maintaining a proxy is pretty difficult.
Hide
Joerg Schaible added a comment -

@r351574nc3: Simply open a new issue that describes exactly the scenario where you're facing this problem. And it would really help if you use a recent XStream version.

Show
Joerg Schaible added a comment - @r351574nc3: Simply open a new issue that describes exactly the scenario where you're facing this problem. And it would really help if you use a recent XStream version.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: