Could not resolve a persistence unit

166 views
Skip to first unread message

r...@i2m.dk

unread,
Sep 10, 2012, 12:51:23 PM9/10/12
to kaleid...@googlegroups.com
I'v added the kaleido-jee6 dependency, trying to deploy to Glassfish v3

<dependency>
            <groupId>org.kaleidofoundry</groupId>
            <artifactId>kaleido-jee6</artifactId>
            <version>0.8.1</version>
            <scope>compile</scope>
</dependency>

and getting this error:

SEVERE: Exception while preparing the app : Could not resolve a persistence unit corresponding to the persistence-context-ref-name [org.kaleidofoundry.core.config.ConfigurationManagerBean/em] in the scope of the module called [dk.i2m_starreports_war_1.0-SNAPSHOT]. Please verify your application.

Tried creating a persistence unit with the unit name KaleidoPersistentContextUnitName but still getting that same error.
 

jraduget

unread,
Sep 10, 2012, 3:21:55 PM9/10/12
to kaleid...@googlegroups.com

The name of the persistence unit is "kaleido". You will need to add to your META-INF/persistence.xml :


<persistence-unit name="kaleido" transaction-type="JTA" >


<jta-data-source>jdbc/kaleido</jta-data-source>


<!-- entities declarations -->

<class>org.kaleidofoundry.core.store.entity.ResourceHandlerEntity</class>

<class>org.kaleidofoundry.core.i18n.entity.I18nMessage</class>

<class>org.kaleidofoundry.core.i18n.entity.I18nMessageGroup</class>

<class>org.kaleidofoundry.core.i18n.entity.I18nMessageLanguage</class>

<class>org.kaleidofoundry.core.config.entity.ConfigurationModel</class>

<class>org.kaleidofoundry.core.config.entity.ConfigurationProperty</class>


<exclude-unlisted-classes>true</exclude-unlisted-classes>

</persistence-unit>


Then, you will need to create a datasource and the database model (only the first time). To do this, run the following command from your glasshfish instance:

cd $GLASSFISH_HOME/bin/

asadmin create-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource --restype javax.sql.XADataSource --property portNumber=1527:password=APP:user=APP:serverName=localhost:databaseName=kaleido:connectionAttributes=\;create\\=true  kaleidoPool

asadmin create-jdbc-resource --connectionpoolid kaleidoPool jdbc/kaleido

asadmin list-jdbc-connection-pools

asadmin ping-connection-pool kaleidoPool



It will use the derby database embedded in glassfish :)

When we use kaleido-core configuration / i18n components, this datasource and database model should not be mandatory to create, I will correct this point.

Thank you for your feedback, I will enrich the wiki to start with glassfish

Please use the last 0.8.2 or 0.9.0-SNAPHOT version ;-)

--
Jérôme

jraduget

unread,
Sep 11, 2012, 5:53:49 AM9/11/12
to kaleid...@googlegroups.com
To correct some missings in my previous answer :

With glassfish and derby, use a persitence.xml like :

<?xml version="1.0" encoding="UTF-8"?>
version="1.0">

<persistence-unit name="kaleido" transaction-type="JTA" >

<jta-data-source>jdbc/kaleido</jta-data-source>

<!-- entities declarations -->
<class>org.kaleidofoundry.core.store.entity.ResourceHandlerEntity</class>
<class>org.kaleidofoundry.core.i18n.entity.I18nMessage</class>
<class>org.kaleidofoundry.core.i18n.entity.I18nMessageGroup</class>
<class>org.kaleidofoundry.core.i18n.entity.I18nMessageLanguage</class>
<class>org.kaleidofoundry.core.config.entity.ConfigurationModel</class>
<class>org.kaleidofoundry.core.config.entity.ConfigurationProperty</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-database" value="Derby" />
<property name="eclipselink.logging.level" value="INFO" />
<property name="eclipselink.logging.level.sql" value="INFO" />
<property name="eclipselink.logging.timestamp" value="false" />
<property name="eclipselink.logging.session" value="false" />
<property name="eclipselink.logging.thread" value="false" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>

</persistence-unit>

</persistence>

Then start derby / glassfish database, create datasource, and deploy your war / ear : 

asadmin start-database
asadmin create-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource --restype javax.sql.XADataSource --property portNumber=1527:password=APP:user=APP:serverName=localhost:databaseName=kaleido:connectionAttributes=\;create\=true  kaleidoPool
asadmin create-jdbc-resource --connectionpoolid kaleidoPool jdbc/kaleido
asadmin deploy --dbvendorname=javadb --createtables=true yourApplication.war


Regards,

Reply all
Reply to author
Forward
0 new messages