JPA Console with entities in external jar file
已回答
Hi,
I've got some problems trying to run queries with JPA Console. I have all of my entities defined in an external jar file linked in my persistence.xml :
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="primary">
<jta-data-source>java:/jboss/datasources/LOGICATESTDS</jta-data-source>
<jar-file>lib/xdbLogicaEntity.jar</jar-file>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.connection.characterEncoding" value="utf8"/>
<property name="hibernate.connection.useUnicode" value="true"/>
<property name="hibernate.connection.charSet" value="UTF-8"/>
<property name="hibernate.enable_lazy_load_no_trans" value="true"/>
<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="25000"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.c3p0.max_statements" value="500"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServer2008Dialect"/>
</properties>
</persistence-unit>
</persistence>
When I open up the persistence panel everything is ok, I can see and navigate my PU and all of my entities.
But when I try to run a simple query I got this error:
[2017-10-10 18:04:13] javax.persistence.PersistenceException: Unable to build entity manager factory
[2017-10-10 18:04:13] java.lang.IllegalArgumentException: File [lib/xdbLogicaEntity.jar] referenced by given URL [file:lib/xdbLogicaEntity.jar] does not exist
I tried to move the jar in every possible path but got no solution.
Can somebody help me please?
请先登录再写评论。
What is the full stacktrace? What Hibernate version do you use? Does it work if specify full path to the jar? Please check also this thread: https://stackoverflow.com/q/31107835/2000323