Skip to main content

Posts

Showing posts from January, 2012

org.apache.maven.reactor.MavenExecutionException: Cannot find parent:

This exception will occur maven project has like below structure and parent POM is not installed in repository that means first time building. |-- my-module | `-- pom.xml `-- parent      `-- pom.xml   To solve this error need add relative path in other POMs in parent section.         <parent> <groupId>parent.group</groupId> <artifactId>parent.artifact</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>../parent/pom.xml</relativePath> </parent>

Caused by: java.lang.VerifyError:

java.lang.VerifyError occurs when overriding a final method from the parent class. In my situation implementation class is overriding a method from another library, now that library has changed and they made that method as final.  When  VerifyError comes, check the version of library or class has changed or not?

javac: invalid target release: 1.6

While running Maven build the below error occur, when there are more than one JDK installed.  Failure executing javac, but could not parse the error: javac: invalid target release: 1.6 Usage: javac <options> <source files> Example JDK 5 and JDK 6 has installed JDK 5 is on that JAVA_HOME. this error will occur. To resolve this set JAVA_HOME as JDK 6 in enviroment variables setting dialog or set JAVA_HOME in command prompt before running maven build. Second one temporary solution once the command window closed, JAVA_HOME reset back to default in system settings.

XML validation using XMLbeans

XML file validation is somewhat painful job. If we have XML Schema(XSD) that can be done very easily using Apache XmlBean. Also traversing or parsing XML will be joyful with XmlBean. First we have to generate Java class for XSD using XmlBean's scomp command, this can be done in command line. there are some options to generate source only or only Jar file. After having Xmlbean objects for XSD, parsing and validating can be done like below: void validate(String fileName) {          XmlDocument xmlObject = XmlDocument.Factory.parse(new File(fileName)); // parse the XML file         ArrayList validationErrors = new ArrayList ();           XmlOptions validationOptions = new XmlOptions();          validationOptions.setErrorListener(validationErrors);          boolean isValid = xmlObject.validate(validationOptions);  // to display error we should pass options.         if (!isValid) {             for (XmlValidationError es : validationErrors) {    

Blob type in Hibernate

In some scenarios we would have store large data into database like image or file. For large date Blob type is best one. If you use Hibernate as your ORM framework, there is a small trick to store Blob object into Database. @Column(name="ImageData") @Lob() byte[] imageData; Just add @Lob() annotation for variable or table column in Entity class, rest handling the Blob type will be taken care by Hibernate.