jaxws:client address property not resolving placeholder - spring

Having the strangest problem right now - have a Spring XML file where the address property of the jaxws:client is using a property placeholder for the address attribute but it is refusing to resolve the address attribute.
This is the log file error:
Caused by: java.net.MalformedURLException: no protocol: ${member.service.uri}
at java.net.URL.(URL.java:567) ~[na:1.6.0_33]
at java.net.URL.(URL.java:464) ~[na:1.6.0_33]
at java.net.URL.(URL.java:413) ~[na:1.6.0_33]
at org.apache.cxf.transport.http.HTTPConduit.setupURL(HTTPConduit.java:700) ~[cxf-
bundle-2.6.0.jar:2.6.0]
at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:474) ~[cxf-
bundle-2.6.0.jar:2.6.0]
at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:46) ~[cxf-api-2.6.0.jar:2.6.0]
... 43 common frames omitted
Here is the excerpt from my Spring XML 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:http="http://cxf.apache.org/transports/http/configuration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws" \
xmlns:sec="http://cxf.apache.org/configuration/security"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
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
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://cxf.apache.org/configuration/security
http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<http:conduit name="https://.*">
<http:tlsClientParameters>
<sec:trustManagers>
<sec:keyStore type="JKS" password="${jkspass}" file="${jkslocation}" />
</sec:trustManagers>
</http:tlsClientParameters>
<http:client AutoRedirect="true" Connection="Keep-Alive" />
</http:conduit>
<!-- Member Service -->
<!--<bean id="memberServiceProxy" class="com.loyalty.tp.ets.common.member.ws.Member"
factory-bean="memberServiceProxyFactory" factory-method="create"/> -->
<jaxws:client id="memberServiceProxy"
serviceClass="com.loyalty.tp.ets.common.member.ws.Member"
address="${member.service.uri}">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
</jaxws:client>
<bean id="memberServiceProxyFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.loyalty.tp.ets.common.member.ws.Member"/>
<property name="address" value="${member.service.uri}"/>
</bean>
<!-- ETS Collector Service -->
<bean id="collectorServiceProxy" class="com.loyalty.tp.ets.collectorservice.Collector"
factory-bean="collectorServiceProxyFactory" factory-method="create"/>
<bean id="collectorServiceProxyFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.loyalty.tp.ets.collectorservice.Collector"/>
<property name="address" value="${ets.collector.service.uri}"/>
</bean>
</beans>
It resolves the ${jksLocation} and ${jkspassword} just fine. What is going on here ?

It seems to be an incompatibility between certain versions of cxf and spring try finding a couple wich work together.
I have camel-cxf:2.12.0.redhat-610379 which bring cxf 2.7.0 and spring 3.2.8.RELEASE and everything is ok

Related

Apache Camel invalid namespace handler

I have an application that has been developed (reworked) on Eclipse. It works fine in the development environment. However when it is loaded into Tomcat it fails with a namespace exception:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [camel-config.xml]
Offending resource: class path resource [spring-config.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [camel-config.xml]; nested exception is
org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.apache.camel.spring.handler.CamelNamespaceHandler] for namespace [http://camel.apache.org/schema/spring]: problem with handler class file or dependent class; nested excep
tion is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
my spring-config and camel-config are below
<?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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-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/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-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/task http://www.springframework.org/schema/task/spring-task-3.1.xsd">
<context:component-scan base-package="foo.bar.agent" />
<task:annotation-driven />
<import resource="camel-config.xml" />
</beans>
camel-config.xml
<?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: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://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">
<!-- enable Spring #Component scan -->
<context:component-scan base-package="com.altegix.agent.hl7" />
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
<property name="ignoreMissingLocation" value="true" />
<property name="locations">
<list>
<value>classpath:default.properties</value>
<value>file:/opt/altegix/agent/application.properties</value>
</list>
</property>
</bean>
<bean id="myhl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
<property name="charset" value="iso-8859-1" />
<property name="validate" value="false" />
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring"
id="resultsCamelContext">
<contextScan />
<camel:endpoint id="hl7listener"
uri="mina2:tcp://{{results.endpoint.server}}:{{results.endpoint.port}}?sync=true&codec=#myhl7codec" />
</camelContext>
<context:annotation-config />
<bean class="com.altegix.agent.hl7.HL7ListenerConfiguration" />
I don't understand why I would be getting a InvalidNamespace Exception? There is also the noClassDefFoundError which I have not seen before - maybe am I missing some classes that are in Eclipse?

show error osgix:cm-properties when run the project

I have xml configuration in my project, what means the code below? because when I run with mvn camel:run. the error show in line 21, in osgix:cm-properties, persistent-id tag. what means the code for? thanks
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configures the Camel Context -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ctx="http://www.springframework.org/schema/context"
xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:camel="http://cxf.apache.org/transports/camel"
xmlns:osgi="http://camel.apache.org/schema/osgi" xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
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/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium-1.2.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://cxf.apache.org/transports/camel http://cxf.apache.org/transports/camel.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
">
<!-- FOR READ OSGI CONFIGURATION -->
<osgix:cm-properties
id="com.prudential.integration.middleware.crm.services"
persistent-id="com.prudential.integration.middleware.crm.services" />
<ctx:property-placeholder
properties-ref="com.prudential.integration.middleware.crm.services" />
<!-- FOR READ OSGI CONFIGURATION -->
<bean id="crmProcess" class="com.prudential.integration.middleware.crm.services.process.CRMProcess">
<property name="urlNewEmail" value="${urlNewEmail}" />
<property name="reportLoc" value="${reportLoc}" />
<property name="prefixReportName" value="${prefixReportName}" />
<property name="csvDelimiter" value="${csvDelimiter}" />
<property name="crmRequestTimeOut" value="${crmRequestTimeOut}" />
<property name="crmReadTimeOut" value="${crmReadTimeOut}" />
</bean>
<cxf:rsServer id="crmEndPoint" address="/crm"
serviceClass="com.prudential.integration.middleware.crm.services.service.CRMServices" />
</beans>

Am facing the issue while running the application in 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:int="http://www.springframework.org/schema/integration"
xmlns:int-mongodb="http://www.springframework.org/schema/integration/mongodb"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/mongodb
http://www.springframework.org/schema/integration/mongodb/spring-integration-mongodb.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
<bean id="messageDestination" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="messageQueue1" />
</bean>
<!-- spring integration beans -->
<int:channel id="jmsMessages">
<int:queue capacity="1000" />
</int:channel>
<jms:inbound-channel-adapter id="jmsMsgAdapter"
connection-factory="connectionFactory" destination="messageDestination"
channel="jmsMessages">
<int:poller fixed-rate="500" />
</jms:inbound-channel-adapter>
<mongo:db-factory id="mongoDbFactory" dbname="DeviceTrack"
port="27017" host="localhost" />
<int-mongodb:outbound-channel-adapter
channel="jmsMessages" collection-name="jmsMessage" mongodb-factory="mongoDbFactory" />
</beans>
Error :
Caused by: groovy.lang.MissingMethodException: No signature of method: static ajsc.util.AjscLogMessageService.formatExceptionDetails() is applicable for argument types: (org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException) values: [org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 30 in XML document from URL [file:D:/LucyWorkspace/ExistingDeviceFlow/target/swm/package/nix/dist_files/appl/ExistingDeviceFlow/conf/YOUR_SERVICE/v1/appMessageContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 32; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'int:channel'.]
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1500)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1486)
at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.callStatic(StaticMetaClassSite.java:65)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:206)
at ajsc.util.AjscLogMessageService.logMessage(AjscLogMessageService.groovy:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
enter code here
when I used without spring integration every thing worked well. When am integrating with Spring I am not able build the xml properly. I think I have done
some xml parsing problems because of some missing xsd.
Can any one help me to resolve the issue...
no declaration can be found for element 'int:channel'
It generally means you don't have the spring-integration-core jar on your classpath; the xsd in in that jar (mapped by /META-INF/spring.schemas).

Mongo DB configuration not working when loaded

I have the following mongo db configuration for spring framework:
<?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:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<mongo:mongo host="127.0.0.1" port="27017" />
<mongo:db-factory id="mongoDbFactory" username="admin" password="abc" dbname="test123"
mongo-ref="mongo" />
<!-- <mongo:db-factory dbname="test123" /> -->
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
</bean>
However when I start up spring framework it doesn't seems like it is connecting to the test123 database. And it is connecting to the default test database. Anyone has any ideas?
Can you change the xml to following 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:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<!-- Default bean name is 'mongo' -->
<mongo:mongo host="localhost" port="27017" />
<bean id="mongoTemplate"
class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongo" />
<constructor-arg name="databaseName" value="test123" />
</bean>
<!-- To translate any MongoExceptions thrown in #Repository annotated classes -->
<context:annotation-config />
</beans>

Internationalize REST Spring-MVC application?

Actually the question asked on SO continue. According to my spring-servlet.xml configuration for internationalization, I can not change the language of request. When I send request including "?language=tr" it returns me messages from en file. Any help would be appreciated.
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- SPRING INTERNALIZATION CONFIGURATION -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en"/>
</bean>
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
p:paramName="language" />
</mvc:interceptors>
<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
</bean>
<!-- Declare a view resolver -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
</beans>
my applicationContext.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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-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/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- Activates various annotations to be detected in bean classes -->
<context:annotation-config />
<!-- spring frameworka properties dosyasını tanıtma -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/applicationContext.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
<aop:aspectj-autoproxy>
<aop:include name="myLogger"/>
</aop:aspectj-autoproxy>
<bean id="myLogger" class="sow.webservices.aop.SowLoggerAOP"/>
<bean id="personService" class="sow.webservices.services.PersonService" />
<!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
For example #Controller and #Service. Make sure to set the correct base-package-->
<context:component-scan base-package="sow.webservices" />
<!-- Configures the annotation-driven Spring MVC Controller programming model.
Note that, with Spring 3.0, this tag works in Servlet MVC only! -->
<mvc:annotation-driven />
<!-- Loads MongoDB configuraton -->
<import resource="mongo-config.xml"/>
</beans>
Rather make sure that you added the localeChangeInterceptor bean within the interceptors properties of your handleMapping bean as follows:
<bean id="handlerMapping"vclass="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
</bean>
Or try to register the LocaleChangeInterceptor as an mvc:interceptor:
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
p:paramName="language" />
</mvc:interceptors>
You need to add the mvc namespace schema (xmlns:mvc="http://www.springframework.org/schema/mvc") in the root declaration of the spring context file so it may look as:
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
...
</beans>

Resources