Showing posts with label Spring. Show all posts
Showing posts with label Spring. Show all posts

Wednesday, 16 May 2012

JAXB: Marshal exception while marshalling generics, class nor any of its classes known to this context

If you have a class as ServiceResult<T> with a generic parameter and you get exception as "class my.examples.dto.ResultDto nor any of its classes known to this context" while marshalling although you have ResultDto in Jaxb context, try @XmlSeeAlso as below

@XmlRootElement
@XmlSeeAlso(ResultDto.class, ResultDtoAnother.class)
public class ServiceResult<T> {
public T result;
}

This resolves the issue temporarily until we have a cleaner solution from JaxB

Wednesday, 7 September 2011

Auto scan hibernate entity beans like component-scan for general spring components

Use the following configuration to auto scan your hibernate entity beans.

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

<property name="dataSource" ref="resourcesDataSource" />
<property name="packagesToScan">
<list>
<value>my.packages.hibernate.domain</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>

</property>
</bean>