Getting com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException when using JsonItemReader with JacksonJsonObjectReader - jackson

I am facing an issue with spring batch JsonItemReader, getting the above error when trying to read from json file.
JsonItemReader configuration
#Autowired
private ObjectMapper objectMapper;
#StepScope
#Bean
public JsonItemReader<CustomerDTO> customerItemReader(){
return new JsonItemReaderBuilder<CustomerDTO>()
.jsonObjectReader(new JacksonJsonObjectReader<>(objectMapper,CustomerDTO.class))
.resource(new FileSystemResource(customerFilePath))
.name("jsonCustomerItemReader")
.build();
}
DTO
#Data
public class CustomerDTO {
private int id;
private String firstName;
private String lastName;
private String gender;
private String contactNo;
private String country;
private String dob;
}
Json Sample
[
{
"id": 372,
"firstName": "Jessie",
"lastName": "Campos",
"gender": "female",
"contactNo": "(828) 559-3435",
"country": "Poland",
"dob": "2017-04-03T11:15:53 -08:00"
}
]
Stacktrace
As seen here, the error states that the id is not found in the CustomerDTO object. Not sure why I am getting the error.
org.springframework.batch.item.ParseException: Unable to read next
JSON object at
org.springframework.batch.item.json.JacksonJsonObjectReader.read(JacksonJsonObjectReader.java:90)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.item.json.JsonItemReader.doRead(JsonItemReader.java:110)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.read(AbstractItemCountingItemStreamItemReader.java:93)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader$$FastClassBySpringCGLIB$$ebb633d0.invoke()
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
~[spring-core-5.3.23.jar:5.3.23] at
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:137)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.batch.item.json.JsonItemReader$$EnhancerBySpringCGLIB$$299546ea.read()
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.core.step.item.SimpleChunkProvider.doRead(SimpleChunkProvider.java:99)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.step.item.SimpleChunkProvider.read(SimpleChunkProvider.java:180)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.step.item.SimpleChunkProvider$1.doInIteration(SimpleChunkProvider.java:126)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.core.step.item.SimpleChunkProvider.provide(SimpleChunkProvider.java:118)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:71)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:407)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:331)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
~[spring-tx-5.3.23.jar:5.3.23] at
org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:273)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:82)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] at
org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:258)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:208)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:152)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:413)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:136)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:320)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:149)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
~[spring-core-5.3.23.jar:5.3.23] at
org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:140)
~[spring-batch-core-4.3.7.jar:4.3.7] at
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
~[na:na] at
java.base/java.lang.reflect.Method.invoke(Method.java:578) ~[na:na]
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:128)
~[spring-batch-core-4.3.7.jar:4.3.7] at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
~[spring-aop-5.3.23.jar:5.3.23] at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
~[spring-aop-5.3.23.jar:5.3.23] at
jdk.proxy2/jdk.proxy2.$Proxy93.run(Unknown Source) ~[na:na] at
org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.execute(JobLauncherApplicationRunner.java:199)
~[spring-boot-autoconfigure-2.7.4.jar:2.7.4] at
org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.executeLocalJobs(JobLauncherApplicationRunner.java:173)
~[spring-boot-autoconfigure-2.7.4.jar:2.7.4] at
org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.launchJobFromProperties(JobLauncherApplicationRunner.java:160)
~[spring-boot-autoconfigure-2.7.4.jar:2.7.4] at
org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.run(JobLauncherApplicationRunner.java:155)
~[spring-boot-autoconfigure-2.7.4.jar:2.7.4] at
org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.run(JobLauncherApplicationRunner.java:150)
~[spring-boot-autoconfigure-2.7.4.jar:2.7.4] at
org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762)
~[spring-boot-2.7.4.jar:2.7.4] at
org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:752)
~[spring-boot-2.7.4.jar:2.7.4] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
~[spring-boot-2.7.4.jar:2.7.4] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
~[spring-boot-2.7.4.jar:2.7.4] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
~[spring-boot-2.7.4.jar:2.7.4] at
com.example.BatchApplication.main(BatchApplication.java:11)
~[classes/:na] Caused by:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
Unrecognized field "id" (class com.example.batch.dto.CustomerDTO), not
marked as ignorable (0 known properties: ]) at [Source:
(sun.nio.ch.ChannelInputStream); line: 3, column: 14] (through
reference chain: com.example.batch.dto.CustomerDTO["id"]) at
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
~[jackson-databind-2.13.4.jar:2.13.4] at
com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:1127)
~[jackson-databind-2.13.4.jar:2.13.4] at
com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:2023)
~[jackson-databind-2.13.4.jar:2.13.4] at
com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1700)
~[jackson-databind-2.13.4.jar:2.13.4] at
com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1678)
~[jackson-databind-2.13.4.jar:2.13.4] at
com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:320)
~[jackson-databind-2.13.4.jar:2.13.4] at
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
~[jackson-databind-2.13.4.jar:2.13.4] at
com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
~[jackson-databind-2.13.4.jar:2.13.4] at
com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4650)
~[jackson-databind-2.13.4.jar:2.13.4] at
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2831)
~[jackson-databind-2.13.4.jar:2.13.4] at
org.springframework.batch.item.json.JacksonJsonObjectReader.read(JacksonJsonObjectReader.java:87)
~[spring-batch-infrastructure-4.3.7.jar:4.3.7] ... 58 common frames
omitted
UPDATE (Workaround)
After a few hours of debugging, It seems that if I don't use lombok #Data annotation and generate the getters and setters its working. Also if I annotate my DTO with #JsonProperty("") its also able to work. Is there a configuration for jackson which I am missing?

Seems that I was missing annotationProcessorPath for lombok in my maven compiler plugin. After updating it to below was able to use the JacksonJsonObjectReader with #Data annotation from lombok.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>19</source>
<target>19</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${version.mapstruct}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${version.lombok}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>${version.mapstruct-lombok}</version>
</path>
</annotationProcessorPaths>
</configuration>

Related

Upgrade from Infinispan 8 to 12

I am upgrading my project from infinispan cache version 8 to 12. After upgrading to infinispan 12 it is no longer possible to serialize a GregorianCalendar java type , resulting in the following error:
ERROR c.m.DemonAlimDatasManagerCourant - Erreur lors de l'alimentation des caches: ISPN000615: Unable to unmarshall 'java.util.GregorianCalendar' as a marshaller is not present in the user or global SerializationContext
org.infinispan.commons.marshall.MarshallingException: ISPN000615: Unable to unmarshall 'java.util.GregorianCalendar' as a marshaller is not present in the user or global SerializationContext
at org.infinispan.encoding.ProtostreamTranscoder.getCtxForMarshalling(ProtostreamTranscoder.java:198)
at org.infinispan.encoding.ProtostreamTranscoder.marshall(ProtostreamTranscoder.java:127)
at org.infinispan.encoding.ProtostreamTranscoder.transcode(ProtostreamTranscoder.java:68)
at org.infinispan.encoding.DataConversion.toStorage(DataConversion.java:227)
at org.infinispan.cache.impl.EncoderCache.valueToStorage(EncoderCache.java:105)
at org.infinispan.cache.impl.EncoderCache.put(EncoderCache.java:698)
at com.manager.DemonAlimDatasManagerCourant.alimenterData(DemonAlimDatasManagerCourant.java:180)
at com.manager.DemonAlimDatasManagerCourant.alimenterInstance(DemonAlimDatasManagerCourant.java:127)
at com.manager.DemonAlimDatasManagerCourant$$FastClassBySpringCGLIB$$a48662da.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at com.manager.DemonAlimDatasManagerCourant$$EnhancerBySpringCGLIB$$de1659e7.alimenterInstance(<generated>)
at com.manager.DemonAlimDatasCourantService.enterDaemon(DemonAlimDatasCourantService.java:53)
at com.manager.DemonAlimDatasCourantService$$FastClassBySpringCGLIB$$723f4b20.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at com.manager.DemonAlimDatasCourantService$$EnhancerBySpringCGLIB$$ea996e79.enterDaemon(<generated>)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
I tried with adding to my config file but it didin't give me a result
<?xml version="1.0" encoding="UTF-8"?>
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:12.1 http://infinispan.org/schemas/infinispan-config-12.1.xsd"
xmlns="urn:infinispan:config:12.1">
<cache-container default-cache="default" shutdown-hook="REGISTER">
<transport stack="tcp" node-name="ecr-dec-cache-light" cluster="ecr-cluster"/>
<serialization marshaller="org.infinispan.commons.marshall.JavaSerializationMarshaller">
<allow-list>
<class>java.util.GregorianCalendar</class>
</allow-list>
</serialization>
<jmx/>
<distributed-cache name="default" />
<distributed-cache name="parametrage" statistics="true" mode="SYNC" owners="1" remote-timeout="3600000">
<locking acquire-timeout="60000" />
<state-transfer enabled="false" />
</distributed-cache>
Is there any other solution?

Jackson MismatchedInputException : no String-argument constructor/factory method to deserialize from String value

I use RestTemplate.exchange in my Spring Boot app to GET this response:
<?xml version="1.0" encoding="UTF-8"?>
<advertisers current_page="1" per_page="10" total_pages="1" total_entries="1">
<advertiser>
<id>1057343</id>
<name>SOME ADVERTISER</name>
<status>ACTIVE</status>
<created_at>2021-10-12T09:06:12Z</created_at>
<updated_at>2022-04-08T13:36:50Z</updated_at>
</advertiser>
</advertisers>
Advertisers.java:
#Data
#FieldDefaults(level = AccessLevel.PRIVATE)
public class Advertisers {
List<Advertiser> advertiser;
}
Advertiser.java:
#Data
#FieldDefaults(level = AccessLevel.PRIVATE)
public class Advertiser {
String id;
String name;
String status;
}
But I get the following exception:
org.springframework.web.client.RestClientException: Error while extracting response for type [class fr.canalplus.tvseg.models.freewheel.entities.Advertisers] and content type [application/xml;charset=utf-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `fr.canalplus.tvseg.models.freewheel.entities.Advertiser` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('1057343'); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `fr.canalplus.tvseg.models.freewheel.entities.Advertiser` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('1057343')
at [Source: (ByteArrayInputStream); line: 4, column: 16] (through reference chain: fr.canalplus.tvseg.models.freewheel.entities.Advertisers["advertiser"]->java.util.ArrayList[0])
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:120)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:1037)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:1020)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:778)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602)
at fr.canalplus.tvseg.services.FreeWheelService.exchange(FreeWheelService.java:102)
at fr.canalplus.tvseg.services.FreeWheelService.getCreativeAdvertiser(FreeWheelService.java:154)
at fr.canalplus.tvseg.controllers.TestController.test(TestController.java:23)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1060)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `fr.canalplus.tvseg.models.freewheel.entities.Advertiser` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('1057343'); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `fr.canalplus.tvseg.models.freewheel.entities.Advertiser` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('1057343')
at [Source: (ByteArrayInputStream); line: 4, column: 16] (through reference chain: fr.canalplus.tvseg.models.freewheel.entities.Advertisers["advertiser"]->java.util.ArrayList[0])
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:387)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:342)
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:105)
... 58 more
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `fr.canalplus.tvseg.models.freewheel.entities.Advertiser` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('1057343')
at [Source: (ByteArrayInputStream); line: 4, column: 16] (through reference chain: fr.canalplus.tvseg.models.freewheel.entities.Advertisers["advertiser"]->java.util.ArrayList[0])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1455)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1081)
at com.fasterxml.jackson.databind.deser.ValueInstantiator._createFromStringFallbacks(ValueInstantiator.java:371)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:323)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1408)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:176)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:166)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:290)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:371)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:164)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4526)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3521)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:376)
... 60 more
I don't understand why the id '1057343' can't be deserialize.
Can you help please? Thank you in advance
The exception thrown by Jackson is really quite misleading.
You need to tell Jackson that your sequence of
<advertiser> ...</advertiser> elements is not wrapped
by an additional XML element.
You do this in your Advertisers class
by annotating the List<Advertiser> property with
#JacksonXmlElementWrapper(useWrapping = false)
See also the javadoc of JacksonXmlElementWrapper.useWrapping.

Arquillian managed container : Server not detected

So I "installed" Arquillian in my jboss project. I used managed container. The server is starting up when I launch my test class. I increased the timeout to 120s instead of 60s to be sure. The problem is that once the server is launched (an i can navigate in the web application), the test is never launched...
On the JUnit tab nothing is happening until the 120s are over and then I get a timeout as if the server that was started is not detected.
Once this error occured, the server is shutdown, so there is has to be a link right ?
Did anyone had the same error ?
Thanks
CODE:
this is the container in arquilian.xml
<container qualifier="jbossas-managed" default="true">
<configuration>
<property name="jbossHome">C:\Developpement\jboss-as-7.1.3.Final</property>
<property name="startupTimeoutInSeconds">120</property>
<property name="javaVmArguments">-server -Xms64m -Xmx6g -XX:MaxPermSize=1024m -Dorg.jboss.as.logging.per-deployment=false -Djava.util.Arrays.useLegacyMergeSort=true -Xrunjdwp:transport=dt_socket,address=8180,server=y,suspend=y</property>
<property name="managementPort">8180</property>
<property name="allowConnectingToRunningServer">true</property>
</configuration>
I use this in my pom file:
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>7.1.3.Final</version>
<exclusions>
<exclusion>
<groupId>google-collections</groupId>
<artifactId>google-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<version>1.2.1.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.0.4.Final</version>
</dependency>
This is my test file:
#RunWith(Arquillian.class)
public class BasculeTest {
private static final int COMPLETE = 0;
private static final int MONTH_INCREMENTATION = 1;
private static final int BASCULE = 2;
private static final int YEAR_INCREMENTATION = 3;
// #Inject CompteursCongesUpdate compteursCongesUpdate;
#Deployment
public static Archive<?> createTestArchive() {
WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war").addClass(CompteursCongesUpdate.class)
.addAsWebInfResource("test-persistence.xml", "classes/META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
return war;
}
#Test
public void testBascule() {
System.out.println("------------------------------- Début TEST -------------------------------");
try {
// compteursCongesUpdate.updateCompteursConges(new Date(), MONTH_INCREMENTATION);
// System.out.println("test +" +compteursCongesUpdate);
System.out.println("--------");
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Une exception a ete levee");
}
Assert.fail("Not yet implemented");
}
}
What I can do now is start the server normally (without executing the test class with junit) and afterwards execute the test class, once the server is runnng. Then I get a new error from log4j: nosuchfielderror: NO_FORMAT
java.lang.NoSuchFieldError: NO_FORMAT
at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:106)
at org.apache.log4j.Category.forcedLog(Category.java:118)
at org.apache.log4j.Category.log(Category.java:288)
at org.jboss.logging.Log4jLogger.doLogf(Log4jLogger.java:48)
at org.jboss.logging.Logger.debugf(Logger.java:565)
at org.jboss.as.arquillian.protocol.jmx.JMXProtocolPackager.generateArquillianServiceArchive(JMXProtocolPackager.java:112)
at org.jboss.as.arquillian.protocol.jmx.JMXProtocolPackager.generateDeployment(JMXProtocolPackager.java:101)
at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.buildTestableDeployments(DeploymentGenerator.java:193)
at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.createTestableDeployments(DeploymentGenerator.java:148)
at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:182)
at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Unable to initialize JCR_MOCK resource resolver factory - sling mocks

I have a simple sling mock test that is loading json data
public class Test {
#Rule
public final SlingContext context = new SlingContext(ResourceResolverType.JCR_MOCK);
#Before
public void setUp() {
context.load().json("/test-1.json", "/content/test");
}
#Test
public void testLoad() {
Resource resource = context.resourceResolver().getResource("/content/test");
}
}
I have the following dependencies added to my pom.xml
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.sling-mock</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.testing</artifactId>
<version>2.0.16</version>
<scope>test</scope>
</dependency>
When i execute this, I get the following exception, even though sling.api (v2.2) is an existing dependency in the pom
java.lang.RuntimeException: Unable to initialize JCR_MOCK resource resolver factory.
at org.apache.sling.testing.mock.sling.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:66)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.newResourceResolverFactory(SlingContextImpl.java:103)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.setUp(SlingContextImpl.java:94)
at org.apache.sling.testing.mock.sling.junit.SlingContext.access$000(SlingContext.java:32)
at org.apache.sling.testing.mock.sling.junit.SlingContext$1.before(SlingContext.java:113)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.NoClassDefFoundError: org/apache/sling/api/resource/ResourceProviderFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.apache.sling.testing.mock.sling.MockJcrResourceResolverFactory.getResourceResolverInternal(MockJcrResourceResolverFactory.java:74)
at org.apache.sling.testing.mock.sling.MockJcrResourceResolverFactory.getResourceResolver(MockJcrResourceResolverFactory.java:111)
at org.apache.sling.testing.mock.sling.context.ContextResourceResolverFactory.initializeJcrMock(ContextResourceResolverFactory.java:72)
at org.apache.sling.testing.mock.sling.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:52)
... 21 more
Caused by: java.lang.ClassNotFoundException: org.apache.sling.api.resource.ResourceProviderFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 37 more
Can someone please help?
You are missing a dependency on org.apache.sling.api ( as shown by a search by class name on search.maven.org )

slf4j don't work in JBOSS when using openJpa module

My EAR application runs fine when i don't use openJpa. Once i use open JPA i get the "SLF4J fail to load class blaaa ". How to configure the openJpa module to use the SL4J which i provide from pom.xml and avoid that error?
I use JBOSS 7.1.1
pom.xml
<properties>
<slf4j.version>1.7.3</slf4j.version>
<logback.version>1.0.10</logback.version>
</properties>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
.......
openjpa module.xml
<module xmlns="urn:jboss:module:1.1" name="org.apache.openjpa">
<resources>
<resource-root path="openjpa-2.2.0.jar"/>
<resource-root path="openjpa-all-2.2.0.jar"/>
</resources>
<dependencies>
<module name="javax.persistence.api"/>
<module name="javax.transaction.api"/>
<module name="javax.validation.api"/>
<module name="org.apache.commons.lang"/>
<module name="org.apache.commons.collections"/>
<module name="org.slf4j"/>
</dependencies>
</module>
jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
</exclusions>
</deployment>
</jboss-deployment-structure>
error
10:17:53,854 ERROR [stderr] (MSC service thread 1-4) SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
10:17:53,860 ERROR [stderr] (MSC service thread 1-4) SLF4J: Defaulting to no-operation (NOP) logger implementation
10:17:53,866 ERROR [stderr] (MSC service thread 1-4) SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
10:17:53,873 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Critical error during deployment: : java.lang.LinkageError: loader constraint violation: when resolving interface method "org.slf4j.ILoggerFactory.getLogger(Ljava/lang/String;)Lorg/slf4j/Logger;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/slf4j/ILoggerFactory, have different Class objects for the type org/slf4j/Logger used in the signature
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242) [openjpa-all-2.2.0.jar:2.2.0]
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254) [openjpa-all-2.2.0.jar:2.2.0]
at net.sf.ehcache.CacheManager.<clinit>(CacheManager.java:131) [ehcache-ee-2.6.2.jar:]
at com.zreflect.emyed.whiteboard.controller.CacheController.<init>(CacheController.java:39) [classes:]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_25]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [rt.jar:1.6.0_25]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [rt.jar:1.6.0_25]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_25]
at java.lang.Class.newInstance0(Class.java:355) [rt.jar:1.6.0_25]
at java.lang.Class.newInstance(Class.java:308) [rt.jar:1.6.0_25]
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:256) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:255) [jsf-impl-2.1.7-jbossorg-2.jar:]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_25]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]
10:17:54,007 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/emyed-whiteboard]] (MSC service thread 1-4) Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener: java.lang.RuntimeException: java.lang.LinkageError: loader constraint violation: when resolving interface method "org.slf4j.ILoggerFactory.getLogger(Ljava/lang/String;)Lorg/slf4j/Logger;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/slf4j/ILoggerFactory, have different Class objects for the type org/slf4j/Logger used in the signature
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292) [jsf-impl-2.1.7-jbossorg-2.jar:]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_25]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]
Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "org.slf4j.ILoggerFactory.getLogger(Ljava/lang/String;)Lorg/slf4j/Logger;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/slf4j/ILoggerFactory, have different Class objects for the type org/slf4j/Logger used in the signature
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242) [openjpa-all-2.2.0.jar:2.2.0]
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254) [openjpa-all-2.2.0.jar:2.2.0]
at net.sf.ehcache.CacheManager.<clinit>(CacheManager.java:131) [ehcache-ee-2.6.2.jar:]
at com.zreflect.emyed.whiteboard.controller.CacheController.<init>(CacheController.java:39) [classes:]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_25]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [rt.jar:1.6.0_25]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [rt.jar:1.6.0_25]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_25]
at java.lang.Class.newInstance0(Class.java:355) [rt.jar:1.6.0_25]
at java.lang.Class.newInstance(Class.java:308) [rt.jar:1.6.0_25]
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:256) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:255) [jsf-impl-2.1.7-jbossorg-2.jar:]
... 8 more
It looks like you're probably getting two different versions of sfl4j. Add <scope>provided</scope> to your slf4j dependency. The other option would be to provide a jboss-deployment-structure.xml to exclude the servers slf4j.
Example jboss-deployment-structure.xml:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="org.slf4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Also make sure you don't have a transitive slf4j dependencies, like sfl4j-jdk14.jar.