-
1. Re: Trouble Using <s:convertEntity/> on Glassfish
thejavafreak Jun 3, 2007 10:13 PM (in response to soluble)Are you using Toplink or Hibernate?
I think the problem comes from your persistence layer. Go and check your persistence.xml settings or paste it here so others can help you finding out the solution -
2. Re: Trouble Using <s:convertEntity/> on Glassfish
soluble Jun 4, 2007 6:08 PM (in response to soluble)My persistence layer uses Hibernate as the provider and is the exact one from the Glassfish example that comes with the jboss-seam-1.2.1.GA download:
<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="bookingDatabase"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>jdbc/__default</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.transaction.flush_before_completion" value="true"/> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/> </properties> </persistence-unit> </persistence>
In fact the only difference my app has to the glassfish example is that I have added a few more session beans and facelets.
I should also mention that a few more stack traces also come up such as:Parent -> EJBClassLoader : urlSet = [] doneCalled = false Parent -> java.net.URLClassLoader@ce16ad was requested to find class org.hibernate.event.EventListenersBeanInfo after done was invoked from the following stack trace java.lang.Throwable at com.sun.enterprise.loader.EJBClassLoader.findClassData(EJBClassLoader.java:707) at com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.java:627) ...
andParent -> EJBClassLoader : urlSet = [] doneCalled = false Parent -> java.net.URLClassLoader@ce16ad was requested to find class org.hibernate.util.CloneableBeanInfo after done was invoked from the following stack trace java.lang.Throwable at com.sun.enterprise.loader.EJBClassLoader.findClassData(EJBClassLoader.java:707) at com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.java:627) ...
andjavax.persistence.PersistenceException: org.hibernate.HibernateException: Could not instantiate dialect class at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720) ... Caused by: java.lang.ClassCastException: org.hibernate.dialect.DerbyDialect cannot be cast to org.hibernate.dialect.Dialect at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:78) ...
I hope this helps. -
3. Re: Trouble Using <s:convertEntity/> on Glassfish
soluble Jun 5, 2007 3:50 PM (in response to soluble)Looking futher at the configuration I have discovered that just adding
<core:entity-manager-factory name="dbFactory" persistence-unit-name="bookingDatabase"/>
to the components.xml file in the Glassfish example of jboss-seam-1.2.1.GA causes all the errors in the previous post. On examination of the org.jboss.seam.core.EntityManagerFactory source code I found that there is a requirement for EntityManagerFactory to use the Seam microcontainer:@Scope(ScopeType.APPLICATION) @Intercept(NEVER) @Startup(depends="org.jboss.seam.core.microcontainer") public class EntityManagerFactory { private String persistenceUnitName; ...
I am pretty certain that I should not need to use the microcontainer in Glassfish v2 as it is EE compliant. Could the problem I am having be related to
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=106649
and
http://jira.jboss.org/jira/browse/JBSEAM-1195
If so is there any way around it or will I have to use the Seam microcontainer with Glassfish to get <s:convertEntity/> working? -
4. Re: Trouble Using <s:convertEntity/> on Glassfish
gavin.king Jun 5, 2007 4:58 PM (in response to soluble)You have misunderstood the semantics of @Startup(depends=...).
Check the JavaDoc, and the line about "if it is installed".
Bottom line: you do not need MC to use an SMPC in glassfish. -
5. Re: Trouble Using <s:convertEntity/> on Glassfish
soluble Jun 5, 2007 8:40 PM (in response to soluble)Thanks for the clarification. Seam really does have some neat features!
I am trying to get to the root of my problem so have reverted to using the "jboss-seam-1.2.1.GA/examples/glassfish" example. I tried adding<core:entity-manager-factory name="dbFactory" persistence-unit-name="bookingDatabase"/>
to the components.xml file expecting the example app to still work. However I got the following error:javax.persistence.PersistenceException: java.lang.NullPointerException at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:252) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:96) at org.jboss.seam.core.EntityManagerFactory.startup(EntityManagerFactory.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ...
Does anyone know what config I should tweak to get the entity-manager-factory working on the glassfish example? I suspect it is a visibility problem with the persistence.xml file and associated entities. However, it is late and I would like to stop experimenting for the night. Maybe once that works, I can try thinking about <s:convertEntity/> again. ;) -
6. Re: Trouble Using <s:convertEntity/> on Glassfish
epbernard Jun 5, 2007 9:19 PM (in response to soluble)Hi,
Before digging more, try and update to HEM 3.3.1
Download the package and copy
cp $HEM_HOME/lib/hibernate-annotations.jar $JBOSSAS_HOME/client
cp $HEM_HOME/lib/hibernate-annotations.jar $HEM_HOME/server/default/lib
cp $HEM_HOME/lib/hibernate-entitymanager.jar $JBOSSAS_HOME/server/default/lib
cp $HEM_HOME/lib/hibernate-commons-annotations.jar $JBOSSAS_HOME/server/default/lib
cp $HEM_HOME/lib/hibernate-validator.jar $JBOSSAS_HOME/server/default/lib
Or accordingly for glassfish -
7. Re: Trouble Using <s:convertEntity/> on Glassfish
soluble Jun 7, 2007 7:31 PM (in response to soluble)epbernard, thank you for your advice. I had a go but it did not seem to fix my problem. The Glassfish log file just came up with another error again resulting in a Context startup failed due to previous errors.
However, I did manage to get <s:convertEntity/> working on the Glassfish example in jboss-seam-1.2.1.GA! In the process it did expose peculiar behaviour of Glassfish and/or Seam which I though might be beneficial to share.
Apart from adding an EVENT scoped stateless bean, persistence entity and facelet file to test the <s:convertEntity/> the only changes I made to the example configuration were as follows:
1) persistence.xml - I added a transaction type and transaction manager to the persistence unit:... <persistence-unit name="bookingDatabase" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>jdbc/__default</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.transaction.flush_before_completion" value="true"/> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/> </properties> </persistence-unit> ...
2) components.xml - I added the config to create an entity manager factory, create an entity manager and then pass it to the entity converter. (Looking at the code, I probably do not need to pass the entity manager to the entity converter.)... <core:entity-manager-factory name="dbFactory" persistence-unit-name="bookingDatabase"/> <core:managed-persistence-context name="entityManager" auto-create="true" entity-manager-factory="#{dbFactory}"/> <core:entity-converter entity-manager="${entityManager}"/> ...
You may realise that this is almost the setup I had with the first post of this thread (apart from the transaction manager). The peculiar behaviour is that in order to add the changes I wanted to the components.xml file, I cannot simply rebuild the app with ant and do the following:
asadmin undeploy jboss-seam-glassfish
asadmin deploy jboss-seam-glassfish.ear
This always produces a Context startup failed due to previous errors with varying stack traces in the Glassfish server.log.
I must do the following to guarantee successful deployment:
asadmin undeploy jboss-seam-glassfish
asadmin stop-domain
<Manually delete \glassfish\domains\domain1\applications\j2ee-apps\jboss-seam-glassfish directory>
asadmin start-domain
asadmin deploy jboss-seam-glassfish.ear
Therefore I cannot hot deploy. To me it seems like a bug in Glassfish which Seam exposes that forces me to stop and start the domain in order to redeploy the application. Something is probably remaining within Glassfish after the undeploy command. Is anyone able to reproduce this problem? (Just get the glassfish example, add the transaction manager to the persistence.xml file and deploy to glassfish. Then add the changes to the components.xml file and redeploy without restarting. The example should fail to work.) -
8. Re: Trouble Using <s:convertEntity/> on Glassfish
epbernard Jun 7, 2007 9:15 PM (in response to soluble)If you manage to reproduce the NullPointerException in the EntityManager 3.3.x, I'm interested in the stacktrace, so that I can understand what's going on