java.lang.ClassCastException: cannot assign instance of java.lang.String to field org.slf4j.impl.JDK14LoggerAdapter.logger of type java.util.logging.Logger in instance of org.slf4j.impl.JDK14LoggerAdapter

QOS.ch JIRA | Thorbjørn Ravn Andersen | 5 years ago
  1. 0

    We currently use slf4j-jdk14-1.5.11 as the slf4j implementation for a legacy web application running inside GlassFish 3.1.1 in order to have the web container handle logging. After migrating the web application to maven the Eclipse Java EE redeployment mechanism now throws ClassCastExceptions when deserializing the session object which contains a controller object which has a field like: static private Logger log = LoggerFactory.getLogger(Controller.class); According to http://www.slf4j.org/faq.html loggers are serializable, hence this bug report. <pre>Full exception: java.lang.ClassCastException: cannot assign instance of java.lang.String to field org.slf4j.impl.JDK14LoggerAdapter.logger of type java.util.logging.Logger in instance of org.slf4j.impl.JDK14LoggerAdapter at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2032) at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1212) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1953) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at org.apache.catalina.session.StandardSession.readRemainingObject(StandardSession.java:1951) at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1859) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at org.apache.catalina.session.StandardSession.deserialize(StandardSession.java:1144) at org.apache.catalina.session.StandardManager.readSessions(StandardManager.java:492) at com.sun.enterprise.web.WebModule.loadSessions(WebModule.java:1573) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2002) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651) at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109) at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130) at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269) at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382) at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232) at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459) at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209) at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168) at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:619) </pre>

    QOS.ch JIRA | 5 years ago | Thorbjørn Ravn Andersen
    java.lang.ClassCastException: cannot assign instance of java.lang.String to field org.slf4j.impl.JDK14LoggerAdapter.logger of type java.util.logging.Logger in instance of org.slf4j.impl.JDK14LoggerAdapter
  2. 0

    We currently use slf4j-jdk14-1.5.11 as the slf4j implementation for a legacy web application running inside GlassFish 3.1.1 in order to have the web container handle logging. After migrating the web application to maven the Eclipse Java EE redeployment mechanism now throws ClassCastExceptions when deserializing the session object which contains a controller object which has a field like: static private Logger log = LoggerFactory.getLogger(Controller.class); According to http://www.slf4j.org/faq.html loggers are serializable, hence this bug report. <pre>Full exception: java.lang.ClassCastException: cannot assign instance of java.lang.String to field org.slf4j.impl.JDK14LoggerAdapter.logger of type java.util.logging.Logger in instance of org.slf4j.impl.JDK14LoggerAdapter at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2032) at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1212) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1953) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at org.apache.catalina.session.StandardSession.readRemainingObject(StandardSession.java:1951) at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1859) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at org.apache.catalina.session.StandardSession.deserialize(StandardSession.java:1144) at org.apache.catalina.session.StandardManager.readSessions(StandardManager.java:492) at com.sun.enterprise.web.WebModule.loadSessions(WebModule.java:1573) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2002) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651) at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109) at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130) at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269) at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382) at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232) at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459) at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209) at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168) at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:619) </pre>

    QOS.ch JIRA | 5 years ago | Thorbjørn Ravn Andersen
    java.lang.ClassCastException: cannot assign instance of java.lang.String to field org.slf4j.impl.JDK14LoggerAdapter.logger of type java.util.logging.Logger in instance of org.slf4j.impl.JDK14LoggerAdapter
  3. 0

    java.io.NotSerializableException: org.primefaces.component.datatable.DataTable after PrimeFaces is upgraded to 5.1

    Stack Overflow | 2 years ago
    java.lang.ClassCastException: cannot assign instance of java.lang.String to field org.primefaces.component.datatable.DataTable$MultiSortState.this$0 of type org.primefaces.component.datatable.DataTable in instance of org.primefaces.component.datatable.DataTable$MultiSortState
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    RequestContext via timer nullpointer exception

    Stack Overflow | 3 years ago | NoodleMage
    java.lang.ClassCastException: cannot assign instance of java.lang.String to field beans.IndexBean.timer of type java.util.Timer in instance of beans.IndexBean
  6. 0

    CJ's DW

    blogspot.com | 1 year ago
    java.lang.ClassCastException: cannot assign instance of java.lang.String to field cn.beans.UserSession.time of type java.util.Date in instance of cn.beans.UserSession

  1. bpbhat77 2 times, last 4 months ago
  2. shiva768 1 times, last 11 months ago
11 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.ClassCastException

    cannot assign instance of java.lang.String to field org.slf4j.impl.JDK14LoggerAdapter.logger of type java.util.logging.Logger in instance of org.slf4j.impl.JDK14LoggerAdapter

    at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues()
  2. Java RT
    ObjectInputStream.readObject
    1. java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2032)
    2. java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1212)
    3. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1953)
    4. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
    5. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    6. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    7. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
    8. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
    9. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    10. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    11. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
    12. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
    13. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    14. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    15. java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    15 frames
  3. Glassfish Core
    StandardSession.readObject
    1. org.apache.catalina.session.StandardSession.readRemainingObject(StandardSession.java:1951)
    2. org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1859)
    2 frames
  4. Java RT
    ObjectInputStream.readObject
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:597)
    5. java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    6. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    7. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    8. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    9. java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    9 frames
  5. Glassfish Core
    StandardManager.readSessions
    1. org.apache.catalina.session.StandardSession.deserialize(StandardSession.java:1144)
    2. org.apache.catalina.session.StandardManager.readSessions(StandardManager.java:492)
    2 frames
  6. Glassfish
    WebApplication.start
    1. com.sun.enterprise.web.WebModule.loadSessions(WebModule.java:1573)
    2. com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2002)
    3. com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)
    4. com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    4 frames
  7. Private APIs of Glassfish
    ApplicationInfo.start
    1. org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    2. org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    3. org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
    3 frames
  8. Kernel Classes
    ApplicationLifecycle.deploy
    1. com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
    2. com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    2 frames
  9. Embedded GlassFish Web
    DeployCommand.execute
    1. org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
    1 frame
  10. Kernel Classes
    AdminAdapter.service
    1. com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
    2. com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    3. com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
    4. com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    5. com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
    6. com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
    7. com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
    8. com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
    8 frames
  11. Grizzly WS
    GrizzlyAdapter.service
    1. com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
    1 frame
  12. Kernel Classes
    ContainerMapper.service
    1. com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    2. com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
    2 frames
  13. Grizzly WS
    AbstractThreadPool$Worker.run
    1. com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    2. com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    3. com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    4. com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    5. com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    6. com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    7. com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    8. com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    9. com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    10. com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    11. com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    12. com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    13. com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    13 frames
  14. Java RT
    Thread.run
    1. java.lang.Thread.run(Thread.java:619)
    1 frame