Jpa console + spring = TypeNotPresentExceptionProxy

Answered

Hi,

I have a problem with jpa console on my application. Aplication on maven with multiple modules. I added an jpa facelet to one of the modules with default JPA provider Hibernate, and remain empty descriptors section.

When I run any query in JPA console (from Persistence tab) I get exception:

java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.createAnnotationData(Class.java:3526)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.createAnnotationData(Class.java:3526)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotation(Class.java:3415)
at java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:258)
at java.lang.Class.isAnnotationPresent(Class.java:3425)
at org.hibernate.annotations.common.reflection.java.JavaAnnotationReader.isAnnotationPresent(JavaAnnotationReader.java:50)
at org.hibernate.annotations.common.reflection.java.JavaXAnnotatedElement.isAnnotationPresent(JavaXAnnotatedElement.java:60)
at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.categorizeAnnotatedClass(AnnotationMetadataSourceProcessorImpl.java:115)
at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.<init>(AnnotationMetadataSourceProcessorImpl.java:104)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.<init>(MetadataBuildingProcess.java:147)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:141)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
at com.intellij.hibernate.console5.remote.HibernateFacadeImpl$MyRemoteConfigurationImpl.buildSessionFactory(HibernateFacadeImpl.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at com.sun.proxy.$Proxy156.buildSessionFactory(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.execution.rmi.RemoteUtil.invokeRemote(RemoteUtil.java:169)
at com.intellij.execution.rmi.RemoteUtil.access$300(RemoteUtil.java:36)
at com.intellij.execution.rmi.RemoteUtil$2$1$1.compute(RemoteUtil.java:150)
at com.intellij.execution.rmi.RemoteUtil.executeWithClassLoader(RemoteUtil.java:226)
at com.intellij.execution.rmi.RemoteUtil$2$1.invoke(RemoteUtil.java:147)
at com.sun.proxy.$Proxy156.buildSessionFactory(Unknown Source)
at com.intellij.hibernate.engine.HibernateEngine.ensureInitialized(HibernateEngine.java:116)
at com.intellij.hibernate.engine.HibernateEngine.createQuery(HibernateEngine.java:135)
at com.intellij.jpa.engine.JpaEngineBase.executeQueryInner(JpaEngineBase.java:142)
at com.intellij.jpa.engine.JpaEngineBase.lambda$queryData$0(JpaEngineBase.java:109)
at com.intellij.database.console.AbstractEngine.lambda$submitRequest$3(AbstractEngine.java:171)
at com.intellij.database.console.AbstractEngine.lambda$submitRunnable$2(AbstractEngine.java:148)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

I also tried to add a persistence.xml configuration but I get the same error.

My components and configuration:

  1. Spring: 4.2.7
  2. Spring orm 4.1.9
  3. Db: PostgreSQL 9.5
  4. Hibernate jpa 2.1
  5. Lombok 1.16.10

Entity manager conf:

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(...);
emf.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
emf.setPackagesToScan(...);
emf.setJpaProperties(...);
emf.setPersistenceUnitName(...);
return emf;
}

Example entity conf:
@Getter
@Setter
@Entity
@NoArgsConstructor
@Table(schema = ..., name = "....")
public class ExampleClass extends AbstractEntity

Abstract Entity contains:

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID", nullable = false, updatable = false, unique = true)

 

Where I should look for the problem?

2 comments
Comment actions Permalink

The meaning of the exception and the reason are explained here https://github.com/spring-projects/spring-boot/issues/1065 , https://github.com/spring-projects/spring-boot/issues/1696#issuecomment-58862103

So, the exception is thrown when in your project hibernate is trying to find some calss which is referenced in one of the annotations, used in the application but the class is not in the classpath. Check your module dependencies for this class dependency and application JavaConfig, may be you could locate this annotation.

0

Please sign in to leave a comment.