Wednesday, 20 June 2012

org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tx/spring-tx-3.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .

Exception in spring roo generated application when run offline

org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tx/spring-tx-3.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .

To identify the issue, take at look at maven dependency hierarchy and see the corresponding jar version from which the xsd is included. In my case, spring-security-web was referring to a 3.0.5 version of spring-tx that resulted in the exception.

I had to explicitly include 3.1.0 version of spring-tx in my pom file and the issue is gone.

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

Thursday, 8 March 2012

Download the latest snapshot from nexus using wget

From Maven 3, support for uniqueVersion is disabled and when you distribute your snapshots by publishing them on nexus you end up with snapshot names ending with timestamps. Suddenly your QA or Integration server scripts start failing if you are getting war file from nexus repository as there is no unique name now.

To get the latest version of snapshot you can use a service available from Nexus as

wget -O my-services.war http://nexus.myorg.net/nexus/service/local/artifact/maven/redirect?r=snapshots\&g=my.company.product.services\&a=my-services\&v=1.0-SNAPSHOT\&p=war

Where
r is the id of the repository
g is the group id
a is the artifact id
v is the version of artifact
p is the packaging type

The argument -O helps in renaming the output file to the name you want so that you have a fixed name you can use in your shell script.