Note that there are some explanatory texts on larger screens.

plurals
  1. POJBoss 7 throwing Entity is not mapped when using @PersistenceContext
    text
    copied!<p>I'm using Spring/JPA/Hibernate 3 in an application that <em>runs just fine in Tomcat 7</em> but fails in JBoss AS 7. I'm using the @PersistenceContext annotation to inject my entity manager in the DAOs but I get the <strong>"Entity is not mapped"</strong> exception when running a query. I DO NOT want JBoss to manage my persistence context and I'm using classpath scanning to construct my LocalContainerEntityManagerFactoryBean. I've tried disabling the jpa module from the JBoss standalone.xml and even adding a jboss-deployment-structure.xml with this content:</p> <pre><code>&lt;jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"&gt; &lt;deployment&gt; &lt;exclusions&gt; &lt;module name="org.hibernate"/&gt; &lt;/exclusions&gt; &lt;/deployment&gt; &lt;/jboss-deployment-structure&gt; </code></pre> <p>It still doesn't work. What's the cause of this exception? Why does JBoss still try to manage my persistence context?</p> <p>P.S.: By default I get a strange PU definition (the PU root url is not my war!)</p> <pre><code>(MSC service thread 1-3) insurance-module 17:51:41.456 [MSC service thread 1-3] DEBUG org.hibernate.ejb.Ejb3Configuration - Processing PersistenceUnitInfo [ 17:51:41,456 INFO [stdout] (MSC service thread 1-3) name: default 17:51:41,456 INFO [stdout] (MSC service thread 1-3) persistence provider classname: null 17:51:41,456 INFO [stdout] (MSC service thread 1-3) classloader: ModuleClassLoader for Module "deployment.insurance-module-0.1-SNAPSHOT.war:main" from Service Module Loader 17:51:41,457 INFO [stdout] (MSC service thread 1-3) Temporary classloader: org.springframework.instrument.classloading.SimpleThrowawayClassLoader@13acaabd 17:51:41,457 INFO [stdout] (MSC service thread 1-3) excludeUnlistedClasses: true 17:51:41,457 INFO [stdout] (MSC service thread 1-3) JTA datasource: null 17:51:41,457 INFO [stdout] (MSC service thread 1-3) Non JTA datasource: com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -&gt; 3, acquireRetryAttempts -&gt; 30, acquireRetryDelay -&gt; 1000, autoCommitOnClose -&gt; false, automaticTestTable -&gt; null, breakAfterAcquireFailure -&gt; false, checkoutTimeout -&gt; 0, connectionCustomizerClassName -&gt; null, connectionTesterClassName -&gt; com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -&gt; z8kfsx8l1ikdpo61c3bmxu|6b5638a, debugUnreturnedConnectionStackTraces -&gt; false, description -&gt; null, driverClass -&gt; com.mysql.jdbc.Driver, factoryClassLocation -&gt; null, forceIgnoreUnresolvedTransactions -&gt; false, identityToken -&gt; z8kfsx8l1ikdpo61c3bmxu|6b5638a, idleConnectionTestPeriod -&gt; 60, initialPoolSize -&gt; 3, jdbcUrl -&gt; jdbc:mysql://localhost:3306/insurance, maxAdministrativeTaskTime -&gt; 0, maxConnectionAge -&gt; 0, maxIdleTime -&gt; 60, maxIdleTimeExcessConnections -&gt; 0, maxPoolSize -&gt; 5, maxStatements -&gt; 0, maxStatementsPerConnection -&gt; 0, minPoolSize -&gt; 1, numHelperThreads -&gt; 3, numThreadsAwaitingCheckoutDefaultUser -&gt; 0, preferredTestQuery -&gt; select 1, properties -&gt; {user=******, password=******}, propertyCycle -&gt; 0, testConnectionOnCheckin -&gt; false, testConnectionOnCheckout -&gt; false, unreturnedConnectionTimeout -&gt; 0, usesTraditionalReflectiveProxies -&gt; false ] 17:51:41,457 INFO [stdout] (MSC service thread 1-3) Transaction type: RESOURCE_LOCAL 17:51:41,457 INFO [stdout] (MSC service thread 1-3) PU root URL: file:/home/mircea/jboss-as-7.0.2.Final/modules/sun/jdk/main/service-loader-resources/ 17:51:41,457 INFO [stdout] (MSC service thread 1-3) Shared Cache Mode: UNSPECIFIED 17:51:41,457 INFO [stdout] (MSC service thread 1-3) Validation Mode: AUTO 17:51:41,457 INFO [stdout] (MSC service thread 1-3) Jar files URLs [] 17:51:41,457 INFO [stdout] (MSC service thread 1-3) Managed classes names [] 17:51:41,457 INFO [stdout] (MSC service thread 1-3) Mapping files names [] 17:51:41,457 INFO [stdout] (MSC service thread 1-3) Properties [] 17:51:41,459 INFO [stdout] (MSC service thread 1-3) insurance-module 17:51:41.459 [MSC service thread 1-3] DEBUG org.hibernate.ejb.Ejb3Configuration - Detect class: true; detect hbm: true 17:51:41,462 INFO [stdout] (MSC service thread 1-3) insurance-module 17:51:41.462 [MSC service thread 1-3] DEBUG o.h.ejb.packaging.AbstractJarVisitor - Searching mapped entities in jar/par: file:/home/mircea/jboss-as-7.0.2.Final/modules/sun/jdk/main/service-loader-resources/ </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload