-
1. Re: JBAS011440: Can't find a persistence unit named null in deployment "test.war"
david.salter Mar 12, 2012 1:11 PM (in response to david.salter)The full error is:
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."test.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".INSTALL: Failed to process phase INSTALL of deployment "test.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_147-icedtea]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_147-icedtea]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_147-icedtea]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class xxx.ManagerBean for component ManagerBean has errors:
JBAS011440: Can't find a persistence unit named null in deployment "test.war"
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:169)
at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:162)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:155)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
-
2. Re: JBAS011440: Can't find a persistence unit named null in deployment "test.war"
aslak Mar 12, 2012 1:54 PM (in response to david.salter)1 of 1 people found this helpfuladdAsManifestResource in a WebArchive will place it under /META-INF
Try using addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml") -> /WEB-INF/classes/ + META-INF/persistence.xml
-
3. Re: JBAS011440: Can't find a persistence unit named null in deployment "test.war"
david.salter Mar 12, 2012 2:41 PM (in response to aslak)That works perfectly. Thanks very much
-
4. Re: JBAS011440: Can't find a persistence unit named null in deployment "test.war"
snoa May 31, 2012 2:42 PM (in response to david.salter)Hi, David, I have a similar situation, I'll explain it: I have 3 projects
- Project Web (deployed as a .war)
- Project EJB (deployed as a .jar)
- Project JPA v2 (deployed as a .jar too)
The problem appear when I try to connect my EJB v3.1 with my JPA v2.0, this were the steps I followed:
- All projects were builds successfully in Eclipse Indigo.
- The JPA project was exported as jar and deployed to JBossAS 7.1.0
- When I tried to export the EJB project to a jar in JBossAS I receive --> JBAS011440: Can't find a persistence unit named EntityProject in deployment "Manager.jar"
In the EJB project I have used EntityManager like this:
@PersistenceContext(unitName="EntityProject")
private EntityManager em;
In my JPA project I have generated all the classes from an Oracle DB (v11g), this is my persistance.xml:
<?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="EntityProject">
<jta-data-source>java:/OracleDS</jta-data-source>
<class>org.package.X</class>
<class>org.package.Y</class>
<class>org.package.Z</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:db"/>
<property name="hibernate.default_schema" value="user"/>
<property name="hibernate.connection.username" value="user"/>
<property name="hibernate.connection.password" value="passw"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
Also, all my projects are independents, they don't belong to any EAR project.
Please, I would appreciate some help,
Sandy...
-
5. Re: JBAS011440: Can't find a persistence unit named null in deployment "test.war"
antonior14 Sep 2, 2016 6:22 AM (in response to david.salter)same issue for me I can't run a Junit Test using Arquillian on Wildfly 8...
this is my test:
@RunWith(Arquillian.class)
public class GenericDaoTest {
@Inject
private EmployeeService employeeService;
@Deployment
public static JavaArchive createTestableDeployment() {
final JavaArchive jar = ShrinkWrap
.create(JavaArchive.class)
.addPackage("service")
.addPackage("service.impl")
.addAsManifestResource("META-INF/persistence.xml",
"persistence.xml, test-persistence.xml")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addPackage("entity");
return jar;
}
@Test
public void should_crud() {
assertNotNull(employeeService);
Employee initialSize = employeeService.findById(new Integer(1));
}
}
Datastore for mysql has been created and test successful
Service classes has writed as below:
@Local
public interface GenericService<T, PK extends Serializable>{
T findById(PK id);
}
------------------------------------------------------------------------------------------------------------------------------------------------
@Local
public interface EmployeeService extends
GenericService<Employee,Integer> {
}
------------------------------------------------------------------------------------------------------------------------------------------------
@Stateless(name = "GenericServiceImpl", mappedName = "GenericServiceImpl")
public class GenericServiceImpl<T, PK extends Serializable> implements
GenericService<T, PK> {
@PersistenceContext(unitName = "timesheet")
protected EntityManager entityManager;
private Class<T> entityClass;
public GenericServiceImpl() {
}
public GenericServiceImpl(Class<T> entityClass) {
this.entityClass = entityClass;
}
@Override
public T findById(PK id) {
return entityManager.find(entityClass, id);
}
}
------------------------------------------------------------------------------------------------------------------------------------------------
A test-persistence,xml has been created too:
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/Timesheet</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
But it doesn't work with this error:
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"test.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"test.war\".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment \"test.war\" Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0041: Component class service.impl.GenericServiceImpl for component EmployeeServiceImpl has errors: WFLYJPA0033: Can't find a persistence unit named timesheet in deployment \"test.war\""},
"WFLYCTL0180: Services with missing/unavailable dependencies" => [ "jboss.deployment.unit.\"test.war\".batch.environment is missing [jboss.deployment.unit.\"test.war\".beanmanager]", "jboss.deployment.unit.\"test.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"test.war\".beanmanager]" ] }
Thanks a lot
-
6. Re: JBAS011440: Can't find a persistence unit named null in deployment "test.war"
antonior14 Sep 12, 2016 2:49 PM (in response to antonior14)solved creating a test persistence xml importing into my junit test as following:
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="PU-NAME">
<jta-data-source>java:jboss/datasources/MyDatasource</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
and added with .addAsResource method in junit test