Spring and JMS Integration Configuration file error - java

I keep having this error when I'm trying to integrate Spring JMS into my current project. It's driving me up the wall and I'm not entirely sure how to fix it as I'm new to Spring.
The prefix "jms" for element "jms:listener-container" is not bound.
The code in question is this,
<jms:listener-container container-type="default" connection-factory="connectionFactory" acknowledge="auto">
<jms:listener destination="TESTQUEUE" ref="simpleMessageListener" method="onMessage" />
</jms:listener-container>
I'm pretty sure it has to do with the jms: namespace but I don't know how to fix it as before my program was complaining about the p: namespace so I had to change it to property name="some value" reference="someReference"

Make sure you have the jms namespace in your context 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:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd">
<!-- <bean/> definitions here -->
</beans>
See http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/jms.html for details.

Related

Changing Camel REST HTTP Binding Configuration

I'm using Camel REST with Camel servlet handling the REST transport and want to change the way headers from the exchange are processed in HTTP requests and responses. I'm using Spring XML to configure my application. Here's the relevant configuration I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<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:camel="http://camel.apache.org/schema/spring"
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://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<!-- Custom Camel Configuration //////////////////////////////////////////////////////////////////////////////// -->
<bean id="myHttpBinding" class="com.example.MyHttpBinding"/>
<bean id="servlet" class="org.apache.camel.component.servlet.ServletComponent">
<property name="httpBinding" ref="myHttpBinding"/>
</bean>
<!-- Routes //////////////////////////////////////////////////////////////////////////////////////////////////// -->
<camel:camelContext id="myCamelContext">
<camel:contextScan/>
<camel:restConfiguration component="servlet" enableCORS="true" bindingMode="json" skipBindingOnErrorCode="false">
<camel:corsHeaders key="Access-Control-Allow-Methods" value="PATCH, PUT, POST, DELETE, GET, OPTIONS, HEAD"/>
<camel:corsHeaders key="Access-Control-Allow-Origin" value="*"/>
<camel:corsHeaders key="Access-Control-Allow-Headers" value="*"/>
</camel:restConfiguration>
</camel:camelContext>
</beans>
When the routes are created, I see that the endpoints are configured with MyHttpBinding set. However, incoming requests are still using ServletRestHttpBinding. This is because when Camel creates the consumer, it executes this block of code:
if (!map.containsKey("httpBinding")) {
// use the rest binding, if not using a custom http binding
HttpBinding binding = new ServletRestHttpBinding();
binding.setHeaderFilterStrategy(endpoint.getHeaderFilterStrategy());
binding.setTransferException(endpoint.isTransferException());
binding.setEagerCheckContentAvailable(endpoint.isEagerCheckContentAvailable());
endpoint.setHttpBinding(binding);
}
How can I set the HTTP binding in a way that Camel will respect it?
Because Camel ultimately looks for the httpBinding property on the endpoint to determine the binding strategy to use, the REST component has to be configured to add that property to the endpoint like so:
<?xml version="1.0" encoding="UTF-8"?>
<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:camel="http://camel.apache.org/schema/spring"
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://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<!-- Custom Camel Configuration //////////////////////////////////////////////////////////////////////////////// -->
<bean id="myHttpBinding" class="com.example.MyHttpBinding"/>
<!-- Routes //////////////////////////////////////////////////////////////////////////////////////////////////// -->
<camel:camelContext id="myCamelContext">
<camel:contextScan/>
<camel:restConfiguration component="servlet" enableCORS="true" bindingMode="json" skipBindingOnErrorCode="false">
<camel:endpointProperty key="httpBinding" value="myHttpBinding"/>
<camel:corsHeaders key="Access-Control-Allow-Methods" value="PATCH, PUT, POST, DELETE, GET, OPTIONS, HEAD"/>
<camel:corsHeaders key="Access-Control-Allow-Origin" value="*"/>
<camel:corsHeaders key="Access-Control-Allow-Headers" value="*"/>
</camel:restConfiguration>
</camel:camelContext>
</beans>
Note that I removed the custom servlet component because it wasn't necessary.

Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/integration/ip

Hi Can you please help me about it? I am using Spring 4.3.8 in Spring STS IDE. I get this exception: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/integration/ip]
Offending resource: class path resource [spring-config.xml]
Maven config:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
My Spring config is:
<?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-ip="http://www.springframework.org/schema/integration/ip"
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
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
<context:property-placeholder location="classpath:udp-server.properties" />
<bean id="udpConsumer" class="com.example.udp.UDPConsumer" />
<int:channel id="inputChannel">
<int:queue />
</int:channel>
<int-ip:udp-inbound-channel-adapter id="udpReceiver"
channel="inputChannel"
port="${udp-server.port}"
pool-size="${udp-server.threads}"
receive-buffer-size="${udp-server.buffer-size}"
multicast="false"
check-length="true"/>
<int:service-activator input-channel="inputChannel"
ref="udpConsumer" />
<int:poller default="true" fixed-rate="500" />
The integration starter only brings in the spring-integration-core jar, to avoid classpath bloat for jars you don't need; you need to add
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-ip</artifactId>
</dependency>
Boot/Maven will bring in the right version to match the core.

Importing Spring bean definition file using relative path

I am writing spring configurations for my project in JAVA. I am new to spring and not to able to figure out the errors related to spring.
I have the following file structure:
ProjectName
--> src
--> META-INF
--> jobs
-->edx
-->request-details.xml
-->clients.xml
-->daos.xml
-->environment.xml
--> request-details-edx-upload.xml
In META-INF/request-details-edx-upload.xml I import the following:
<import resource="jobs/environment.xml" />
<import resource="classpath:META-INF/jobs/edx/request-details.xml" />
<import resource="jobs/clients.xml" />
<import resource="jobs/daos.xml" />
But I get the following error:
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/jobs/edx/request-details.xml]
Offending resource: class path resource [META-INF/request-details-edx-upload.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionDecorator for attribute [dataSetName]
Offending resource: class path resource [META-INF/jobs/edx/request-details.xml]
request-details.xml is something like this:
<?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:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
">
<!-- RequestDetails EDX data upload dao -->
<bean id="requestDetailsDataUploadDao" class="com.amazon.edx.dao.DataUploadDaoEdxClientImpl"
context:providerName="scot"
context:subjectName="${edxRequestDetailsSubject}"
context:dataSetName="by-01-day"
context:keyName="${regionValue}"
context:edxClient-ref="edxClient"
/>
<util:list id="requestDetailsColumnMetaData" value-type="com.amazon.edx.transformer.ColumnMetaData">
<ref bean="Column"/>
<ref bean="Column1"/>
</util:list>
<bean id="Column" class="com.amazon.edx.transformer.ColumnMetaData"
context:attributeName="Id"
context:dataType="VARCHAR2"
context:columnDisplayName="IMS"
/>
<bean id="Column1" class="com.amazon.edx.transformer.ColumnMetaData"
context:attributeName="id1"
context:dataType="VARCHAR2"
context:columnDisplayName="IMS"
/>
<util:constant id="tabDelimiter"
static-field="com.amazon.edx.transformer.Delimiters.TAB_DELIMITER" />
<!-- RequestDetails data backup -->
<bean id="requestDetailsDataTransformer" class="com.amazon.edx.transformer.DataTransformerImpl"
context:dataFlattener-ref="requestDetailsDataFlattener"
context:columnMetadata-ref="requestDetailsColumnMetaData"
context:delimiter="{tabDelimiter}"
/>
</beans>
Is there anything obvious I'm doing wrong with my import of the relative path?
Thanks.
Seems it is wrong schema definition. Try to remove namspace xmlns:context="http://www.springframework.org/schema/context" from <beans> tag. Instead add xmlns:p="http://www.springframework.org/schema/p" namespace. Also you should replace all context: suffix with p: suffix. Proper xml using shortcut with the p-namespace should looks like following:
<?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:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<!-- RequestDetails EDX data upload dao -->
<bean id="requestDetailsDataUploadDao" class="com.amazon.edx.dao.DataUploadDaoEdxClientImpl"
p:providerName="scot"
p:subjectName="${edxRequestDetailsSubject}"
p:dataSetName="by-01-day"
p:keyName="${regionValue}"
p:edxClient-ref="edxClient"
/>
....
</beans>

how to configure properties for mvc spring bean controller?

Is there a special way for doing this?
What i got is:
config.properties with param.key=value
web.xml with ContextLoaderListener that reads the configuration
pages-servlet.xml that defines servlet beans.
What I want is to configure one of the beans in pages-servlet.xml with param.key.
I'm using <property name="myField" value="${param.key}"/> in the xml but I see that the field is configured with ${param.key} instead of 'value'.
What is the right way to configure the bean?
Ok, I solved it by importing application context file that defines configuration bean into pages-servlet.xml.
It works, but seems very wrong.
Property placeholder is what you want.
<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-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:property-placeholder location="classpath:/config.properties" />
<bean id="mybean" class="...">
<property name="xxx" value="${prop.value}" />
</bean>
</beans>

Unable to locate Spring Namespace for JAX-WS

I want to integrate JAX-WS to my Spring project. Found this link:
http://jax-ws-commons.java.net/spring/
I adopted it and integrated it to 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:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
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-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/task
http://www.springframework.org/schema/task/spring-task-3.0.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">
<context:annotation-config />
<context:component-scan base-package="cloud" />
<task:annotation-driven/>
<wss:binding url="/notification" service="#notificationService"></wss:binding>
<ws:service id="notificationService" bean="#notificationImpl"></ws:service>
<bean id="notificationImpl" class="cloud.balancer.Notification" />
</beans>
But every time I start Tomcat, I get this exception:
SEVERE: 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://jax-ws.dev.java.net/spring/servlet]
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]
Eclipse does not report any errors about the namespace. I found a few similar problems with google, but none fixed my error.
Thanks for your help!
Same problem in this : link , you need jaxws-spring.jar from - http://download.java.net/maven/2/org/jvnet/jax-ws-commons/spring/jaxws-spring/

Categories

Resources