How to fix "Configuration Problem: Unable to locate Spring NamespaceHandler for XML schema namespace context"? - spring

I was trying to run application in eclipse, it was running fine. I created jar using Maven install, and while running the jar I am getting the error "Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [appContext.xml]"
<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"
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">
<context:component-scan base-package="package"></context:component-scan>
...
Snap of project structure

Related

deploying rest api war and starting with App Manager produces error FAIL - Application at context path

First time working with web apps and created a simple springboot rest api and it worked fine locally. Deployed the war to a tomcat server by copying the war file into the /webapps/ directory and restarted tomcat.
I checked if this was successful by opening the tomcat web application manager page and can see the app listed:
http://1xx.xxx.xxx.xxx:8080/manager/
When I click start to get it running the following error appears:
FAIL - Application at context path [/first_restapi] could not be started
I searched around and most answers suggest ensuring all pom file dependencies are included and to check the logs. I checked the logs on the tomcat server and the following error stuck out:
Exception sending context initialized event to listener instance of class
[org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem:
Unable to locate Spring NamespaceHandler for XML schema namespace
[http://www.springframework.org/schema/security]
Offending resource: ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]
I did not include a servlet-context.xml file as the tutorial did not show that. But I added it anyway and still got the same error. Can anyone help with this issue?
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
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://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<security:http auto-config="true" create-session="stateless">
<security:intercept-url pattern="/**" access="ROLE_USER"
requires-channel="http"/>
<security:http-basic />
</security:http>
</beans:beans>
You have a dependency problem. For each XML namespace that you (effectively) use in your configuration file, you need the appropriate NamespaceHandler. So in your case, to use the:
beans or util namespace you need spring-beans.jar,
context or task namespace you need spring-context.jar,
mvc namespace you need spring-webmvc.jar,
security namespace you need spring-security-config.jar.
You certainly don't have the last one dependency.

Unable to locate Spring NamespaceHandler for XML schema namespace http://www.springframework.org/schema/data/solr

I am trying to integrate spring and Apache solr. For that i am trying NamespaceHandler http://www.springframework.org/schema/data/solr. But this giving me the following error.
Can any please help me.
<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:oxm="http://www.springframework.org/schema/oxm" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task"
xmlns:solr="http://www.springframework.org/schema/data/solr"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/data/solr
http://www.springframework.org/schema/data/solr/spring-solr.xsd
">
This is leading to an error
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/data/solr]Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]
Thanx in advance for any help..
If this is a new project, you should start from Spring Boot and add Spring Data Solr into it. There are sample projects of how to do it. You can also check a real project using Spring Boot, and Spring Data Solr for auto-complete.

Unable to locate Spring NamespaceHandler for XML schema namespace [http://cxf.apache.org/jaxws]

I need to integrate Spring with CXF version 3.0. CXF libraries are in the classpath. I am getting the error "Unable to locate Spring NamespaceHandler for XML schema namespace [http://cxf.apache.org/jaxws]" when trying to access the web service. What could be the wrong here ? By any chance Schema url got changed?
<?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:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
Did you put the cxf-rt-frontend-jaxws.jar into the class path?
The offline xml schema can be found there.

getting error Invalid NamespaceHandler class org.springframework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler

While running spring i am getting error that
Unexpected exception parsing XML document from class path resource
[spring/tx-annotation-app-context.xml]; nested exception
is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class
[org.springframework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler]
for namespace [http://www.springframework.org/schema/data/jpa]: problem with
handler class file or dependent class; nested exception is
java.lang.NoClassDefFoundError:
org/springframework/data/repository/config/RepositoryConfigurationExtension
Here is my file
<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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<description>Example configuration to get you started.</description>
....
</beans>
Here is the screen shot of my included jars
What i am doing wrong with the namespace ?
Thanks
I think the problem is your using spring-data-commons-core version 1.1 and spring-data-jpa version 1.2. Align the versions of these libraries.
Looking at a pom.xml file from one of my projects I see.
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
and it uses spring-data-commons-core-1.4.0.RELEASE.jar
If you switch the packaging of spring-data-jpa to pom, it should download the necessary dependencies, then switch it back to jar.

Drools integrated with spring faced with a xsd not found warning

I'm using Spring+Drools in my Web Application.The following is the drools modules configuration
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://drools.org/schema/drools-spring
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd"
default-autowire="byName">
<drools:kbase id="kbase1">
<drools:resources>
<drools:resource type="DRL" source="classpath:uniteStickyRules.drl"/>
</drools:resources>
</drools:kbase>
<drools:ksession id="ksession1" type="stateful" kbase="kbase1"/>
When I ran my application using this configuration in my junit project it worked, yet it came with the following problem when I startup my Web application. As a result, I couldnot find my kbase bean.
2012-03-29 12:55:48,402 WARN resolver.SpringPluggableSchemas - Could not find schema classpath:org/drools/container/spring/drools-service-spring.xsd for URI: http://drools.org/schema/drools-service-spring.xsd,
class path resource [org/drools/container/spring/drools-service-spring.xsd] cannot be resolved to URL because it does not exist
2012-03-29 12:55:48,413 WARN resolver.SpringPluggableSchemas - Could not find schema classpath:file:/C:/Users/Dan%20Diephouse/workspace/xfire/target/checkout/xfire-spring/target/test-generated/services.xsd for URI: http://xfire.codehaus.org/config/1.0,
class path resource [file:/C:/Users/Dan%20Diephouse/workspace/xfire/target/checkout/xfire-spring/target/test-generated/services.xsd] cannot be resolved to URL because it does not exist
You see, I didn't put the drools-service-spring.xsd in my .xml file. So I'm quite stuck with it. Any suggestions?

Resources