NutzCN Logo
问答 NUTZ连接MSSQL的问题
发布于 2928天前 作者 qq_6ebbba40 2634 次浏览 复制 上一个帖子 下一个帖子
标签:

严重: Exception starting filter nutz
org.nutz.mvc.LoadingException: org.nutz.ioc.IocException: [dao, dataSource] # FAIL to create Ioc Bean name=[dataSource]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
at org.nutz.lang.Mirror.born(Mirror.java:990)
at org.nutz.lang.Lang.wrapThrow(Lang.java:196)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:135)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4659)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.nutz.ioc.IocException: [dao, dataSource] # FAIL to create Ioc Bean name=[dataSource]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:146)
at net.wendal.nutzbook.MainSetup.init(MainSetup.java:18)
at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:277)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:121)
... 15 more
Caused by: java.lang.RuntimeException: Fail to eval Injector for field: 'events'
at org.nutz.lang.Lang.wrapThrow(Lang.java:163)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:128)
... 24 more
Caused by: java.lang.RuntimeException: java.lang.NoSuchFieldException: Can NOT find field [events] in class [com.alibaba.druid.pool.DruidDataSource] and it's parents classes
at org.nutz.lang.Lang.wrapThrow(Lang.java:180)
at org.nutz.lang.Mirror.getInjecting(Mirror.java:1048)
at org.nutz.ioc.weaver.FieldInjector.create(FieldInjector.java:18)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:125)
... 24 more
Caused by: java.lang.NoSuchFieldException: Can NOT find field [events] in class [com.alibaba.druid.pool.DruidDataSource] and it's parents classes
at org.nutz.lang.Mirror.getField(Mirror.java:476)
at org.nutz.lang.Mirror.getInjecting(Mirror.java:1039)
... 26 more

十二月 16, 2016 2:00:33 下午 org.apache.catalina.core.StandardContext startInternal
严重: One or more Filters failed to start. Full details will be found in the appropriate container log file
十二月 16, 2016 2:00:33 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/nutzbook] startup failed due to previous errors
十二月 16, 2016 2:00:33 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-nio-8090"]
十二月 16, 2016 2:00:33 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-nio-8009"]
十二月 16, 2016 2:00:33 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 3654 ms

11 回复

dao.js写错了, events 与 fields是平级的

var ioc = {
dataSource : {
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
create : "init",
depose : 'close'
},
fields : {
url : "jdbc:sqlserver://localhost:1433;databaseName=nutzbook",
username : "as",
password : "Yuboinfo@#123abc",
testWhileIdle : true, // 非常重要,预防mysql的8小时timeout问题
validationQuery : "select 1" , // Oracle的话需要改一下
maxActive : 100
}
},
dao : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource"}]
}
};
这是我的代码

按"插入代码",重新贴

现在Tomcat一半就卡住提示无法启动,这是什么问题
Server Tomcat v8.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.

对着 http://nutzbook.wendal.net/setup30mins/add_daojson.html 抄一个,用户名和密码能怎么简单怎么来.

警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:nutzbook' did not find a matching property.
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/8.0.30
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Dec 1 2015 22:30:46 UTC
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 8.0.30.0
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 7
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 6.1
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: x86
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: C:\Program Files (x86)\Java\jre1.8.0_25
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_25-b18
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: E:\weixin.metadata.plugins\org.eclipse.wst.server.core\tmp0
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: D:\apache-tomcat-8.0.30
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=E:\weixin.metadata.plugins\org.eclipse.wst.server.core\tmp0
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\apache-tomcat-8.0.30
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=E:\weixin.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:\apache-tomcat-8.0.30\endorsed
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=GBK
十二月 16, 2016 2:34:02 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8090"]
十二月 16, 2016 2:34:02 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
十二月 16, 2016 2:34:02 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
十二月 16, 2016 2:34:02 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
十二月 16, 2016 2:34:02 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 937 ms
十二月 16, 2016 2:34:03 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
十二月 16, 2016 2:34:03 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.0.30
十二月 16, 2016 2:34:03 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [391] milliseconds.
十二月 16, 2016 2:34:05 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
log4j:WARN No appenders could be found for logger (org.nutz.mvc.NutFilter).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

要么把log4j.jar删了, 要么把log4j配置好

log4j.properties

log4j.rootLogger=debug,A1,file

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} [%p][%c] - %m%n

哦哦。validationQuery : "select 1" , // Oracle的话需要改一下这个代码是什么意思

oracle不支持select 1, 需要改成 select 1 from dual

validationQuery 这个配置,可以删掉, 换成 maxWait : 5000

 fields : {
 url : "jdbc:sqlserver://localhost:1433;databaseName=nutzbook",
 username : "as",
 password : "Yuboinfo@#123abc",
 maxWait : 5000,
 maxActive : 100
 }
添加回复
请先登陆
回到顶部