NutzCN Logo
问答 nutz能够连接上数据库,但是运行时出现异常
发布于 2928天前 作者 qq_f5519c6b 2105 次浏览 复制 上一个帖子 下一个帖子
标签:

var ioc = {
dateSource:{
type: "com.alibaba.druid.pool.DruidDataSource",
events:{
create : "init",
depose : 'close'
},
fields : {
driverName : "oracle.jdbc.driver.OracleDriver",
url : "jdbc:oracle:thin:@localhost:1521:TING",
username : "scott",
password : "ting",
testWhileIdle : true,
maxActive : 100
}
},
dao :{
type:"org.nutz.dao.impl.NutDao",
args :
[{refer : "dateSource"}]
}
};

这是我的JS

13 回复

java.lang.RuntimeException: Fail to eval Injector for field: 'driverName'
at org.nutz.lang.Lang.wrapThrow(Lang.java:117)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:88)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:66)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:95)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:70)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:36)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:66)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:30)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.RuntimeException: java.lang.NoSuchFieldException: Can NOT find field [driverName] in class [com.alibaba.druid.pool.DruidDataSource] and it's parents classes
at org.nutz.lang.Lang.wrapThrow(Lang.java:134)
at org.nutz.lang.Mirror.getInjecting(Mirror.java:953)
at org.nutz.ioc.weaver.FieldInjector.create(FieldInjector.java:13)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:85)
... 30 more
Caused by: java.lang.NoSuchFieldException: Can NOT find field [driverName] in class [com.alibaba.druid.pool.DruidDataSource] and it's parents classes
at org.nutz.lang.Mirror.getField(Mirror.java:434)
at org.nutz.lang.Mirror.getInjecting(Mirror.java:944)
... 32 more

是不是跟我导的包有关系?

ojdbc14.jar
druid-0.2.2.jar
nutz-1.b.43-jdk6.jar
这是我导的包

driverName 改成 driverClass , 或者干脆去掉这一行, druid能自动识别驱动的.

@wendal java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.nutz.lang.Lang.wrapThrow(Lang.java:134)
at org.nutz.lang.Lang.wrapThrow(Lang.java:133)
at org.nutz.ioc.trigger.MethodEventTrigger.trigger(MethodEventTrigger.java:21)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:74)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:98)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:66)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:95)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:182)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:70)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:36)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:66)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:30)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.alibaba.druid.stat.DruidDataSourceStatManager.(DruidDataSourceStatManager.java:44)
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:377)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.nutz.ioc.trigger.MethodEventTrigger.trigger(MethodEventTrigger.java:18)
... 32 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
... 39 more

我去掉那一行之后就出现空指针了

你这是刚开始用的吗? 如果是的话, 请更新最新的jar

druid 1.0.25.jar
nutz 1.r.59.jar
ojdbc6.jar

@wendal 好的 谢谢您,我一下看能成功吗。

@wendal 您能给这些包的下载地址给我吗。

@wendal 谢谢您 已经解决了

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