About

Jadira is the home for Sousan and Chris Pheby's open source projects. These are reusable open source Java modules that provide first class solutions using the most effective current JEE technologies.

Search
Tag Cloud
...
Login

Jadira Support > NPE when using┬áPersistentEnum

getting this exception when trying to generate ddl

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (default) on project btc-market-entities: An Ant BuildException has occured: org.hibernate.MappingException: Unable to instantiate custom type: org.jadira.usertype.corejava.PersistentEnum
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: org.hibernate.MappingException: Unable to instantiate custom type: org.jadira.usertype.corejava.PersistentEnum
at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:131)
at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:98)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 25 more
Caused by: org.hibernate.MappingException: Unable to instantiate custom type: org.jadira.usertype.corejava.PersistentEnum
at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:226)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:189)
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.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:118)
... 28 more
Caused by: org.hibernate.MappingException: Unable to instantiate custom type: org.jadira.usertype.corejava.PersistentEnum
at org.hibernate.type.TypeFactory.custom(TypeFactory.java:193)
at org.hibernate.type.TypeFactory.custom(TypeFactory.java:179)
at org.hibernate.type.TypeFactory.byClass(TypeFactory.java:103)
at org.hibernate.type.TypeResolver.heuristicType(TypeResolver.java:130)
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:295)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:187)
at org.hibernate.mapping.Column.getSqlType(Column.java:227)
at org.hibernate.mapping.Table.sqlCreateString(Table.java:417)
at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:1024)
at org.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:126)
at org.hibernate.tool.hbm2x.Hbm2DDLExporter.doStart(Hbm2DDLExporter.java:165)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
... 32 more
Caused by: java.lang.NullPointerException
at org.jadira.usertype.corejava.PersistentEnum.setParameterValues(PersistentEnum.java:35)
at org.hibernate.type.TypeFactory.injectParameters(TypeFactory.java:131)
at org.hibernate.type.TypeFactory.custom(TypeFactory.java:189)
... 45 more

Maven plugin config
<plugins>
<plugin>
<!--<groupId>org.apache.maven.plugins</groupId>-->
maven-antrun-plugin
<!--<version>1.7</version>-->
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<tasks>
<property name="maven_test_classpath" refid="maven.test.classpath"/>
<path id="hibernate_tools_path">
<pathelement path="${maven_test_classpath}"/>
</path>
<property name="hibernate_tools_classpath" refid="hibernate_tools_path"/>
<echo message="hibernate_tools classpath: ${hibernate_tools_classpath}"/>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="maven.plugin.classpath"/>
<mkdir dir="${project.build.directory}/generated-sources/hibernate"/>
<hibernatetool destdir="${project.build.directory}/generated-sources/hibernate">
<classpath refid="hibernate_tools_path"/>
<jpaconfiguration persistenceunit="marketPersistenceUnit"/>
<!--<hbm2ddl export="false" format="true" outputfilename="database.ddl"/>-->
<hbm2ddl

export="false"
outputfilename="database.ddl"
delimiter=";"
format="true"/>
</hibernatetool>
</tasks>
<detail>true</detail>
</configuration>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
hibernate-tools
<version>4.0.0-CR1</version>
<!--<exclusions>-->
<!--<exclusion>-->
<!--hibernate-commons-annotations-->
<!--<groupId>org.hibernate</groupId>-->
<!--</exclusion>-->
<!--</exclusions>-->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
slf4j-simple
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
slf4j-api
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
joda-time
<version>${joda.time.version}</version>
</dependency>
<dependency>
<groupId>org.joda</groupId>
joda-money
<version>${joda-money.version}</version>
</dependency>
<dependency>
<groupId>org.jadira.usertype</groupId>
usertype.core
<version>3.1.0.CR10</version>
</dependency>
<dependency>
<groupId>org.jadira.cdt</groupId>
cdt
<version>3.1.0.CR10</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
postgresql
<version>${postgresql.driver.version}</version>
</dependency>
</dependencies>
</plugin>

field declaration

@Column(name = "ORDER_TYPE", nullable = false)
@Type(type = CustomTypes.ENUM)
private OrderType orderType;

December 21, 2013 | Unregistered CommenterNikita

You need to provide a parameter to specify the enum class. See Usertypes User Guide for an example.

March 11, 2014 | Registered CommenterChris