1
votes

I have written two little hello world applications using Grails (V2.0.0.RC1), and I want to deploy them using Glassfish (v3.1).

If I deploy it either one of the applications all by itself on Glassfish the application works just fine, and I can access it either at http://t1-0.1 or at http://t2-0.1. If instead, however, I deploy one of the applications, and then deploy the other (so that both are available to people visiting my web site), then the second deployment command gives me the following error message:

c:>asadmin deploy t2-0.1.war

remote failure: Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Errorcreating bean with name 'hibernateProperties': Cannot resolve reference to bean'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init methodfailed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Database may be already in use: "Locked by another process". Possible solutions: closeall other connection(s); use the server mode; SQL statement:null/1349c415392c6dc06a3e7086cd1bb075c7881fc0650 [90020-147]). Please see server.log for more details.

What's going on here? I presume that there is something peculiar about Grails and its use of Hibernate (since otherwise Glassfish wouldn't complain about allowing me to have two applications that work together). But maybe I'm misreading the error message? Does anybody have any recommendations?

1
can you please post your glassfish persistence provider config? Normally an application accesses the db over the glassfish api not directly - I guess the problem lies somewhere here. Your Grails DB config would also be very helpful.k-deux

1 Answers

0
votes

It turns out that the problem lay in my misuse of the default configuration provided by Grails. In the file DataSource.groovy each application is given a pointer to a database, and by default that pointer looks like this:

development {
    dataSource {
        dbCreate = "create-drop" 
        url = "jdbc:h2:mem:devDb;MVCC=TRUE"
    }
}

The problem is that multiple applications will be given identical configurations, and the underlying memory-based h2 database references between the multiple applications conflict. Therefore, the solution for a couple of "hello world" example applications is to change one of those references. For example:

development {
    dataSource {
        dbCreate = "create-drop" 
        url = "jdbc:h2:mem:devDb2;MVCC=TRUE"
    }
}

Of course, in production code you will likely end up referencing a real database, and then your applications will naturally cooperate in their database references.