Error JBAS011440 with JBoss 7.1.1: persistence unit not found
maulattu May 14, 2012 10:58 AMHi all,
I'm developing a simple example with jboss 7.1.1 under Windows using persistence APIs.
The database driver installation (both postgres as well as mysql) were ok, as well as the datasource creation:
...
16:18:02,496 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.0)
16:18:02,507 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
...
16:18:03,314 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [ java : jboss / datasources / hibernatepg]
16:18:03,314 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) JBAS010400: Bound data source [java : jboss / datasources / ExampleDS]
16:18:03,445 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source [java:/MySqlDS]
I created the persistence.xml file under META-INF directory:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="persistenceUnit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/MySqlDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
</persistence>
Even following these tutorials:
https://community.jboss.org/message/715357#715357
http://www.mastertheboss.com/jboss-application-server/50-jboss-entity-bean.html
There's no way to let reachable this datasource in a singleton ejb:
@Singleton
public class SingletonBean {
...
@PersistenceContext(unitName = "persistenceUnit")
private EntityManager em;
...
}
In fact I've this error related to such datasource:
JBAS011440: Can't find a persistence unit named persistenceUnit in deployment "persistence.jar"
Even if I call the datasource "java:/MySqlDS" with name "persistenceUnit" (now it has name "MySqlDS_Pool") there's no way to have a working and deployable jar file
Any advice please?
thank you all guys!