开发者

grails war java.sql.SQLException: Io exception: Invalid number format for port number

Strange problem - we build a grails project on windows and it works fine, but on a unix machine getting:

java.sql.SQLException: Io exception: Invalid number format for port number
(stack trace below)

Pretty strange as we define the datasource to come from jndi:

DataSource.groovy:

envName {
        dataSource {
            dbCreate = "none"
            jndiName = "java:comp/env/jdbc/ourDataSource"
            dialect="org.hibernate.dialect.Oracle10gDialect"
        }

The jndi is handled by a setting in context.xml on the application server:

 <Resource name="jdbc/ourDataSource" 
       auth="Container" 
       type="javax.sql.DataSource" 
       username="OUR_DB_USERNAME" 
       password="OUR_DB_PASSWORD" 
       driverClassName="oracle.jdbc.OracleDriver"
       url="jdbc:oracle:thin:@host:1521:sid" 
       maxActive="8" 
       maxIdle="4"/>

We would expect the build to be environment agnostic. Examining the deltas:

Both are using slightly different versions of the JDK - 1.6.0_21 on unix, 1.6.0_22 on windows. Assume this wouldn't be a factor.

We are using grails 3.5.1 for both.

Debugging I've expanded WAR files generated by grails on the unix machine and on the windows machine and by default it didn't include lots of JAR dependencies in WEB-INF/lib but without complaint. I added these by setting a JAR dependency in Config.groovy so they are now present but the build WEB-INF/classes seem to differ.

Running low on ideas - any suggestions would be much appreciated.

grails command to build on unix:

grails -Dgrails.env=envName war OUR.WAR

Full stacktrace is:

ERROR  initWebApplicationContext, Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io exception: Invalid number format for port number)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: 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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io exception: Invalid number format for port number)
    ... 5 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io exception: Invalid number format for port number)
    ... 5 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io exception: Invalid number format for port number)
    ... 5 more
Caused by: org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionF开发者_开发问答actory (Io exception: Invalid number format for port number)
    ... 5 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io exception: Invalid number format for port number)
    at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at $Proxy22.getMetaData(Unknown Source)
    ... 5 more
Caused by: java.sql.SQLException: Io exception: Invalid number format for port number
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
    at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:439)
    at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
    at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
    at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
    at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
    at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
    ... 7 more

Annoyingly all the java/maven builds have been straightforward migrations - but grails uses ivy rather than maven - hopefully the vmware/springsource guys will provide full maven integration in future negating these sorts of difficulties.

But any help now would be great - or suggestions for other things to debug


Solution: add java.sql.SQLException breakpoint

I've solved this. In eclipse added breakpoint on java.sql.SQLException. Looking up through the stack it had picked up the wrong configuration in DataSource.groovy; in turn the -Dgrails.env argument in Hudson was not being picked up. Painful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜