javax.persistence.PersistenceException: java.lang.ClassCastException: java.lang.String

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Doing this: Map overrides = new HashMap(); overrides.put("javax.persistence.transactionType", "RESOURCE_LOCAL"); Ejb3Configuration ejb3cfg = new Ejb3Configuration(); ejb3cfg.createEntityManagerFactory(null, overrides); result in class cast exception: C:\work\os\hibernate\HibernateExt\tools\src\testsupport\anttest-build.xml:205: javax.persistence.PersistenceException: java.lang.ClassCastException: java.lang.String at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:184) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:154) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.hibernate.tool.ant.BuildFileTestCase.executeTarget(BuildFileTestCase.java:241) at org.hibernate.tool.ant.HibernateToolTest.testEJB3ConfigurationFailureExpected(HibernateToolTest.java:65) 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:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) 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:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: javax.persistence.PersistenceException: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) at org.hibernate.tool.ant.EJB3ConfigurationTask.createConfiguration(EJB3ConfigurationTask.java:23) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:216) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:151) ... 21 more Caused by: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:101) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:150) ... 26 more --- Nested Exception --- javax.persistence.PersistenceException: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) at org.hibernate.tool.ant.EJB3ConfigurationTask.createConfiguration(EJB3ConfigurationTask.java:23) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:216) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:151) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.hibernate.tool.ant.BuildFileTestCase.executeTarget(BuildFileTestCase.java:241) at org.hibernate.tool.ant.HibernateToolTest.testEJB3ConfigurationFailureExpected(HibernateToolTest.java:65) 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:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) 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:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:101) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:150) ... 26 more for some reason the for loop expects Map.Entry from a keyset ....?
    via by Max Rydahl Andersen,
  • Doing this: Map overrides = new HashMap(); overrides.put("javax.persistence.transactionType", "RESOURCE_LOCAL"); Ejb3Configuration ejb3cfg = new Ejb3Configuration(); ejb3cfg.createEntityManagerFactory(null, overrides); result in class cast exception: C:\work\os\hibernate\HibernateExt\tools\src\testsupport\anttest-build.xml:205: javax.persistence.PersistenceException: java.lang.ClassCastException: java.lang.String at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:184) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:154) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.hibernate.tool.ant.BuildFileTestCase.executeTarget(BuildFileTestCase.java:241) at org.hibernate.tool.ant.HibernateToolTest.testEJB3ConfigurationFailureExpected(HibernateToolTest.java:65) 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:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) 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:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: javax.persistence.PersistenceException: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) at org.hibernate.tool.ant.EJB3ConfigurationTask.createConfiguration(EJB3ConfigurationTask.java:23) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:216) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:151) ... 21 more Caused by: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:101) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:150) ... 26 more --- Nested Exception --- javax.persistence.PersistenceException: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) at org.hibernate.tool.ant.EJB3ConfigurationTask.createConfiguration(EJB3ConfigurationTask.java:23) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:216) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:151) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.hibernate.tool.ant.BuildFileTestCase.executeTarget(BuildFileTestCase.java:241) at org.hibernate.tool.ant.HibernateToolTest.testEJB3ConfigurationFailureExpected(HibernateToolTest.java:65) 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:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) 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:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:101) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:150) ... 26 more for some reason the for loop expects Map.Entry from a keyset ....?
    via by Max Rydahl Andersen,
    • javax.persistence.PersistenceException: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) at org.hibernate.tool.ant.EJB3ConfigurationTask.createConfiguration(EJB3ConfigurationTask.java:23) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:216) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:151) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.hibernate.tool.ant.BuildFileTestCase.executeTarget(BuildFileTestCase.java:241) at org.hibernate.tool.ant.HibernateToolTest.testEJB3ConfigurationFailureExpected(HibernateToolTest.java:65) 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:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) 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:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.ClassCastException: java.lang.String at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:101) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:150) ... 26 more
    No Bugmate found.