grails war java.sql.SQLException:Io exception:端口号的数字格式无效

时间:2011-05-26 20:17:01

标签: unix grails build environment war

奇怪的问题 - 我们在Windows上构建了一个grails项目,它工作正常,但在unix机器上得到:

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

我们定义来自jndi的数据源非常奇怪:

DataSource.groovy中:

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

jndi由应用程序服务器上的context.xml中的设置处理:

 <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"/>

我们希望构建与环境无关。检查增量:

两者在UNIX上使用略有不同版本的JDK - 1.6.0_21,在Windows上使用1.6.0_22。假设这不是一个因素。

我们正在使用grails 3.5.1。

调试我在unix机器和windows机器上扩展了grails生成的WAR文件,默认情况下它没有包含WEB-INF / lib中的大量JAR依赖项,但没有抱怨。我通过在Config.groovy中设置JAR依赖项来添加这些,所以它们现在存在,但构建WEB-INF / classes似乎有所不同。

缺乏想法 - 任何建议都会受到高度赞赏。

grails命令构建在unix上:

grails -Dgrails.env=envName war OUR.WAR

完整的堆栈跟踪是:

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 PoolableConnectionFactory (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

令人讨厌的是,所有的java / maven构建都是简单的迁移 - 但是grails使用的是常春藤而不是maven - 希望vmware / springsource的人们将来会提供完整的maven集成来消除这些困难。

但现在任何帮助都会很棒 - 或建议其他事情进行调试

1 个答案:

答案 0 :(得分:1)

解决方案:添加java.sql.SQLException断点

我已经解决了这个问题。在eclipse中,在java.sql.SQLException上添加了断点。通过堆栈向上看,它在DataSource.groovy中找到了错误的配置;反过来,Hudson中的-Dgrails.env参数没有被提取。痛苦。