NutzCN Logo
问答 请问nutz框架部署到tomcat上需要修改数据吗??
发布于 2693天前 作者 qq_4e5959f6 1667 次浏览 复制 上一个帖子 下一个帖子
标签:

在本地写了一个nutz框架信息,然后部署到没有eclipse的tomcat上就报错,数据库连接不上,显示《using password no!!!但是单独写一个mysql连接就能在tomcat上连接数据库

24 回复

数据库配置文件没找到?

        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:
265)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
        at sun.reflect.GeneratedConstructorAccessor36.newInstance(Unknown Sourc
)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown So
rce)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.jav
:325)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnect
on(DruidAbstractDataSource.java:1375)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnect
on(DruidAbstractDataSource.java:1431)
        at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(Dr
idDataSource.java:1888)
2017-08-09 10:52:57,051 com.alibaba.druid.pool.DruidDataSource$CreateConnection
hread.run(DruidDataSource.java:1890) ERROR - create connection error, url: jdbc
mysql://localhost:3306/public_0_1
java.sql.SQLException: Access denied for user ''@'localhost' (using password: No
)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3887)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3823)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870)
        at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(My
sqlIO.java:1659)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:
265)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
        at sun.reflect.GeneratedConstructorAccessor36.newInstance(Unknown Sourc
)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown So
rce)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.jav
:325)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnect
on(DruidAbstractDataSource.java:1375)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnect
on(DruidAbstractDataSource.java:1431)
        at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(Dr
idDataSource.java:1888)

用户名没有,密码没有, 目测是配置文件没加载上, 写错路径了?

可是我再本机上可以运行跑起来呀,我打包成war到tomcat下就出现这个问题

所以是路径问题, 贴dao.js(通常是conf所在的文件)看看

        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:
265)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
        at sun.reflect.GeneratedConstructorAccessor36.newInstance(Unknown Sourc
)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown So
rce)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.jav
:325)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnect
on(DruidAbstractDataSource.java:1375)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnect
on(DruidAbstractDataSource.java:1431)
        at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(Dr
idDataSource.java:1888)
2017-08-09 10:52:57,051 com.alibaba.druid.pool.DruidDataSource$CreateConnection
hread.run(DruidDataSource.java:1890) ERROR - create connection error, url: jdbc
mysql://localhost:3306/public_0_1
java.sql.SQLException: Access denied for user ''@'localhost' (using password: N
)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3887)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3823)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870)
        at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(M
sqlIO.java:1659)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:
265)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
        at sun.reflect.GeneratedConstructorAccessor36.newInstance(Unknown Sourc
)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown So
rce)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.jav
:325)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnect
on(DruidAbstractDataSource.java:1375)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnect
on(DruidAbstractDataSource.java:1431)
        at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(Dr
idDataSource.java:1888)
var ioc = {
		conf : {
            type : "org.nutz.ioc.impl.PropertiesProxy",
            fields : {
                paths : ["custom/"]
            }
        },
        backendDataSource : {
            type : "com.alibaba.druid.pool.DruidDataSource",
            events : {
                create : "init",
                depose : 'close'
            },
            fields : {
                url : {java:"$conf.get('db.backend.url')"},
                username : {java:"$conf.get('db.backend.username')"},
                password : {java:"$conf.get('db.backend.password')"},
                testWhileIdle : true,
                validationQuery : {java:"$conf.get('db.backend.validationQuery')"},
                maxActive : {java:"$conf.get('db.backend.maxActive')"}
            }
        },
        backendDao : {
            type : "org.nutz.dao.impl.NutDao",
            args : [{refer:"backendDataSource"}]
        },
        dao : {
        	 type : "org.nutz.dao.impl.NutDao",
             args : [{refer:"backendDataSource"}]
        },
      
        
        gameServerDataSource : {
            type : "com.alibaba.druid.pool.DruidDataSource",
            events : {
                create : "init",
                depose : 'close'
            },
            fields : {
                url : {java:"$conf.get('db.game_server.url')"},
                username : {java:"$conf.get('db.game_server.username')"},
                password : {java:"$conf.get('db.game_server.password')"},
                testWhileIdle : true,
                validationQuery : {java:"$conf.get('db.game_server.validationQuery')"},
                maxActive : {java:"$conf.get('db.game_server.maxActive')"}
            }
        },
        gameServerDao : {
            type : "org.nutz.dao.impl.NutDao",
            args : [{refer:"gameServerDataSource"}]
        },
        daoData: {
            type : "org.nutz.dao.impl.NutDao",
            args : [{refer:"gameServerDataSource"}]
        },
        
        
        publicServerDataSource : {
            type : "com.alibaba.druid.pool.DruidDataSource",
            events : {
                create : "init",
                depose : 'close'
            },
            fields : {
                url : {java:"$conf.get('db.public.url')"},
                username : {java:"$conf.get('db.public.username')"},
                password : {java:"$conf.get('db.public.password')"},
                testWhileIdle : true,
                validationQuery : {java:"$conf.get('db.public.validationQuery')"},
                maxActive : {java:"$conf.get('db.public.maxActive')"}
            }
        },
        daoPublic:{
            type : "org.nutz.dao.impl.NutDao",
            args : [{refer:"publicServerDataSource"}]
        },
        
        
        playerInfoServerDataSource:{
        	 type : "com.alibaba.druid.pool.DruidDataSource",
             events : {
                 create : "init",
                 depose : 'close'
             },
             fields : {
                 url : {java:"$conf.get('fot.url')"},
                 username : {java:"$conf.get('fot.username')"},
                 password : {java:"$conf.get('fot.password')"},
                 testWhileIdle : true,
                 validationQuery : {java:"$conf.get('fot.validationQuery')"},
                 maxActive : {java:"$conf.get('fot.maxActive')"}
             }
        },
        daoPlayerInfo:{
        	type : "org.nutz.dao.impl.NutDao",
            args : [{refer:"playerInfoServerDataSource"}]
        },
        logDao : {
       	 type : "org.nutz.dao.impl.NutDao",
            args : [{refer:"playerInfoServerDataSource"}]
       },
};

custom的完整路径是什么?

demo/javaResources/custom

maven项目?? 普通JavaEE项目??

demo/javaResources/conf/custom
demo/javaResources/conf/ioc

javaResources是源文件夹?? 然后conf也是源文件夹? 嵌套了?

不会吧!!conf是我加进去的,和src源文件夹平行的!!

哦,神奇的结构, 按你的说法就是
demo/javaREsources/src
demo/javaREsources/conf/custom
demo/javaREsources/conf/ioc
检查一下war文件里面的 WEB-INF/classes下有无custom目录, 如果有,检查里面的properties文件

不过挺神奇的, jdbc url读到了,但用户名和密码没有读到, 不在同一个文件内??

在呀!!里面的文件也是全的!!也完成,就是那里没有读到用户名和密码!!!

会不会在tomcat下面需要修改什么东西啊???我本机上没问题,服务器上的数据库连接也没问题,可是把这个项目部署到tomcat下后就读不到了!!公司也没人用nutz,所以只能求大神帮忙了

启动日志贴来看看,看到读到什么了

啊??我那边服务器上没有eclipse!!贴不出来吧??

tomcat有日志文件的

有个办法可以测试一下, 把war里面的custom目录中对应的properties文件删掉, 看看报错有何不同

如果没有变化,证明还有其他custom目录存在, 或者在某个jar文件内

话说, 你本地没有tomcat吗? 本地重现一下嘛

我把那个public数据库中的东西都注了,然后就可以跑起来!!!!我马上重现一下

添加回复
请先登陆
回到顶部