in my web application developped with GWT, Hibernate ans Spring, I encounter when setting the jobClass bean in the application-context.xml file.
I get this error at runtime :
Error 500 Error creating bean with name 'schedulerFactory' defined in class path resource [application-context.xml]:
Cannot resolve reference to bean 'cronTrigger' while setting bean property 'triggers' with key [0];
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'cronTrigger' defined in class path resource [application-context.xml]:
Cannot resolve reference to bean 'exampleJob1' while setting bean property 'jobDetail';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'exampleJob1' defined in class path resource [application-context.xml]:
Initialization of bean failed;
nested exception is org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [fr.web.utils.ExampleJob] to required type [java.lang.Class] for property 'jobClass';
nested exception is java.lang.IllegalArgumentException:
Cannot convert value of type [fr.web.utils.ExampleJob] to required type [java.lang.Class] for property 'jobClass':
PropertyEditor [org.springframework.beans.propertyeditors.ClassEditor] returned inappropriate value
Here is my Java class :
public class ExampleJob extends QuartzJobBean {
private AbsenceDao absenceDao;
#Override
protected void executeInternal(JobExecutionContext context)
throws JobExecutionException {
List untreatedDemands = new ArrayList();
untreatedDemands = absenceDao.getDemandsAskedNotValidated();
}
public AbsenceDao getAbsenceDao() {
return absenceDao;
}
public void setAbsenceDao(AbsenceDao absenceDao) {
this.absenceDao = absenceDao;
}
}
and here is my application-context.xml :
<!-- variables d'environnement - fichier properties -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="placeholderconfig">
<property name="fileEncoding" value="UTF-8"/>
<property name="locations">
<list>
<value>classpath:internal.properties</value>
</list>
</property>
</bean>
<!-- Configuration du crontrigger -->
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref local="exampleJob1" />
</property>
<property name="cronExpression">
<util:constant static-field="fr.web.utils.APP_VAR.CRON_EXPRESSION" />
</property>
</bean>
<bean id="jobClass" class="fr.web.utils.ExampleJob">
<property name="absenceDao" ref="absenceDao"/>
</bean>
<bean id="exampleJob1" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" ref="jobClass" />
<property name="jobDataAsMap">
<map>
<entry key="timeout" value="5" />
</map>
</property>
</bean>
<tx:annotation-driven transaction-manager="hibernateTransactionManager"/>
<!-- Bean containing all the properties of the application -->
<bean class="fr.web.utils.ApplicationProperties" id="applicationProperties" lazy-init="true" scope="singleton">
<constructor-arg index="0" value="classpath:internal.properties"/>
</bean>
<!-- Bean DAO -->
<bean abstract="true" id="abstractDao">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean class="fr.web.dao.AbsenceDao" id="absenceDao" parent="abstractDao"/>
</bean>
</beans>
property jobClass requires class and you have given reference of bean , So change
<bean id="exampleJob1" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" ref="jobClass" />
<property name="jobDataAsMap">
<map>
<entry key="timeout" value="5" />
</map>
</property>
</bean>
to (Note : value attribute below)
<bean id="exampleJob1" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="fr.acensi.web.utils.ExampleJob" />
<property name="jobDataAsMap">
<map>
<entry key="timeout" value="5" />
</map>
</property>
</bean>
There is another option here which you may think neater or not, I like it as it keeps the context a bit cleaner.
<bean id="exampleJob1" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<bean factory-bean="jobClass" factory-method="getClass" />
</property>
</bean>
the breakdown of the problem is as Jigar Joshi describes solution is slighty different.
It allows you to keep you bean jobClass instantiation seperate from the building of the JobDetailbean.
Related
I am getting this error when a bean of my project is initializated:
Could not convert constructor argument value of type [com.sun.proxy.$Proxy42] to required type [org.springframework.batch.item.file.MultiResourceItemReader]
This MultiResourceItemReader is a property of a FlatFileItemReader. In other spring batch jobs I have it the same without problems, but I can't localize the cause of the proxy conversion here. This is the bean definition of the linemapper.:
<bean id="updateStateBlocksReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
<property name="strict" value="false" />
<property name="recordSeparatorPolicy" ref="skipBlankLinesPolicy" />
<property name="comments">
<array value-type="java.lang.String">
<value>HEADER</value>
<value>FOOTER</value>
</array>
</property>
<property name="lineMapper">
<bean class="com.telefonica.gest.jt.nuc.myjob.reader.MyCustomLineMapper">
<constructor-arg ref="updateStateBlocksMultiReader" /> *****----> Error line
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value=";" />
<property name="names" value="field1,field2" />
</bean>
</property>
<property name="fieldSetMapper">
<bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" ref="readerDTO" />
</bean>
</property>
</bean>
</property>
</bean>
<!-- This is the MultiResourceItemReader used as argument in the constructor of the lineMapper (To extract the current fileName) -->
<bean id="updateStateBlocksMultiReader" class="org.springframework.batch.item.file.MultiResourceItemReader" scope="step">
<property name="resources" value="file:#{jobExecutionContext['PATH_IN']}/#{jobExecutionContext['FILENAME_IN']}"/>
<property name="delegate" ref="updateStateBlocksReader"/>
</bean>
I tried adding a StepScope bean with a proxyTargetClass property setted to "true" but not works. Finally I leave here the java of "MyCustomLineMapper.java" so you can see the constructor:
public class MyCustomLineMapper<T> implements LineMapper<BaseDTO>, InitializingBean {
private LineTokenizer tokenizer;
private BeanWrapperFieldSetMapper<BaseDTO> fieldSetMapper;
private MultiResourceItemReader<T> delegator;
public MyCustomLineMapper(final MultiResourceItemReader<T> delegator) {
this.delegator = delegator;
}
public BaseDTO mapLine(final String line, final int lineNumber) throws Exception {
...
I am tried moving the bean scopes and config the proxyTargetclass property without effect. Not sure how continue with this. Sorry my bad english and Thanks.
This question may sound old but I am not able to use multiple properties files as after looking for solution I came to know that for validator class I added hibernate validator 4,5,Jboss Logging final jars and now Its saying
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1197783': Cannot resolve reference to bean 'validator' while setting bean property 'validator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'validator' defined in ServletContext resource [/WEB-INF/springDispatcherServlet-servlet.xml]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider;
and this is my configuration file
<mvc:annotation-driven enable-matrix-variables="true"
validator="validator" />
<context:component-scan base-package="com.*" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/views/" />
<property name="suffix" value=".jsp" />
</bean>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="language" />
</bean>
</mvc:interceptor>
</mvc:interceptors>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
value="/com/resources/messages,/com/resources/messages_validation.properties"
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
</bean>
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="validationMessageSource" ref="messageSource" />
</bean>
name of properties file (they are in same folder)
messages_en.properties
messages_nl.properties
messages_validations.properties
I am not able to understand why It is giving me error if everything is in right place
Please help
Try,
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:com/resources/messages</value>
<value>classpath:com/resources</value>
</list>
</property>
</bean>
I guess this should work assuming your messageproperties is under /com/resources
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:/com/resources/messages/" />
<property name="defaultEncoding" value="UTF-8" />
<property name="fallbackToSystemLocale" value="false"/>
</bean>
I have a project in Java 1.6 and I have to pass in java 1.8.
I get this error :
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private net.amm.noc.telecom.reporting.services.TicketManager net.amm.noc.telecom.reporting.integration.itest.EndToEndTestCase.ticketManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [net.amm.noc.telecom.reporting.services.TicketManager] is defined: expected single matching bean but found 2: [ticketManager, proxiedTicketManagerImpl]
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [net.amm.noc.telecom.reporting.services.TicketManager] is defined: expected single matching bean but found 2: [ticketManager, proxiedTicketManagerImpl]
Exception in thread "ActiveMQ ShutdownHook" java.lang.NoClassDefFoundError: org/apache/activemq/transport/vm/VMTransportFactory
at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:518)
at org.apache.activemq.broker.BrokerService.containerShutdown(BrokerService.java:1754)
at org.apache.activemq.broker.BrokerService$4.run(BrokerService.java:1732)
Caused by: java.lang.ClassNotFoundException: org.apache.activemq.transport.vm.VMTransportFactory
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
... 3 more
My class test :
#ContextConfiguration(locations = { "classpath:/application-context.xml" })
public class EndToEndTestCase extends AbstractTestNGSpringContextTests {
#Autowired
#Qualifier("ticketManager")
private TicketManager ticketManager;
/**
* This test relies on the proxied ticketManager (stub) to send the NLV
* buffer on the bus. The deployed skeleton intercepts the message,
* transform it and delegates the process to the actual bean.
*/
#Test
public void test1() {...
And the appContext :
<!-- defines which bean are service requests delegated to -->
<alias name="proxiedTicketManagerImpl" alias="ticketManagerImpl" />
<!-- defines which bean are response requests delegated to -->
<alias name="proxiedTicketResponseImpl" alias="ticketResponseImpl" />
<bean id="telecomReportingMethodInvocationInterceptor"
class="net.amm.noc.integration.itest.MethodInvocationInterceptor">
<property name="channel" value="TICKET-MANAGER" />
</bean>
<bean id="proxiedTicketManagerImpl" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyTargetClass" value="true" />
<property name="target">
<bean
class="net.amm.noc.telecom.reporting.mock.TicketManagerMock">
<property name="ticketResponse" ref="ticketResponse" />
</bean>
</property>
<property name="interceptorNames">
<list>
<value>telecomReportingMethodInvocationInterceptor</value>
</list>
</property>
</bean>
<bean id="proxiedTicketResponseImpl" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyTargetClass" value="true" />
<property name="target">
<bean class="net.amm.noc.telecom.reporting.mock.TicketResponseMock" />
</property>
<property name="interceptorNames">
<list>
<value>telecomReportingMethodInvocationInterceptor</value>
</list>
</property>
</bean>
<bean id="ticketManager" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="interfaces" value="net.amm.noc.telecom.reporting.services.TicketManager" />
<property name="proxyInterfaces" value="net.amm.noc.telecom.reporting.services.TicketManager" />
<property name="target">
<bean class="java.lang.Object" />
</property>
<property name="interceptorNames">
<list>
<value>telecomReportingServiceInterceptor</value>
</list>
</property>
</bean>
<bean id="telecomReportingServiceInterceptor"
class="net.amm.noc.integration.client.aop.ServiceInterceptor">
<property name="serviceMessageEncoder" ref="telecomReportingEncoder" />
<property name="serviceCaller">
<bean class="net.amm.noc.integration.mep.client.MepServiceCaller">
<property name="responseListener" ref="telecomReportingResponseListener"></property>
<property name="contextFactory">
<bean
class="net.amm.noc.integration.mep.client.MepServiceClientContextFactory"
init-method="init">
<property name="serviceDefinition">
<bean
class="net.amm.noc.integration.mep.service.GenericServiceDefinition">
<property name="category" value="NOC" />
<property name="name" value="TEL_REPORT" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
Does anyone can help me solve this problem?
For information, it's OK with Java 1.6
Thank you.
I have simple application with following folder structure:
ProjFolder
|-----src
|----------packagename
|---------------{sourcefiles}
|----------META-INF
|---------------{beans.xml}
|---------------{hibernate.cfg.xml}
|---------------{EntityMapping.hbm.xml}
here is the part of beans.xml Spring config file:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:./META-INF/jdbc.properties" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:./META-INF/hibernate.cfg.xml" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>classpath:./META-INF/EntityMapping.hbm.xml</value>
</list>
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
when i start my unit tests i getting following exception:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'wrapperClass' defined in class path resource
[META-INF/beans.xml]: Cannot resolve reference to bean 'wrapperClassField'
while setting constructor argument; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'xmlBooksource' defined in class path resource
[META-INF/beans.xml]: Cannot resolve reference to bean
'sessionFactory' while setting bean property 'sessionFactory'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in class path
resource [META-INF/beans.xml]: Invocation of init method failed;
nested exception is java.io.FileNotFoundException: class path resource
[classpath:/META-INF/EntityMapping.hbm.xml] cannot be opened because it does not exist
The same exception is thrown when i type
<property name="mappingResources">
<list>
<value>EntityMapping.hbm.xml</value>
</list>
</property>
Why spring cant find this file and how i must fill its location to make this code work?
Thanks in advance.
Have you tried removing the classpath: prefix? In looking at the Hibernate code, the mappingResources setter expects passes the strings to new ClassPathResource(String). This expects classpath resources already. The string then gets passed to ClassLoader.getResourceAsStream(String). None of this code would strip the "classpath:" prefix from the front of the resource string.
I'm not sure the error message is consistent with the beans.xml content you posted.
In the error you have
[classpath:/META-INF/EntityMapping.hbm.xml]
which isn't the same as
classpath:./META-INF/EntityMapping.hbm.xml
Notice the missing "." at the beginning in the error.
The second beans.xml configuration, should probably produce a different error message with:
[classpath:EntityMapping.hbm.xml]
This would be searching for the file in the root of your compiled application (jar, war, exploded, what have you).
I have successfully configure Hibernate 4 with Spring 3.1. My applicationContext.xml file is inside web-inf folder and has the following hibernate cofiguration:
<!-- Session Factory Declaration -->
<bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="DataSource" />
<!--
<property name="annotatedClasses">
<list>
<value>iltaf.models.Levels</value>
</list>
</property>
-->
<property name="mappingLocations" value="classpath:iltaf/models/*.hbm.xml" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/>
<!-- Transaction Manager is defined -->
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="SessionFactory"/>
</bean>
</beans>
and I have separate hibernate.cfg.xml file inside my src folder. I am using Eclipse Juno Java EE version.
I am using Spring 3.0.5.Release MVC for exposing a webservice and below is my servlet.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"
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">
<!-- To enable #RequestMapping process on type level and method level -->
<context:component-scan base-package="com.pyramid.qls.progressReporter.service" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="marshallingConverter" />
<ref bean="atomConverter" />
<ref bean="jsonConverter" />
</list>
</property>
</bean>
<bean id="marshallingConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<constructor-arg ref="jaxbMarshaller" />
<property name="supportedMediaTypes" value="application/xml"/>
</bean>
<bean id="atomConverter" class="org.springframework.http.converter.feed.AtomFeedHttpMessageConverter">
<property name="supportedMediaTypes" value="application/atom+xml" />
</bean>
<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json" />
</bean>
<!-- Client -->
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<ref bean="marshallingConverter" />
<ref bean="atomConverter" />
<ref bean="jsonConverter" />
</list>
</property>
</bean>
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.pyramid.qls.progressReporter.impl.BatchProgressMetricsImpl</value>
<value>com.pyramid.qls.progressReporter.datatype.InstrumentStats</value>
<value>com.pyramid.qls.progressReporter.datatype.InstrumentInfo</value>
<value>com.pyramid.qls.progressReporter.datatype.BatchProgressMetricsList</value>
<value>com.pyramid.qls.progressReporter.datatype.LoadOnConsumer</value>
<value>com.pyramid.qls.progressReporter.datatype.HighLevelTaskStats</value>
<value>com.pyramid.qls.progressReporter.datatype.SessionStats</value>
<value>com.pyramid.qls.progressReporter.datatype.TaskStats</value>
<value>com.pyramid.qls.progressReporter.datatype.ComputeStats</value>
<value>com.pyramid.qls.progressReporter.datatype.DetailedInstrumentStats</value>
<value>com.pyramid.qls.progressReporter.datatype.ImntHistoricalStats</value>
</list>
</property>
</bean>
<bean id="QPRXmlView" class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg ref="jaxbMarshaller" />
</bean>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="xml" value="application/xml"/>
<entry key="html" value="text/html"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
</bean>
<bean id="QPRController" class="com.pyramid.qls.progressReporter.service.QPRController">
<property name="jaxb2Mashaller" ref="jaxbMarshaller" />
</bean>
</beans>
Following is what i am doing in controller (QPRController)
#RequestMapping(value = "/clientMetrics/{clientId}", method = RequestMethod.GET)
public ModelAndView getBatchProgressMetrics(#PathVariable String clientId) {
List<BatchProgressMetrics> batchProgressMetricsList = null;
batchProgressMetricsList = batchProgressReporter.getBatchProgressMetricsForClient(clientId);
BatchProgressMetricsList batchList = new BatchProgressMetricsList(batchProgressMetricsList);
ModelAndView mav = new ModelAndView("QPRXmlView", BindingResult.MODEL_KEY_PREFIX + "batchProgressMetrics", batchList);
return mav;
}
This is what my batchprogressmetricsList looks like:
#XmlRootElement(name = "batchProgressMetrics")
public class BatchProgressMetricsList implements Serializable{
private int count;
private List<BatchProgressMetrics> batchProgressMetricsList;
public BatchProgressMetricsList() {
}
public BatchProgressMetricsList(List<BatchProgressMetrics> batchProgressMetricsList) {
this.batchProgressMetricsList = batchProgressMetricsList;
this.count = batchProgressMetricsList.size();
}
public int getCount() {
return count;
}
#XmlElement(name = "batchProgressMetrics1")
public List<BatchProgressMetrics> getBatchProgressMetrics() {
return batchProgressMetricsList;
}
Now i get the following:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'QPRController' defined in ServletContext resource [/WEB-INF/rest-servlet.xml]: Cannot resolve reference to bean 'jaxbMarshaller' while setting bean property 'jaxb2Mashaller'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jaxbMarshaller' defined in ServletContext resource [/WEB-INF/rest-servlet.xml]: Invocation of init method failed; nested exception is org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
com.pyramid.qls.progressReporter.iface.BatchProgressMetrics is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at com.pyramid.qls.progressReporter.iface.BatchProgressMetrics
at public java.util.List com.pyramid.qls.progressReporter.datatype.BatchProgressMetricsList.getBatchProgressMetrics()
at com.pyramid.qls.progressReporter.datatype.BatchProgressMetricsList
com.pyramid.qls.progressReporter.iface.BatchProgressMetrics does not have a no-arg default constructor.
this problem is related to the following location:
at com.pyramid.qls.progressReporter.iface.BatchProgressMetrics
at public java.util.List com.pyramid.qls.progressReporter.datatype.BatchProgressMetricsList.getBatchProgressMetrics()
at com.pyramid.qls.progressReporter.datatype.BatchProgressMetricsList
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
Previously i got this without the change.
SEVERE: Servlet.service() for servlet rest threw exception
javax.servlet.ServletException: Unable to locate object to be marshalled in model: {org.springframework.validation.BindingResult.batchProgressMetrics=
Note that BatchProgressMetrics is an interface so my MAV is returning list of BatchProgressMetrics objects and i have entry for its impl in classes to be bound in servlet.xml.
Can you please help me as to what i am doing wrong. And yes if i send just batchProgressMetricsList.get(0) in MAV it just works fine.
This because the JAXB context doesn't know how to handle lists of objects, only the objects themselves. It makes sense when you think about it - the only way to represent a list in XML is to wrap it in a container element, and it has no information as to how to do that.
So you need to define a class which is the container for the list of BatchProgressMetrics, and return that in the model instead.