You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 28 Members of 4510 |
| Forum: Seam Users |
12. Mar 2008, 04:21 CET | Link |
This is driving me nuts but I sense that I almost have the last piece in the puzzle ... can anyone help me?
Summary: I have built a complex Seam application and it runs great on JBoss AS 4.2. Now I need to have it run on Tomcat 6.
I followed the instructions as they are laid out in the wiki: 1. I installed JBoss Embedded to Tomcat 2. I added the listeners to server.xml and context.xml 3. I set-up my my persistence, hibernate and components files
-------------------- components.xml ------------------
<persistence:hibernate-session-factory name="hibernateSessionFactory"/>
<persistence:managed-hibernate-session name="gadb" auto-create="true" session-factory-jndi-name="java:/gadb"/>
<transaction:hibernate-transaction session="#{gadb}"/>
<factory name="session" scope="STATELESS" auto-create="true" value="#{entityManager.delegate}"/>
-------------------- persistence.xml ------------------
<persistence-unit name="gadb" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/gaDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
</properties>
</persistence-unit>
------------------- hibernate.cfg.xml -----------------
<session-factory name="java:/gadb">
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.datasource">java:/gaDatasource</property>
<property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="transaction.flush_before_completion">true</property>
<property name="connection.release_mode">after_statement</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
----------------- Code to access the Session ----------------------------
@In Session gadb;
My application fires up and everything parses successfully, but when the SeamListener goes after the datasource it simply cannot find it:
SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
org.hibernate.HibernateException: Could not find datasource: java:/gaDatasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:59)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
I'd REALLY appreciate help on this as I have being on this for 3 days already!!
I don't think, this is a seam-related problem. Did you configure the data source in tomcat? You had to configure it in JBoss too, right?
I'm not sure whether you can just deploy something similar to a JBoss xxx-ds.xml file on Tomcat, but you can look for the configuration of Tomcat's resource factory in the tomcat documentation on JDBC data sources in JNDI.
Hi!
I have a very similar problem. Since the deployment of my complex seam project on Tomcat didn't work I tried it this way: I set up a new (virtual) machine with Win XP Pro SP2, Tomcat 6.0.16 and Seam 2.0.1.GA (and JBoss AS 4.2.2.GA). Then I created a completely new Seam project with seam-gen. Even this simple project could not be deployed (although I didn't change the source). The main problem is, that the persistence unit can be found (same problem as above). I also tried to use JBoss Embedded Beta 3, but this leads to even more problems with contexts. So it would be great if somebody could shortly explain which steps have to be done to get a (newly created) seam project deploy on Tomcat, especially how this naming problems can be solved.
Thank you very much!
I was my understanding that since Tomcat's JNDI is read-only, it is not usable and once JBoss Embedded is installed, that is the JNDI provider. Therefore, providing a context for Tomcat is unnecessary.
I forgot to provide info on where I define my JDBC. I put it in a file called hibernate-ds.xml:
<datasources> <local-tx-datasource> <jndi-name>gaDatasource</jndi-name> <connection-url>jdbc:mysql://vijay:3306/xxx</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>xx</user-name> <password>xx</password> </local-tx-datasource> </datasources>Also, here are the versions of the software:
Here are some relevant excerpts from my log. First the JBoss Embedded stuff. NOTE: This shows that the ConnectionFactoryBindingService successfully bound gaDatasource to JNDI (java:gaDatasource), and then started a persistence unit with name gadb.
WARN [org.jboss.mx.loading.UnifiedLoaderRepository3] Tried to add non-URLClassLoader. Ignored WARN [org.jboss.aop.deployment.AspectManagerService] Could not find base-aspects.xml file in the resources of org.apache.catalina.loader.StandardClassLoader@b6ece5 INFO [org.jboss.aop.deployers.AspectDeployer] Deploying xml into org.jboss.aop.AspectManager@77baf4 for org.apache.catalina.loader.StandardClassLoader@b6ece5 INFO [org.jboss.resource.deployers.RARDeployment] Required license terms exist, view vfsfile:/C:/apache-tomcat-6.0.14/lib/deploy/jboss-local-jdbc.rar/META-INF/ra.xml INFO [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS' INFO [org.jboss.resource.deployers.RARDeployment] Required license terms exist, view vfsfile:/C:/apache-tomcat-6.0.14/lib/deploy/jboss-xa-jdbc.rar/META-INF/ra.xml INFO [org.jboss.resource.deployers.RARDeployment] Required license terms exist, view vfsfile:/C:/apache-tomcat-6.0.14/lib/deploy/jms-ra.rar/META-INF/ra.xml WARN [org.jboss.jms.server.security.SecurityMetadataStore] WARNING! POTENTIAL SECURITY RISK. It has been detected that the MessageSucker component which sucks messages from one node to another has not had its password changed fro m the installation default. Please see the JBoss Messaging user guide for instructions on how to do this. INFO [org.jboss.jms.server.ServerPeer] JBoss Messaging 1.4.0.SP1 server [0] started INFO [org.jboss.jms.server.connectionfactory.ConnectionFactory] Connector bisocket://bevans:4457 has leasing enabled, lease period 10000 milliseconds INFO [org.jboss.jms.server.connectionfactory.ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@1d22ddb started WARN [org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper] supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clust ered. So connection factory will *not* support failover WARN [org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper] supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balancing INFO [org.jboss.jms.server.connectionfactory.ConnectionFactory] Connector bisocket://bevans:4457 has leasing enabled, lease period 10000 milliseconds INFO [org.jboss.jms.server.connectionfactory.ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@9aa764 started INFO [org.jboss.jms.server.destination.QueueService] Queue[/queue/DLQ] started, fullSize=200000, pageSize=2000, downCacheSize=2000 INFO [org.jboss.jms.server.destination.QueueService] Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000 INFO [org.jboss.jms.server.connectionfactory.ConnectionFactory] Connector bisocket://bevans:4457 has leasing enabled, lease period 10000 milliseconds INFO [org.jboss.jms.server.connectionfactory.ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@30cd64 started INFO [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA' Mar 12, 2008 7:26:20 AM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Mar 12, 2008 7:26:20 AM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.14 Mar 12, 2008 7:26:20 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive newRiskApp.war Mar 12, 2008 7:26:20 AM org.apache.catalina.loader.WebappLoader start INFO: Dual registration of jndi stream handler: factory already defined INFO [org.jboss.ejb3.deployers.PersistenceUnitParsingDeployer] Found persistence units [org.jboss.ejb3.metadata.jpa.spec.PersistenceUnitMetaData@30cefd{name=gadb}] WARN [org.jboss.xb.builder.runtime.CollectionPropertyHandler] ClassInfo.getDeclaredConstructor(null) didn't work for org.jboss.metadata.ejb.spec.InterceptorClassesMetaData, found the default ctor in ClassInfo.getDeclaredConstruct ors() INFO [org.jboss.ejb3.deployers.AppClientScanningDeployer] mainClass = class com.lowagie.tools.ToolboxAvailable INFO [org.jboss.ejb3.deployers.AppClientScanningDeployer] mainClass = class org.jboss.cache.Version INFO [org.jboss.ejb3.deployers.AppClientScanningDeployer] mainClass = class org.jboss.kernel.plugins.bootstrap.standalone.StandaloneBootstrap INFO [org.jboss.ejb3.deployers.AppClientScanningDeployer] mainClass = class org.jgroups.Version INFO [org.jboss.ejb3.MCKernelAbstraction] installing bean: jboss.j2ee:jar=jboss-seam.jar,name=TimerServiceDispatcher,service=EJB3 with dependencies: INFO [org.jboss.ejb3.MCKernelAbstraction] and supplies: INFO [org.jboss.ejb3.MCKernelAbstraction] Class:org.jboss.seam.async.LocalTimerServiceDispatcher INFO [org.jboss.ejb3.EJBContainer] STARTED EJB: org.jboss.seam.async.TimerServiceDispatcher ejbName: TimerServiceDispatcher WARN [org.jboss.ejb3.timerservice.jboss.JBossTimerServiceFactory] TIMER SERVICE IS NOT INSTALLED INFO [org.jboss.ejb3.MCKernelAbstraction] installing bean: jboss.j2ee:jar=jboss-seam.jar,name=EjbSynchronizations,service=EJB3 with dependencies: INFO [org.jboss.ejb3.MCKernelAbstraction] and supplies: INFO [org.jboss.ejb3.MCKernelAbstraction] Class:org.jboss.seam.transaction.LocalEjbSynchronizations INFO [org.jboss.ejb3.EJBContainer] STARTED EJB: org.jboss.seam.transaction.EjbSynchronizations ejbName: EjbSynchronizations INFO [org.jboss.ejb3.MCKernelAbstraction] installing bean: persistence.units:unitName=gadb with dependencies: INFO [org.jboss.ejb3.MCKernelAbstraction] and supplies: INFO [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=gaDatasource' to JNDI name 'java:gaDatasource' INFO [org.jboss.ejb3.entity.PersistenceUnitDeployment] Starting persistence unit persistence.units:unitName=gadb INFO [org.hibernate.cfg.annotations.Version] Hibernate Annotations 3.3.1.Beta1 INFO [org.hibernate.cfg.Environment] Hibernate 3.2.4.sp1 INFO [org.hibernate.cfg.Environment] hibernate.properties not found INFO [org.hibernate.cfg.Environment] Bytecode provider name : javassist INFO [org.hibernate.cfg.Environment] using JDK 1.4 java.sql.Timestamp handling INFO [org.hibernate.ejb.Version] Hibernate EntityManager 3.3.2.Beta1 INFO [org.hibernate.ejb.Ejb3Configuration] Processing PersistenceUnitInfo [ name: gadb ...] WARN [org.hibernate.ejb.Ejb3Configuration] Persistence provider caller does not implement the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.After this, the hibernate.cfg.xml file is read and here is where it should pick up the JNDI configured JDBC, but it fails:
It is then later that the SeamListener tries to get a handle that failure is fatal.
By the way, don't think I didn't try using a Tomcat context.xml file.
First I tried using that and the hibernate-ds.xml file. When I did this I got a conflict:
ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=jboss.jca:name=comp/env/jdbc/gaDatasource,service=DataSourceBinding state=Create mode=Manual requiredState=Installed org.jboss.deployment.DeploymentException: Could not bind ConnectionFactory into jndi: java:comp/env/jdbc/gaDatasource at org.jboss.resource.connectionmanager.ConnectionFactoryBindingService.bindConnectionFactory(ConnectionFactoryBindingService.java:164) ... Caused by: javax.naming.NameAlreadyBoundException; remaining name 'comp' at org.jnp.server.NamingServer.createSubcontext(NamingServer.java:465) at org.jnp.interfaces.NamingContext.createSubcontext(NamingContext.java:1059)Then, I tried with JUST the context.xml (no hibernate-ds file) and got the following:
java.lang.RuntimeException: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS): *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State} persistence.units:unitName=gadb -> <UNKNOWN>{Described:** UNRESOLVED Demands 'jboss.jca:name=comp/env/jdbc/gaDatasource,service=DataSourceBinding **} *** CONTEXTS IN ERROR: Name -> Error <UNKNOWN> -> ** UNRESOLVED Demands 'jboss.jca:name=comp/env/jdbc/gaDatasource,service=DataSourceBinding **Ok, I think the hibernate warning:
... is a red fish, because when I change the value of 'connection.datasource' to something completely invalid, I get:
So, the problem must lie in how Seam is interacting with Hibernate.
Here's the full exception I get:
Come on SEAM experts, throw me a bone! I'm dying here!
I'd just like to throw in a here - regarding the missing dependencies problem.
I can't seem to find anywhere any documentation as to how to get a Seam project set up with a datasource in Tomcat.. certainly not for a project created with seam-gen.
(I am using the embedded-jboss-beta3 btw)
Copy the -ds.xml into the deploy folder.
All the Seam examples do this when you deploy to tomcat.
Read about how to report a bug.
I am getting a similar error. However I haven't installed the EJ3 embedded component but I have seen a JPA example in the examples directory of Seam distribution that has I was able to successfully deploy on Tomcat 6 without the embedded EB3. No errors!.
Only when I try to deploy a Seam application build using the Seam Web Project plug-in for Eclipse and that too without installing the embedded EJB3 component that I get the datasource not found error.
I haven't tried packaging the Seam Web Project eclipse plug-in application using ant into a war file and seeing the result. I will be trying that soon.
Your help in this matter will help us select our technology stack at UCLA for our Financial department. Seam is the frontrunner in this evaluation process but it has to run on Tomcat 6 without embedded JBoss!
Regards Raj