One step forward.... I double checked and you were correct. I updated the MANIFEST.MF in the embedded-glassfish-all.jar in my local maven repository, but I guess I failed to give jar the -m argument because the manifest was missing the entry. So I updated it again, and verified that the edit was present and the container loaded without issue.
To outline a bit more, I am attempting to build with maven. My project structure is that of a simple jar file.
pom.xml
src/
src/main/java/
......... my java classes (jpa entities, dao classes)
src/main/resources/
......... my spring configuration files
src/test/java/
......... my JUnit test cases
src/test/resources/
......... my spring context.xml files
src/test/resources/org/glassfish/embed/domain.xml
I made my AppTest.java class a @Stateless EJB because the application would not load otherwise. I got an exception stating the my dataSource could not be located with a JNDI lookup. Of course my lookup was occurring within my spring context.
I have a persistence.xml defined in src/main/resources/META-INF/persistence.xml, and I have the following defined in it:
<persistence-unit name="my-pu" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
Because I don't actually have an EJB project or any EJB's (other than the AppTEst class), I chose to define the following in my Spring test-applicationContext.xml.
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaDialect">
<bean
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
</property>
<property name="persistenceUnitName" value="survey-pu"/>
<property name="persistenceUnitManager">
<bean
class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"/>
</property>
</bean>
This is because my Dao classes require an EntityManager and I didn't know of any way to have the container inject it into them as they are not defined as EJB's.
public abstract class BaseDaoImpl<T, PK extends java.io.Serializable>
implements BaseDao<T, PK> {
protected JpaTemplate jpaTemplate;
@PersistenceContext
public void setEntityManager(EntityManager entityManager) {
jpaTemplate = new JpaTemplate(entityManager);
}
Everything appears to be working correctly now; the container loads, the dataSource is located, and my test code is executed to test the dao classes. The issue I have now is that my inserts are not committing to the database. EclipseLink is loaded and appears to be functional but nothing is persisted to the database tables. I've added a call to EntityManager.flush() after my call to EntityManager.persist(), but this results in an exception from EclipseLink stating:
org.springframework.dao.InvalidDataAccessApiUsageException:
Exception Description: No transaction is currently active; nested exception is javax.persistence.TransactionRequiredException:
Exception Description: No transaction is currently active
So I'm guessing that this might have something to do with the EntityManagerFactory I have defined in Spring:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
But then this raises the question of how can I get access to the EntityManager bound in JNDI from the defined persistence.xml in the application seeing as I don't have any EJB's within my project?
Thanks for the help....
[Message sent by forum member 'fericit_bostan']
http://forums.java.net/jive/thread.jspa?messageID=475202