2

When I try run my application, i always get error: Unable to locate NamespaceHandler for namespace [http://www.springframework.org/schema/context]. I dont know whats is wrong. So this is my application-context.xml:

<?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:context="http://www.springframework.org/schema/context"
    xmlns:ws="http://jax-ws.dev.java.net/spring/core"
    xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
    xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
            http://jax-ws.dev.java.net/spring/core http://jax-ws.dev.java.net/spring/core.xsd
            http://jax-ws.dev.java.net/spring/servlet http://jax-ws.dev.java.net/spring/servlet.xsd">

    <import resource="classpath:datasource.xml" />

    <!-- Register @Autowired annotation -->
    <bean
        class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />

    <context:component-scan base-package="pl.edu.pk" />

    <wss:binding url="/StudentService.ws">
        <wss:service>
            <ws:service bean="#studentServiceEndpoint"></ws:service>
        </wss:service>
    </wss:binding>

    <bean id="studentServiceEndpoint" class="pl.edu.pk.webservices.StudentServiceEndpoint" />

</beans>

and this is my pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.madbit.hibernate</groupId>
    <artifactId>spring-hibernate4</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <spring.version>3.2.2.RELEASE</spring.version>
    </properties>
        <repositories>
            <repository>
                <id>java.net</id>
                <url>http://download.java.net/maven/2</url>
            </repository>
        </repositories>
    <dependencies>
        <!-- Spring framework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency> <!-- Used for Hibernate4 LocalSessionFactoryBean -->
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- AOP dependency -->
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2.2</version>
        </dependency>

        <!-- Persistence Management -->
        <dependency> <!-- Apache BasicDataSource -->
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
        </dependency>

        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901.jdbc4</version>
        </dependency>

        <dependency> <!-- Hibernate -->
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.3.Final</version>
        </dependency>

        <dependency>
            <groupId>org.apache.xbean</groupId>
            <artifactId>xbean-spring</artifactId>
            <version>2.8</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
        </dependency>


            <!-- Exclude some unnecessary libraries -->
            <dependency>
                <groupId>org.jvnet.jax-ws-commons.spring</groupId>
                <artifactId>jaxws-spring</artifactId>
                <version>1.8</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-core</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-context</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.sun.xml.stream.buffer</groupId>
                        <artifactId>streambuffer</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jvnet.staxex</groupId>
                        <artifactId>stax-ex</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

        </dependencies>
        <build>
            <finalName>web services</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.1</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
</project>

I cant find what is wrong ;/ It's should be library problem but where?

Mariola
  • 249
  • 7
  • 16
  • Have you considered this solution? http://stackoverflow.com/questions/2161050/spring-3-0-unable-to-locate-spring-namespacehandler-for-xml-schema-namespace?rq=1 – Mohamed Taher Alrefaie Dec 02 '13 at 17:43

1 Answers1

1

That normally because spring-context.jar is missing from your classpath. Try adding spring-context dependency to your pom.xml

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>${spring.version}</version>
</dependency>
gerrytan
  • 40,313
  • 9
  • 84
  • 99
  • How did you run the app? Have you made sure all required libraries exist on the classpath (and no conflicting version)? – gerrytan Jun 16 '13 at 03:27