<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
UNRESOLVED Demands 'persistence.unit:unitName=...
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/drake2711">Matthias Becker</a> in <i>EJB3</i> - <a href="http://community.jboss.org/message/595352#595352">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  i am new to JBoss and EJBs in general so plase help <span> :) </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  Every time i try to deploy my application i get erros indicateing that the persistance unit cannot be found:</p><ul><li>UNRESOLVED Demands 'persistence.unit:unitName=EsbMonitorEAR-0.0.1-SNAPSHOT.ear/#EsbMonitorPU' **</li><li>14:51:40,882 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=<strong>persistence.unit:unitName=EsbMonitorEAR-0.0.1-SNAPSHOT.ear/#EsbMonitorPU</strong> state=Create: javax.persistence.PersistenceException: [PersistenceUnit: EsbMonitorPU] class or package not found</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>and the following kind of demands:</p><ul><li>and demands:<br/>14:51:27,287 INFO  [org.jboss.ejb3.deployers.JBossASKernel]     persistence.unit:unitName=<strong>EsbMonitorEAR-0.0.1-SNAPSHOT.ear/#EsbMonitorPU</strong>; Required: Described</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>where does this name come from?</p><p>The persistence.xml (i had to place it in the META-INF of the EAR-file) looks like this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><?xml version="1.0" encoding="UTF-8"?></span>
<span class="jive-xml-tag"><span><persistence version="2.0" xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span>" xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>" xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span> </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" target="_blank">http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd</a><span>"></span></span>
  <span class="jive-xml-tag"><persistence-unit name="EsbMonitorPU" transaction-type="JTA"></span>
    <span class="jive-xml-tag"><jta-data-source></span>java:jdbc/esb_monitor_dev<span class="jive-xml-tag"></jta-data-source></span>
    <span class="jive-xml-tag"><class></span>...<span class="jive-xml-tag"></class></span>
    <span class="jive-xml-tag"><exclude-unlisted-classes></span>false<span class="jive-xml-tag"></exclude-unlisted-classes></span>
    <span class="jive-xml-tag"><properties></span>
      <span class="jive-xml-tag"><property name="eclipselink.ddl-generation" value="create-tables"/></span>
      <span class="jive-xml-tag"><property name="hibernate.hbm2ddl.auto" value="update" /></span>
      <span class="jive-xml-tag"><property name="jboss.entity.manager.jndi.name" value="java:/EsbMonitorPU"/></span>
      <span class="jive-xml-tag"><property name="jboss.entity.manager.factory.jndi.name" value="java:/EsbMonitorPUFactory"/></span>
    <span class="jive-xml-tag"></properties></span>
  <span class="jive-xml-tag"></persistence-unit></span>
<span class="jive-xml-tag"></persistence></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This is the DS-File wich is localed in the server\default\deploy directory:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml">
<span class="jive-xml-tag"><datasources></span>
   <span class="jive-xml-tag"><local-tx-datasource></span>
      <span class="jive-xml-comment"><!-- The jndi name of the DataSource, it is prefixed with java:/ -->
      <!-- Datasources are not available outside the virtual machine -->
      <span class="jive-xml-tag"><jndi-name></span>jdbc/esb_monitor_dev<span class="jive-xml-tag"></jndi-name></span>
      <!-- for in-process persistent db, saved when jboss stops. The
      org.jboss.jdbc.DerbyDatabase mbean is necessary for properly db shutdown -->
      <span class="jive-xml-tag"><connection-url></span>jdbc:derby://localhost:3301/esb_monitor_dev;create=true<span class="jive-xml-tag"></connection-url></span>
      <!-- The driver class -->
      <span class="jive-xml-tag"><driver-class></span>org.apache.derby.jdbc.ClientDriver<span class="jive-xml-tag"></driver-class></span>
      <!-- The login and password -->
      <span class="jive-xml-tag"><user-name></span>ESB<span class="jive-xml-tag"></user-name></span>
      <span class="jive-xml-tag"><password></span>sa<span class="jive-xml-tag"></password></span>
      <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
      <span class="jive-xml-tag"><min-pool-size></span>5<span class="jive-xml-tag"></min-pool-size></span>
      <!-- The maximum connections in a pool/sub-pool -->
      <span class="jive-xml-tag"><max-pool-size></span>20<span class="jive-xml-tag"></max-pool-size></span>
      <!-- The time before an unused connection is destroyed -->
      <span class="jive-xml-tag"><idle-timeout-minutes></span>5<span class="jive-xml-tag"></idle-timeout-minutes></span>
      <!-- Whether to check all statements are closed when the connection is returned to the pool,
           this is a debugging feature that should be turned off in production -->
      <span class="jive-xml-tag"><track-statements/></span>
      <!-- This mbean can be used when using in process persistent derby --></span>
   <span class="jive-xml-tag"></local-tx-datasource></span>
<span class="jive-xml-tag"></datasources></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>And this is how i refer to the PUs:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-java">    @PersistenceUnit(unitName=<font color="red">"EsbMonitorPU"</font>)
    <font color="navy"><b>private</b></font> EntityManagerFactory factory;
 
    @PersistenceContext(unitName = <font color="red">"EsbMonitorPU"</font>)
    <font color="navy"><b>private</b></font> EntityManager em;
 
    <font color="navy"><b>protected</b></font> <font color="navy"><b>final</b></font> EntityManager getEntityManager() <font color="navy">{</font>
        <font color="navy"><b>if</b></font> (em == <font color="navy"><b>null</b></font>) <font color="navy">{</font>
            em = factory.createEntityManager();
        <font color="navy">}</font>
        <font color="navy"><b>return</b></font> em;
    <font color="navy">}</font>
 
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I assembled all this code from various sources in the iNet but nothing works so far.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Any Ideas? How ist this courios "<strong>EsbMonitorEAR-0.0.1-SNAPSHOT.ear/#EsbMonitorPU</strong>" name assembled? Is my Maven configuration responsible for that? If so i dont understand how...</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I use JBoss 6.0.0Final</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thank you</p><p>BTW: If i run it directly from Eclipse, everything works fine...</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/595352#595352">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB3 at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>