camel cxf soap and karaf issue - spring

Hi I'm facing this issue -Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://camel.apache.org/schema/spring]
Offending resource: URL [bundle://2888.0:0/META-INF/spring/camel-context.xml]
while deploying bundle into karaf.
My code is like below.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<camelContext id="SOAPSERVICE" xmlns="http://camel.apache.org/schema/spring">
<routeBuilder id="soapRouter" ref="soapRoute"/>
</camelContext>
<bean class="com.example.router.SoapRouter" id="soapRoute"/>
<!-- setting up a Camel CXF web-service -->
<cxf:cxfEndpoint id="exampleServiceEndPoint"
address="http://localhost:9000/example/"
wsdlURL="http://localhost:9000/example?wsdl"
serviceClass="com.example.ExampleServiceEndpoint"/>

You have to install camel-spring feature on your container

If you have this problem with Camel > 3.8, add camel-spring-xml. Using the spring xml dsl has been split off

Related

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.

spring context error with processing xml

I have problem with processing root-context with really simple content. I just want to configure camel-client and camel proxy beans but I get:
Error occured processing XML 'Provider
com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated:
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1
counts of IllegalAnnotationExceptions Class has two properties of
the same name "outputs" this problem is related to the following
location: at public java.util.List
org.apache.camel.model.ResequenceDefinition.getOutputs() at
org.apache.camel.model.ResequenceDefinition this problem is related to
the following location: at private java.util.List
org.apache.camel.model.ResequenceDefinition.outputs at
org.apache.camel.model.ResequenceDefinition '. See Error Log for more
details
This is my root-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:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
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.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<camel:camelContext id="camel-client">
</camel:camelContext>
<!-- Camel proxy for a given service, in this case the JMS queue -->
<camel:proxy
id="serviceProxy"
camelContextId="camel-client"
serviceInterface="pl.test.Service"
serviceUrl="jms:queue:test?transferException=true"/>
<bean id="jboss" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="connectionFactory"/>
</bean>
<jee:jndi-lookup id="connectionFactory" jndi-name="QueueConnectionFactory">
</jee:jndi-lookup>
</beans>
I have camel dependancies in my pom.xml. Anyone could give me a hint where I am doing the mistake?
According to the Camel proxy documentation <camel:proxy> must be within <camel:camelContext>:
<camel:camelContext id="camel-client">
<camel:proxy
id="serviceProxy"
camelContextId="camel-client"
serviceInterface="pl.test.Service"
serviceUrl="jms:queue:test?transferException=true"/>
</camel:camelContext>

Register a OSGI service and get that OSGI service refrence using WSO2 Product

Actually i want to migrate my application from FUSE ESB to WSO2esb.
In my FUSE application, i have created a OSGI bundle for Logger and register Logger service in OSGI registry.Other OSGI bundle can get that OSGI service through reference of it.
I have created one OSGI maven Project for Logger using servicemix-camel-osgi artifactId.
I've using Apache Camel Approach so created one MainRoute xml file.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
<bean id="Logger" class="com.logging.LoggerImpl" factory-method="getInstance"></bean>
<osgi:service id="LoggerService" ref="Logger" interface="com.logging.Logger"></osgi:service>
<camelContext autoStartup="true" xmlns="http://camel.apache.org/schema/spring"/>
</beans>
In this file i've created Spring bean of LoggerImpl Class and register it as OSGI service using SpringDM.
Then i've created other Maven Project of ABC using servicemix-camel-osgi artifactId and in that project i've created one route file.
it's looks like :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd">
<import resource="classpath:spring-beans.xml" />
<osgi:reference id="util_logger" interface="com.logging.Logger" bean-name="Logger"></osgi:reference>
<camelContext trace="false" xmlns="http://camel.apache.org/schema/spring"/>
</bean>
so as shown in above file i've getting Logger service using OSGI Refrence.
Main motive for doing this is when i Register Logger OSGI service in Registry then any OSGI bundle can use that service using Reference of it rather than importing the package.
Same thing want to implement in WSO2 but can't get any solution.
If any solution or suggestion then please suggest me, so i can achieve it.
Thanks.

mvc:annotation-driven does not work in Spring

I have the <mvc:annotation-driven/> annotation which errors out. The error I get is :
The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.
When I used the beans
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
it works fine. How is that possible
My complete Spring context XML file is :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/mvc http://www.springframework.org/schema/mvc/spring-mvc-2.5.xsd">
<mvc:annotation-driven/>
</beans>
I believe that there is no mvc:annotation-driven annotation in Spring 2.5, I think it was introduced in Spring 3.0. Consider using the current version of Spring.
I could not find the actual http://www.springframework.org/schema/mvc/spring-mvc-2.5.xsd I'm not sure that it even existed.
Missign dependcy spring-webmvc, show your pom

spring social xml config

i have already read the spring social document but the part of configuration is Java based, but my project's configuration is xml based. so please tell me how config spring social in spring xml config file. thank you and sorry for my poor english
Posting your code and issues will help us to provide you the best solution. Refer to the link below may be that is what you are looking for
http://harmonicdevelopment.tumblr.com/post/13613051804/adding-spring-social-to-a-spring-mvc-and-spring
Take a look at the example xml config
https://github.com/SpringSource/spring-social-samples/tree/master/spring-social-showcase-xml/src/main/webapp/WEB-INF/spring
You have to create a social config xml file and you have to import to your root-context.xml file. Also, you may think about configure your app with spring security. It's depends of your project architecture.
Sample spring social xml config file :
<?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:social="http://www.springframework.org/schema/social"
xmlns:facebook="http://www.springframework.org/schema/social/facebook" xmlns:bean="http://java.sun.com/jsf/core"
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-3.2.xsd
http://www.springframework.org/schema/social http://www.springframework.org/schema/social/spring-social.xsd
http://www.springframework.org/schema/social/facebook http://www.springframework.org/schema/social/spring-social-facebook.xsd">
<!-- Ensures that configuration properties are read from a property file -->
<context:property-placeholder location="file:${sampleapp.appdir}/conf/appparam.txt"/>
<!--
Configures FB and Twitter support.
-->
<facebook:config app-id="${facebook.clientId}" app-secret="${facebook.clientSecret}" />
<!--
Configures the connection repository. This application uses JDBC
connection repository which saves connection details to database.
This repository uses the data source bean for obtaining database
connection.
-->
<social:jdbc-connection-repository data-source-ref="sampleappDS" connection-signup-ref="accountConnectionSignup"/>
<!--
This bean is custom account connection signup bean for your registeration logic.
-->
<bean id="accountConnectionSignup" class="com.sampleapp.social.AccountConnectionSignup"></bean>
<!--
This bean manages the connection flow between the account provider and
the example application.
-->
<bean id="connectController" class="org.springframework.social.connect.web.ConnectController" autowire="constructor">
<constructor-arg index="0" ref="connectionFactoryLocator"/>
<constructor-arg index="1" ref="connectionRepository"/>
</bean>
Sample root-context.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"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<!-- Scan for Spring beans declared via annotations. -->
<context:component-scan base-package="com.sampleapp"/>
<context:annotation-config/>
<context:property-placeholder location="file:${sampleapp.appdir}/conf/appparam.txt"/>
<cache:annotation-driven/>
<!-- Root Context: defines shared resources visible to all other web components -->
<import resource="security-config.xml"/>
<import resource="classpath*:spring/bean-context.xml"/>
<import resource="classpath*:spring/persistence-config.xml"/>
<import resource="social-config.xml"/>
<aop:aspectj-autoproxy proxy-target-class="true"/>

Resources