Note that there are some explanatory texts on larger screens.

plurals
  1. POPersistence.xml and OSGi (Equinox)
    text
    copied!<p>I am currently testing out using OSGi. I am running this through Eclipse. I want to have my DAO layer as part of an OSGi solution, but my first stumbling block is this error:</p> <pre><code>Jun 29, 2009 6:12:37 PM org.hibernate.cfg.annotations.Version &lt;clinit&gt; INFO: Hibernate Annotations 3.3.0.GA Jun 29, 2009 6:12:37 PM org.hibernate.ejb.Version &lt;clinit&gt; INFO: Hibernate EntityManager 3.3.0.GA Jun 29, 2009 6:12:37 PM org.hibernate.ejb.Ejb3Configuration configure INFO: Could not find any META-INF/persistence.xml file in the classpath </code></pre> <p>I have tried putting the persistence.xml file in a lot of different places, to no avail. <strong>Any ideas on what I am doing wrong?</strong> </p> <p><strong>Is there a way to manually load the persistence.xml?</strong></p> <p>The <strong>activator</strong> looks like this:</p> <pre><code>package com.activator; public class PersistenceActivator implements BundleActivator { @Override public void start(BundleContext arg0) throws Exception { EntityManagerFactory emf = Persistence .createEntityManagerFactory("postgres"); EntityManager em = emf.createEntityManager(); SimpleDaoImpl dao = new SimpleDaoImpl(); dao.setEntityManager(em); } @Override public void stop(BundleContext arg0) throws Exception { // TODO Auto-generated method stub } } </code></pre> <p>Here is what my directory structure looks like:</p> <p><a href="http://www.freeimagehosting.net/uploads/7b7b7d2d30.jpg">alt text http://www.freeimagehosting.net/uploads/7b7b7d2d30.jpg</a></p> <p>Here is my <strong>Manifest.MF</strong></p> <pre><code>Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Dao Plug-in Bundle-SymbolicName: Dao Bundle-Version: 1.0.0 Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: org.osgi.framework;version="1.4.0" Bundle-Activator: com.activator.PersistenceActivator Export-Package: com.dao.service Require-Bundle: HibernateBundle;bundle-version="1.0.0" </code></pre> <p><strong>HibernateBundle</strong> contains all of the Hibernate and Persistence Jars.</p> <p>Here is my <strong>Persistence.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;persistence&gt; &lt;!-- Sample persistence using PostgreSQL. See postgres.txt. --&gt; &lt;persistence-unit name="postgres" transaction-type="RESOURCE_LOCAL"&gt; &lt;properties&gt; &lt;property name="hibernate.archive.autodetection" value="class" /&gt; &lt;!-- Comment out if schema exists &amp; you don't want the tables dropped. --&gt; &lt;property name="hibernate.hbm2ddl.auto" value="create-drop" /&gt; &lt;!-- drop/create tables @startup, drop tables @shutdown --&gt; &lt;!-- Database Connection Settings --&gt; &lt;property name="hibernate.connection.autocommit"&gt;true&lt;/property&gt; &lt;property name="hibernate.connection.driver_class" value="org.postgresql.Driver" /&gt; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /&gt; &lt;property name="hibernate.connection.username" value="postgres" /&gt; &lt;property name="hibernate.connection.password" value="postgres" /&gt; &lt;property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/test" /&gt; &lt;!-- Not sure about these... --&gt; &lt;property name="hibernate.max_fetch_depth"&gt;16&lt;/property&gt; &lt;property name="hibernate.jdbc.batch_size"&gt;1000&lt;/property&gt; &lt;property name="hibernate.use_outer_join"&gt;true&lt;/property&gt; &lt;property name="hibernate.default_batch_fetch_size"&gt;500&lt;/property&gt; &lt;!-- Hibernate Query Language (HQL) parser. --&gt; &lt;property name="hibernate.query.factory_class"&gt; org.hibernate.hql.ast.ASTQueryTranslatorFactory&lt;/property&gt; &lt;!-- Echo all executed SQL to stdout --&gt; &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt; &lt;property name="hibernate.format_sql"&gt;false&lt;/property&gt; &lt;!-- Use c3p0 for the JDBC connection pool --&gt; &lt;property name="hibernate.c3p0.min_size"&gt;3&lt;/property&gt; &lt;property name="hibernate.c3p0.max_size"&gt;100&lt;/property&gt; &lt;property name="hibernate.c3p0.max_statements"&gt;100&lt;/property&gt; &lt;property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" /&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; &lt;/persistence&gt; </code></pre> <p>Things I have tried in the Manifest's Classpath with no luck: </p> <p><strong>Bundle-ClassPath: ., META-INF/persistence.xml</strong> </p> <p><strong>Bundle-ClassPath: ., ../META-INF/persistence.xml</strong></p> <p><strong>Bundle-ClassPath: ., /META-INF/persistence.xml</strong></p> <p><strong>Bundle-ClassPath: ., ./META-INF/persistence.xml</strong></p> <p><strong>Bundle-ClassPath: ., META-INF</strong></p> <p><strong>Bundle-ClassPath: ., ../META-INF</strong></p> <p><strong>Bundle-ClassPath: ., /META-INF</strong></p> <p><strong>Bundle-ClassPath: ., ./META-INF</strong></p> <p><strong>Bundle-ClassPath: ., C:\Workspaces\OSGiJPA\Dao\META-INF\persistence.xml</strong></p> <p><strong>Bundle-ClassPath: ., C:\Workspaces\OSGiJPA\Dao\META-INF</strong></p>
 

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