WebSphere Spring Apache CXF SOAP WebService Client timeout not working - spring

I need to configure a SOAP WebService client with certain timeout values for connection attempts and service invocations.
The WS client is a jar dependency generated using the WSDL with Maven cxf-codegen-plugin. I use this client jar in my web app as a maven dependency and invoke the service operations.
So my webapp pom contains:
<dependency>
<groupId>my.web.service</groupId>
<artifactId>web-service-client-jar</artifactId>
<version>x.x.x</version>
</dependency>
along with the Apache CXF dependencies:
<!-- CXF dependencies -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
And I have defined below spring configuration to setup timeouts which does not work..
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<http-conf:conduit name="*.http-conduit">
<http-conf:client ConnectionTimeout="20000" ReceiveTimeout="10000" />
</http-conf:conduit>
<cxf:bus>
<cxf:outInterceptors>
<ref bean="fileuploadlogOutbound" />
</cxf:outInterceptors>
</cxf:bus>
<!-- Outbound Message Logging -->
<bean id="fileuploadlogOutbound" class="test.logging.MyLoggingOutInterceptor">
<property name="prettyLogging" value="true" />
</bean>
But to my confusion, the outInterceptors defined for pretty logging works fine. Hence, I doubt if my configuration has any errors or not. FYI I'm trying to get this working in WebSphere 8.5 environment.
This is how I instantiate the WS Client in spring:
<jaxws:client id="documentUploadServiceJaxwsClient"
serviceClass="org.tempuri.IDocumentUploadService" address="#serviceEndpointString" >
<jaxws:binding>
<soap:soapBinding version="1.2" mtomEnabled="true" />
</jaxws:binding>
</jaxws:client>
Is there any steps missing in Spring config or do I need to look into WebSphere 8.5 specific configuration which will enforce HTTP/SOAP connection & response timeouts?

I figured out that my CXF configuration mentioned above works fine but the WAS environment where the application deployed is actually overriding any config you define at the application level. Hence, I followed this link to copy and define custom HTTP Transport policy where you can set values for below timeouts.
Read timeout
Write timeout
Connection timeout

Related

Publishing and Accessing OSGI Service with JBoss Fuse Fabric

I have an OSGi service that I exposed and deployed on jboss fuse fabric.
now I need to access this service from another bundle deployed on another container in jboss fuse fabric. but the service is not accessible in client container.
jboss fuse V6.3
when I deploy OSGi-service bundle and client bundle in the same container in fuse fabric, it works, but when I deploy the in different containers in does not work and show an error:
Unable to start blueprint container for bundle com.osgi.app.bean-camel-client10/1.0.0 due to unresolved dependencies [(objectClass=org.fusesource.example.service.HelloWorldSvc)]
In client:
POM.xml :
<dependency>
<groupId>com.osgi.app</groupId>
<artifactId>bean-app-service1</artifactId>
<version>1.0</version>
</dependency>
config.xml:
<reference id="helloWorld"
interface="org.fusesource.example.service.HelloWorldSvc"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint" >
<route>
<from uri="timer:foo?period=5000"/>
<to uri="bean:org.fusesource.example.service.HelloWorldSvc?method=sayHello"/>
<log message="The message contains: ${body}"/>
</route>
in service-provider:
pom.xml:
<groupId>com.osgi.app</groupId>
<artifactId>bean-app-service2</artifactId>
<version>1.0</version>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${version.maven-bundle-plugin}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
<Export-Package>org.fusesource.example.service</Export-Package>
</instructions>
</configuration>
</plugin>
config.xml:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="hello" class="org.fusesource.example.service.impl.HelloWorldSvcImpl"/>
<service ref="hello" interface="org.fusesource.example.service.HelloWorldSvc"/>
</blueprint>
How can I access the service which is deployed in another container in fuse fabric, through a camel context?
<service ref="hello" interface="org.fusesource.example.service.HelloWorldSvc"/>
means exactly this: call BundleContext.registerService("org.fusesource.example.service.HelloWorldSvc", object, properties).
After registration you have a service registered in local OSGi registry which is scoped by single instance of JVM - that never meant exposing the service to be accessible in different JVM.
If you want a service to be available in different JVM (== in different OSGi registry), you need some kind of remoting - try using CXF endpoint or one of remoting camel components (camel-cxf, camel-rest, ...).

How to config logging in Apache Ignite, sfl4j or log4j

I created spring-boot app with Apache Ignite and want to config logging on server and client side. I followed instructions https://apacheignite.readme.io/docs/logging but i got some issues with logging.
For Slf4j
<property name="gridLogger">
<bean class="org.apache.ignite.logger.slf4j.Slf4jLogger"/>
</property>
on server side if I set GNITE_QUIET=false i get
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
Ok, I added libs in $IGNITE_HOME/libs/ignite-slf4j/ slf4j-log4j12 and log4j
log4j:WARN No appenders could be found for logger (org.apache.ignite.internal.util.typedef.G).
log4j:WARN Please initialize the log4j system properly.
I tried to set -Dlog4j.configurationFile=config/log4j.xml, but it doesn't help.
On server side I managed to set up logging with
<property name="gridLogger">
<bean class="org.apache.ignite.logger.log4j.Log4JLogger">
<constructor-arg type="java.lang.String" value="log4j.xml"/>
</bean>
</property>
but in spring-boot ms I got
Caused by: class org.apache.ignite.IgniteCheckedException: Log4j configuration path was not found: config/log4j.xml
It works if I set absolute path
<constructor-arg type="java.lang.String" value="/home/username/work/ignite/config/log4j.xml"/>
but that's not what I need. How do I need to config logs in server/client side correctly?
According your first error, do you use maven? If yes, did you try to include following dependencies to your POM-file?
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
"Log4j configuration path was not found" is probably thrown because you placed your config to the folder which is not part of your project. If you don't want to use full path just move it to "resources" folder of the project.

How to set primary rabbit template and rabbit connection factory

I am facing some errors in a spring boot project where I am using spring integration to connect to RabbitMQ. I am doing the configuration for RabbitMQ in XML files like this:
<!-- RabbitMQ configuration -->
<rabbit:connection-factory
id="rabbitConnectionFactory_2"
host="${queuing.events.host}"
port="${queuing.events.port}"
username="${queuing.events.username}"
password="${queuing.events.password}"
virtual-host="${queuing.events.virtual-host}"
publisher-returns="true"/>
<rabbit:template id="amqpTemplate_2" connection-factory="rabbitConnectionFactory_2" />
<rabbit:admin id="rabbitAdmin_2" connection-factory="rabbitConnectionFactory_2"/>
<rabbit:listener-container connection-factory="rabbitConnectionFactory_2" auto-startup="true" requeue-rejected="false" />
<bean id="rabbitListenerContainerFactory_2" class="org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory">
<property name="connectionFactory" ref="rabbitConnectionFactory_2"/>
</bean>
<!-- -->
But I am creating two of each component. How to set the primaries ones?
Now the problem comes here, I was using this version for spring cloud:
<spring-cloud.version>Dalston.SR2</spring-cloud.version>
And everything was working fine, but if I update the version to:
<spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
This error is coming:
Description:
Parameter 0 of method rabbitSender in org.springframework.cloud.sleuth.zipkin2.sender.ZipkinRabbitSenderConfiguration required a single bean, but 2 were found:
- rabbitConnectionFactory: defined in null
- rabbitConnectionFactory_2: defined in null
Action:
Consider marking one of the beans as #Primary, updating the consumer to accept multiple beans, or using #Qualifier to identify the bean that should be consumed
And the error comes because of this dependency:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
If I remove this dependency the error is not coming.
You can find an example project to reproduce this scenario. In the pom file you'll see this:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Dalston.SR2</spring-cloud.version> <!-- it works with this version-->
<!-- <spring-cloud.version>Edgware.RELEASE</spring-cloud.version> --> <!-- doesn't work with this version-->
</properties>
<dependencies>
<!-- SPRING BOOT -->
<!-- it fails because of this dependency in that we are using Edgware.RELEASE version -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
...
https://github.com/fjmpaez911/spring-integration-zipkin-cloud
So I need to know how to set a primary configuration for RabbitMQ and in addition I think that could be an issue because this error only comes if I use this version Edgware.RELEASE
Am I missing something?
fran, in Edgware.RELEASE the <artifactId>spring-cloud-sleuth-zipkin</artifactId> will resolve Zipkin 2 dependencies try using <artifactId> spring-cloud-starter-zipkin-legacy</artifactId> instead
To define the primary connection factory for RabbitMQ in XML files, you can do something like this:
<!-- Here the primary connection -->
<bean id="rabbitConnectionFactory" primary="true" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<constructor-arg value="${spring.rabbitmq.host}"/>
<property name="username" value="${spring.rabbitmq.username}"/>
<property name="password" value="${spring.rabbitmq.password}"/>
<property name="virtualHost" value="${spring.rabbitmq.virtual-host}"/>
</bean>
<!-- RabbitMQ configuration -->
<rabbit:connection-factory
id="rabbitConnectionFactory_2"
host="${queuing.events.host}"
port="${queuing.events.port}"
username="${queuing.events.username}"
password="${queuing.events.password}"
virtual-host="${queuing.events.virtual-host}"
publisher-returns="true"/>
<rabbit:template id="amqpTemplate_2" connection-factory="rabbitConnectionFactory_2" />
<rabbit:admin id="rabbitAdmin_2" connection-factory="rabbitConnectionFactory_2"/>
<rabbit:listener-container connection-factory="rabbitConnectionFactory_2" auto-startup="true" requeue-rejected="false" />
<bean id="rabbitListenerContainerFactory_2" class="org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory">
<property name="connectionFactory" ref="rabbitConnectionFactory_2"/>
</bean>

Spring 3.x JSON status 406 "characteristics not acceptable according to the request "accept" headers ()"

Upon trying to get my response in JSON using Spring 3.x, I get the 406 error "The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ()."
Here is my environment
* Spring 3.2.0.RELEASE
* included jackson-mapper-asl-1.7.9.jar, jackson-core-asl-1.7.9.jar
* Tomcat 6.x
* mvc:annotation-driven in Spring configuration XML file
My Controller:
#RequestMapping("/contest")
public class ContestController {
#RequestMapping(value="{name}", headers="Accept=*/*", method = RequestMethod.GET)
public #ResponseBody Contest getContestInJSON(#PathVariable String name) {
Contest contest = new Contest();
contest.setName(name);
contest.setStaffName(new String("contestitem1"));
return contest;
}
}
My Spring Configuration file
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
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-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">
<context:component-scan base-package="com.contestframework.controllers" />
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="atom" value="application/atom+xml"/>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
</list>
</property>
</bean>
<mvc:annotation-driven />
</beans>
After this I just access the Controller using below:
http://domain/SpringWebProject/json/contest/abcd
and the response I get is Status 406: "The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ()."
I also tried an alternate mechanism by access this using Javascript AJAX to make sure my request header has application/JSON but this led to the same Status 406 result
$.getJSON('contest/abcd', function(data) {
console.log(data) }
Here is my REQUEST HEADER captured from browser:
Request URL:http://localhost:8080/SpringWebProject/json/contest/abcd
Request Method:GET
Status Code:406 Not Acceptable
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:JSESSIONID=59689C95B0B9C21494EB0AB9D9F7BCCD
Host:localhost:8080
Referer:http://localhost:8080/SpringWebProject/json/welcome
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
X-Requested-With:XMLHttpRequest
Response Headersview source
Content-Length:1070
Content-Type:text/html;charset=utf-8
Date:Fri, 12 Oct 2012 18:23:40 GMT
Server:Apache-Coyote/1.1
Appreciate any help in this regard.
I have also just experienced this same issue. It would appear it is an issue with the latest 3.2.0.RELEASE, as I previously had 3.1.2.RELEASE and it all worked. After changing to 3.2.0.RELEASE it breaks. Have tested with 3.1.3.RELEASE and that works fine. So for now I would suggest rolling back to 3.1.3.RELEASE
EDIT: Thanks to another post on this site that linked to the following location: http://static.springsource.org/spring-framework/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-config-content-negotiation
I've now got it working by disabling the getting of media type based on the extension of the requested path. This can be done by the following:
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/>
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<!-- Turn off working out content type based on URL file extension, should fall back to looking at the Accept headers -->
<property name="favorPathExtension" value="false" />
</bean>
And specify version 3.2 for all the xsd schema locations.
And this is using the following jackson jars:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.1.2</version>
</dependency>
There is nothing wrong in your configuration, let me suggest a few small changes though:
a) Your namespaces appear wrong - they are referring to the 3.0 schemas, just change them to either 3.1 one's or don't refer to the version explicitly, this way for eg.
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
OR
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
b) You don't require the ContentNegotiatingViewResolver, you can remove everything but the component-scan and <mvc:annotation-driven/> from your configuration
c) The request will not directly work from the browser as it explicitly requires an Accept header of "application/json" - $.getJson call should work though as it sends the correct headers
d) Remove the headers=Acc.. from the #RequestMapping, and produces also, both are filtering criteria to match up the correct mapped method call.
With these, there is no reason why the json should not get served out, can you please try with these and see how it goes.
I had the same problem and I solved it by adding following dependency
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jackson.version}</version>
</dependency>
Previously I'm doing it with following dependency
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${com.jackson.core-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${com.jackson.core-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${com.jackson.core-version}</version>
</dependency>
In short I have replace com.fasterxml.jackson.core by org.codehaus.jackson
I had this problem in Spring MVC 4. Adding jackson-annotations, jackson-core and jackson-databind didn't solve the problem. Try this libs:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
I think you need to add a produces="application/json" to your #RequestMapping (haven't looked at spring mvc in a while so i'm not 100% positive) ...
http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html
16.3.2.6 Producible Media Types
You can narrow the primary mapping by specifying a list of producible media types. The request will be matched only if the Accept request header matches one of these values. Furthermore, use of the produces condition ensures the actual content type used to generate the response respects the media types specified in the produces condition. For example:
#Controller
#RequestMapping(value = "/pets/{petId}", method = RequestMethod.GET, produces="application/json")
#ResponseBody
public Pet getPet(#PathVariable String petId, Model model) {
// implementation omitted
}
I had the same problem and the comment added by Biju Kunjummen in this answer worked for me perfectly
https://stackoverflow.com/a/12873170/20654
That is have public getters in my Java class
I had a similar problem, it got resolved when I added jackson-databind library.
These are my dependencies:
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.12</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.3</version>
</dependency>
Thank you for sharing you experience.I experienced the same problem and it works for me using configuration as show below:
Spring MVC Version : 3.2.5.RELEASE
Apache-tomcat-6.0.24
JDK1.6
jackson-core-asl-1.9.10.jar
jackson-mapper-asl-1.9.10.jar
Spring MVC Config File:
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/>
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<!-- Turn off working out content type based on URL file extension, should fall back to looking at the Accept headers -->
<property name="favorPathExtension" value="false" />
</bean>
Model class : Country.java
private Integer countryId;
private String name;
//public setters and getters
Controller Method:
#RequestMapping(value = "/get_country_json",method = RequestMethod.GET)
#ResponseBody
public Country getCountry()
Deployment Descriptor(web.xml)
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
URL Requested to call controller method: /SpringCURDApp/get_country_json.htm
I hope this can help someone.
Don't make the same mistake I did, spend all day playing around with Spring configuration, when actually your object returned in a web service is not marshaling to XML correctly. It seems Spring catches a JAXB marshaling error and doesn't report it. Use this sandbox code to validate JAXB marshaling:
MyClass myclass = new MyClass();
//populate myclass here
JAXBContext context = JAXBContext.newInstance(MyClass.class);
Marshaller m = context.createMarshaller();
StringWriter w = new StringWriter();
m.marshal(myclass, w);
System.out.println(w);
This produced and displayed an exception. Fixed the cause, and my web service is available in both XML and JSON.
Shortly:
For Spring MVC 4.1.6 there is enough:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.0</version>
</dependency>
jackson-databind has dependency on core and annotations artifacts.
In details:
What is HTTP 406 error?
406 Not Acceptable
The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.
It means that Server cannot generate content which MEDIA TYPE stated in Accept Header.
But how does server know which MEDIA TYPE it can generate and which not?
Spring Web has concept of HttpMessageConverter. Some of these converters are already registered in Spring and AbstractMessageConverterMethodArgumentResolver holds them in property messageConverters.
During request processing AbstractMessageConverterMethodProcessor analyzes what spring can convert and saves all supported MEDIA TYPES in producibleMediaTypes variable.
If requested MEDIA TYPE is not producible then says Error 406 == I cannot generated requested media type. Sorry.
To cut the long story short - register required converters. In your case it's jackson library which produces application/json
Please, see http://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-config-content-negotiation
As you can see
"For file extensions in the request URI, the MVC Java config and the
MVC namespace, automatically register extensions such as .json, .xml,
.rss, and .atom if the corresponding dependencies such as Jackson,
JAXB2, or Rome are present on the classpath."
You should add ".json" at the end of URI (like http://domain/SpringWebProject/json/contest/abcd.json)
It works for me.
I had similar issue but it was weird. I will explain how I resolved it.
In my web.xml my dispacher servlet was mapped to *.htm
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
and no matter what I did it always threw -
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" header
Finally I changed it to
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
and it worked. What I think is when you just specify
<mvc:annotation-driven/>
the extension takes precedence over accept header and .htm was was creating issues. And obviously I could not use xml or json since servlet itself was not mapped.
I would also like to add that produces annotation that you, spring will try to map it will accept header of the incoming request. I was making request handler method generic for json and xml. Since I am using Java 8 and Jaxb is inbuilt in Java since Java 7 no need for JAXB dependency. For json I only needed to add -
<dependency org="com.fasterxml.jackson.core" name="jackson-databind" rev="2.8.5"/>
I am using ivy for dependency management.
Maybe you should update your jackson library. I use Spring v4.3.8 and I use it as follows:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.7</version>
</dependency>
If you are using Spring 4 then you must only update your libraries:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.0</version>
</dependency>

Embedded ActiveMQ in Embedded Glassfish (using maven-embedded-glassfish-plugin)

Im trying to run a ActiveMQ glassfish embedded using the maven-embedded-glassfish-plugin.
I have separately completed below tutorials, so I know the basics.
The goal is to have a setup that builds in one click and avoids 3pp libraries in svn.
1 http://www.hascode.com/2011/09/java-ee-6-development-using-the-maven-embedded-glassfish-plugin/
2 http://javadude.wordpress.com/2011/07/21/glassfish-v3-1-running-embedded-activemq-for-jms-part-1/
Project setup for #2 is used as startpoint from now and I will try to merge the steps from #1
I've setup a glassfish-resources.xml hoping it will do the configuration tutorial 1 did from the glassfish admin-console.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<resource-adapter-config resource-adapter-name="activemq-rar-5.6.0" thread-pool-ids="thread-pool-1">
<property name="ServerUrl" value="vm://localhost:61616"></property>
<property name="BrokerXmlConfig" value="broker:(tcp://0.0.0.0:61616)"></property>
</resource-adapter-config>
<connector-resource enabled="true" jndi-name="amqres"
object-type="user" pool-name="amqpool">
</connector-resource>
<connector-connection-pool
connection-definition-name="javax.jms.ConnectionFactory"
fail-all-connections="false" idle-timeout-in-seconds="300"
is-connection-validation-required="false" max-pool-size="32"
max-wait-time-in-millis="60000" name="amqpool" pool-resize-quantity="2"
resource-adapter-name="activemq-rar-5.6.0" steady-pool-size="2" />
<admin-object-resource res-adapter="activemq-rar-5.6.0"
res-type="javax.jms.Queue" jndi-name="amqmsg"></admin-object-resource>
</resources>
additions to pom.xml
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-rar</artifactId>
<version>5.6.0</version>
<type>rar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.6.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Q1: How is glassfish-resources.xml loaded? Should i use maven admin command or place it in some META-INF?
edit: looks like it goes in web-inf if war and meta-inf if ejb-jar
Q2: Not entirely sure what is the next step. #1 has me copy activemq and log4j libraries to GLASSFISH_HOME/glassfish/lib so far I only added the dependency in the pom.xml, what is the equivalent here?
Q3: The Rar needs to be deployed as well. How can multiple applications be deployed?

Resources