运行springmvc那个例子的时候报的错

12-02-01 mistbow
下面这个错误需要怎么修改呢?我已经在tomcat配置过jndi了。

这个错误是在启动tomcat的时候报出的。

程序的还是可以运行的。

java.io.IOException: Unable to scan directory of protocol: jndi

at com.jdon.util.scanAnnotation.IteratorFactory.create(IteratorFactory.java:52)

at com.jdon.util.scanAnnotation.ScanAnnotationDB.scanArchives(ScanAnnotationDB.java:49)

at com.jdon.container.annotation.type.AnnotationScaner$1.call(AnnotationScaner.java:56)

at com.jdon.container.annotation.type.AnnotationScaner$1.call(AnnotationScaner.java:51)

at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

at java.util.concurrent.FutureTask.run(FutureTask.java:138)

at com.jdon.container.annotation.type.AnnotationScaner.startScan(AnnotationScaner.java:63)

at com.jdon.container.annotation.ContainerLoaderAnnotation.startScan(ContainerLoaderAnnotation.java:37)

at com.jdon.container.factory.ContainerBuilderFactory.createContainerBuilder(ContainerBuilderFactory.java:54)

at com.jdon.container.startup.ContainerSetupScript.initialized(ContainerSetupScript.java:51)

at com.jdon.container.startup.ContainerSetupScript.prepare(ContainerSetupScript.java:73)

at com.jdon.container.finder.ContainerFinderImp.findContainer(ContainerFinderImp.java:46)

at com.jdon.spring.AppContextJdon.setApplicationContext(AppContextJdon.java:83)

at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:116)

at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398)

at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:599)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:437)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)

at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)

at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)

at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)

at javax.servlet.GenericServlet.init(GenericServlet.java:212)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206)

at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)

at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)

at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)

at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)

at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)

at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)

at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)

at org.apache.catalina.core.StandardService.start(StandardService.java:525)

at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)

at org.apache.catalina.startup.Catalina.start(Catalina.java:595)

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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

[该贴被mistbow于2012-02-01 10:11修改过]

[该贴被mistbow于2012-02-01 10:15修改过]

[该贴被mistbow于2012-02-01 10:18修改过]

banq
2012-02-01 10:20

use test;
create table testuser (
       userId           char(20) not null,
       name             varchar(20) null,
       PRIMARY KEY  (userId)
);
INSERT INTO testuser VALUES ('1', 'tony');
INSERT INTO testuser VALUES ('2', 'sunny');
INSERT INTO testuser VALUES ('3', 'kevin');

<p>

Tomcat的JDNI配置:

<Context path="" debug="5" reloadable="true" crossContext="true">
  <Resource name="jdbc/TestDS" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="root" password="" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true"/>

</Context>
<p>

mistbow
2012-02-01 10:48
jndi这个我已经配置了 但是还是有那个错误 我的配置如下:

server.xml:

<Resource name="jdbc/DataSource" auth="Container"

type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/test"

username="root" password="root" maxActive="20" maxIdle="10"

maxWait="-1"/>

context.xml:

<ResourceLink name="jdbc/simplejdbc" global="jdbc/DataSource" type="javax.sql.DataSource"/>

然后您的web.xml是这样子的:

<resource-ref>

<res-ref-name>jdbc/simplejdbc</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>

这几个地方配置的应该没问题吧?

banq
2012-02-01 11:53
2012年02月01日 10:48 "@mistbow"的内容
jdbc/DataSource ...

和web.xml无关,server.xml和context.xml中只要配置一项即可,无需两个都配。

程序中使用的JNDI名称是: java:comp/env/jdbc/TestDS

java:comp/env是JavaEE规定前缀,去除这个前缀,就是jdbc/TestDS,这是Resource名称,在Server.xml或context.xml中的Resource名称name值也要是jdbc/TestDS。

注意两个resource中的name值要一样,这称为映射mapping,是你的应用程序和tomcat之间接口名称映射,需要一样。

而你是jdbc/DataSource,改为jdbc/TestDS即可。

猜你喜欢