Problems configuring Seam 2.1.x with Glassfish+Derby
andrewilms Jan 19, 2009 8:27 PMHey Seam-experts,
I'm a newbie regarding Seam so please forgive my dumb question. I got the book "Seam In Action" (Dan Allan) and study the examples project "open18". Everythings works fine with JBoss 4.2.2 and the H2 database. I'm impressed.
The future project at work needs Glassfish, though. So I tried to migrate that seam-gen created projected to the current Glassfish/Derby versions. I used the instructions from various sources but none of them really work for me.
So when I try to start the application in my browser, I get a stacktrace with a few interesting lines:
Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: entityManager
...
Caused by: java.lang.IllegalArgumentException: could not set property value: entityManager.setPersistenceUnitJndiName
...
Caused by: java.lang.IllegalArgumentException: Could not invoke method by reflection: ManagedPersistenceContext.setPersistenceUnitJndiName(java.lang.String) with parameters: (org.hibernate.ejb.EntityManagerFactoryImpl) on: org.jboss.seam.persistence.ManagedPersistenceContext
The components.xml contains these lines (and many more):
<transaction:ejb-transaction/>
<core:init debug = "@debug@"
jndi-pattern = "java:comp/env/open18/#{ejbName}/local" />
<core:manager concurrent-request-timeout = "500"
conversation-timeout = "120000"
conversation-id-parameter = "cid"
parent-conversation-id-parameter = "pid" />
< persistence:entity-manager-factory
name = "open18EntityManagerFactory"
persistence-unit-name = "open18" />
< persistence:managed-persistence-context
name = "entityManager"
auto-create = "true"
persistence-unit-jndi-name = "#{open18EntityManagerFactory}" />
Here are the last few lines of the web.xml:
ejb-local-ref>
<ejb-ref-name>open18/EjbSynchronizations/local</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home></local-home>
<local>
org.jboss.seam.transaction.LocalEjbSynchronizations
</local>
<ejb-link>EjbSynchronizations</ejb-link>
</ejb-local-ref >
And here is the important part of the persistence-dev.xml:
<persistence-unit name="open18">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/__default</jta-data-source>
<properties>
<!-- The following two properties are for Glassfish -->
<property name = "hibernate.dialect"
value = "org.hibernate.dialect.DerbyDialect" />
<property name ="hibernate.transaction.manager_lookup_class"
value = "org.hibernate.transaction.SunONETransactionManagerLookup" />
<property name = "hibernate.hbm2ddl.auto" value = "update" />
<property name = "hibernate.show_sql" value = "true" />
<property name = "hibernate.format_sql" value = "true" />
<property name = "hibernate.cache.provider_class"
value = "org.hibernate.cache.HashtableCacheProvider" />
</properties>
</persistence-unit>
Does anybody know how to fix our problem? Any (!) help is VERY appreciated. Two collegues and I looked in every corner of the internet but we just can't find the solution ..
Thank you,
Andre
I'm a newbie regarding Seam so please forgive my dumb question. I got the book "Seam In Action" (Dan Allan) and study the examples project "open18". Everythings works fine with JBoss 4.2.2 and the H2 database. I'm impressed.
The future project at work needs Glassfish, though. So I tried to migrate that seam-gen created projected to the current Glassfish/Derby versions. I used the instructions from various sources but none of them really work for me.
So when I try to start the application in my browser, I get a stacktrace with a few interesting lines:
Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: entityManager
...
Caused by: java.lang.IllegalArgumentException: could not set property value: entityManager.setPersistenceUnitJndiName
...
Caused by: java.lang.IllegalArgumentException: Could not invoke method by reflection: ManagedPersistenceContext.setPersistenceUnitJndiName(java.lang.String) with parameters: (org.hibernate.ejb.EntityManagerFactoryImpl) on: org.jboss.seam.persistence.ManagedPersistenceContext
The components.xml contains these lines (and many more):
<transaction:ejb-transaction/>
<core:init debug = "@debug@"
jndi-pattern = "java:comp/env/open18/#{ejbName}/local" />
<core:manager concurrent-request-timeout = "500"
conversation-timeout = "120000"
conversation-id-parameter = "cid"
parent-conversation-id-parameter = "pid" />
< persistence:entity-manager-factory
name = "open18EntityManagerFactory"
persistence-unit-name = "open18" />
< persistence:managed-persistence-context
name = "entityManager"
auto-create = "true"
persistence-unit-jndi-name = "#{open18EntityManagerFactory}" />
Here are the last few lines of the web.xml:
ejb-local-ref>
<ejb-ref-name>open18/EjbSynchronizations/local</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home></local-home>
<local>
org.jboss.seam.transaction.LocalEjbSynchronizations
</local>
<ejb-link>EjbSynchronizations</ejb-link>
</ejb-local-ref >
And here is the important part of the persistence-dev.xml:
<persistence-unit name="open18">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/__default</jta-data-source>
<properties>
<!-- The following two properties are for Glassfish -->
<property name = "hibernate.dialect"
value = "org.hibernate.dialect.DerbyDialect" />
<property name ="hibernate.transaction.manager_lookup_class"
value = "org.hibernate.transaction.SunONETransactionManagerLookup" />
<property name = "hibernate.hbm2ddl.auto" value = "update" />
<property name = "hibernate.show_sql" value = "true" />
<property name = "hibernate.format_sql" value = "true" />
<property name = "hibernate.cache.provider_class"
value = "org.hibernate.cache.HashtableCacheProvider" />
</properties>
</persistence-unit>
Does anybody know how to fix our problem? Any (!) help is VERY appreciated. Two collegues and I looked in every corner of the internet but we just can't find the solution ..
Thank you,
Andre