开发者

Unable to locate Spring NamespaceHandler for XML schema namespace

I am running some servlet code in tomcat in eclipse. It's been working fine but today I get the error Unable to locate Spring NamespaceHandler for XML schema namespace. The full error looks like this:

SEVERE: Allocate exception for servlet RunServlet
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration     problem: Unable to locate Spring NamespaceHandler for XML schema namespace     [http://www.springframework.org/schema/tx]
Offending resource: class path resource [spring/dao.xml]

I've had a look at other questions regarding this error, but I don't really understand the answers.

When I look at the target libs, I can see that spring-tx-3.0.5.RELEASE.jar is in WEB-INF/lib.

Can anyone help me out?

Thanks so much!

EDIT: dao.xml starts:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

EDIT: Not sure if this is relevant, but I'm working on a mac book pro, and the latest mac update updated to Java 1.6, and I just switched over my Java preferences to 1.6.

EDIT: I'm also getting the following message in the Tomcat log, but I think I was getting it before and I don't think it's related, but just in case:

INFO: Starting Servlet Engine: Apache Tomcat/7.0.14
Jul 6, 2011 11:59:55 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/Users/bw/Documents/workspace2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/core/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

EDIT: Sorry - didn't see your comments. Here's a listing of th开发者_StackOverflow中文版e WEB-INF.

b-ws-macbook-pro:lib bw$ ls -ltr
total 13456
-rw-r--r--  1 bw  staff   62983 May 14 09:26 activation-1.1.jar
-rw-r--r--  1 bw  staff   53082 May 14 09:26 spring-asm-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff   60686 May 14 09:26 commons-logging-1.1.1.jar
-rw-r--r--  1 bw  staff   61379 May 14 09:26 spring-oxm-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff    4467 May 14 09:26 aopalliance-1.0.jar
-rw-r--r--  1 bw  staff  100870 May 14 09:26 spring-context-support-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff   62086 May 14 09:26 commons-pool-1.3.jar
-rw-r--r--  1 bw  staff  169752 May 14 09:26 spring-expression-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  175412 May 14 09:27 spring-webmvc-portlet-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  121757 May 14 09:27 commons-dbcp-1.2.2.jar
-rw-r--r--  1 bw  staff  321190 May 14 09:27 spring-aop-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  231922 May 14 09:27 spring-tx-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  334327 May 14 09:27 spring-orm-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  371792 May 14 09:27 mybatis-2.3.5.jar
-rw-r--r--  1 bw  staff  382442 May 14 09:27 spring-core-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  418977 May 14 09:27 spring-webmvc-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  388864 May 14 09:27 mail-1.4.jar
-rw-r--r--  1 bw  staff  395587 May 14 09:27 spring-web-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  668861 May 14 09:27 spring-context-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  555410 May 14 09:27 spring-beans-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  385712 May 14 09:27 spring-jdbc-3.0.5.RELEASE.jar
-rw-r--r--  1 bw  staff  512707 May 14 09:27 mysql-connector-java-5.0.5.jar
-rw-r--r--  1 bw  staff  610790 May 14 09:27 c3p0-0.9.1.2.jar
-rw-r--r--  1 bw  staff  391834 May 14 09:27 log4j-1.2.15.jar

EDIT: Thanks, Christian. It's weird, though, because I DON'T have that file in my jars anyway, and I do list it as provided:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>

I'm sure I'm missing something here..

EDIT: Hmm.. now Tomcat can't even find applicationContext. Something weird going on with my setup, I think.


For future references:

Maybe you forgot some spring-XXX dependency.

Por example, in maven check if you have the related dependency:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-XXX</artifactId>
    <version>${org.springframework.version}</version>
</dependency>

Regards


Gah. I fixed it, but I really don't know how. I read this post ClassNotFoundException DispatcherServlet when launching Tomcat (Maven dependencies not copied to wtpwebapps) and saw that I had the same thing - a problem listed with the build in the 'markers' pane. I ran the quick fix it suggested and now everything is working again. Like I said, I hadn't touched it since a couple of days ago. Apparently it just gets confused sometimes. 6 hours later.. Thanks for your suggestions, guys.


Change the namespace in dao.xml from

http://www.springframework.org/schema/tx/spring-tx-2.0.xsd

to

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

(and probably spring-beans too)


I had this same problem from Eclipse Indigo on Kubuntu. I removed m2e and reinstalled a different version of the connector, http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/, and everything runs fine now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜