play2war / play2-war-plugin

WAR Plugin for Play framework 2.x
Apache License 2.0
443 stars 71 forks source link

How to deploy play framework 2.4 application on glassfish and read application.conf? #300

Open satomikko94 opened 8 years ago

satomikko94 commented 8 years ago

Same question is at stackoverflow : http://stackoverflow.com/questions/34738905/how-to-deploy-play-framework-2-4-application-on-glassfish-and-read-application-c

I tried to deploy play framework 2.4 application on glassfish4. I used maven play2 plugin and play2 war plugin made war file with the following instruction.

https://play2-maven-plugin.github.io/play2-maven-plugin/1.0.0-beta4/war-packaging.html

After that, I tried to deploy my war from glassfish console, but it returned the following error.

Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: 
ContainerBase.addChild: start: org.apache.catalina.LifecycleException: com.google.inject.CreationException: 
Unable to create injector, see the following errors: 
1) Error in custom provider, Configuration error: Configuration error
[Cannot connect to database [default]] while locating play.api.db.DBApiProvider while locating play.api.db.DBApi for parameter 0 
at play.db.DefaultDBApi.<init>(DefaultDBApi.java:28) 
at play.db.DefaultDBApi.class(DefaultDBApi.java:28) while locating play.db.DefaultDBApi while locating play.db.DBApi for field 
at play.db.DBModule$NamedDatabaseProvider.dbApi(DBModule.java:61) while locating play.db.DBModule$NamedDatabaseProvider 
at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149) 
at play.db.DBModule.bindings(DBModule.java:40): Binding(interface play.db.Database qualified with QualifierInstanc .... msg.seeServerLog

The following is the part of full log.

Caused by: Configuration error: Configuration error[Exception during pool initialization]
    at play.api.Configuration$.configError(Configuration.scala:178)
    at play.api.PlayConfig.reportError(Configuration.scala:1048)
    at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:69)
    at play.api.db.PooledDatabase.createDataSource(Databases.scala:199)
    at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:124)
    at play.api.db.DefaultDatabase.dataSource(Databases.scala:122)
    at play.api.db.DefaultDatabase.getConnection(Databases.scala:143)
    at play.api.db.DefaultDatabase.getConnection(Databases.scala:139)
    at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:44)
    ... 130 more
Caused by: com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
    at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:542)
    at com.zaxxer.hikari.pool.BaseHikariPool.<init>(BaseHikariPool.java:171)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:60)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:48)
    at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:80)
    at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:58)
    at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:54)
    at scala.util.Try$.apply(Try.scala:191)
    at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54)
    ... 136 more
Caused by: java.sql.SQLException: JDBC4 Connection.isValid() method not supported, connection test query must be configured
    at com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:441)
    at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:540)
    ... 144 more

3) Error in custom provider, java.lang.NullPointerException
  at play.db.DBModule.bindings(DBModule.java:40):
Binding(interface play.db.Database qualified with QualifierInstance(@play.db.NamedDatabase(value=default)) to ProviderTarget(play.db.DBModule$NamedDatabaseProvider@34850279)) (vi
a modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
  while locating play.db.Database annotated with @play.db.NamedDatabase(value=default)

My conf/application.conf is here:

db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:@url..."
db.default.username=username
db.default.password=password

It works on local environment. I think glassfish can't read application.conf in war file.

Could you give me the advice?

dlecan commented 8 years ago

Where is located Oracle driver ? Is it compatible with JDBC v4 ?