Thursday, June 12, 2014

Generating JAXB artifacts from XSD/WSDL through Maven

Generating JAXB artifacts from XSD/WSDL through Maven

The maven-jaxb2-plugin can be used to generate the java classes from both XSD/WSDL.

Plugin configuration in Pom.xml

The below plug in configuration can be used in the pom.xml file to generate the sources.
<plugin>
  <groupId>org.jvnet.jaxb2.maven2</groupId>
  <artifactId>maven-jaxb2-plugin</artifactId>
  <version>0.7.3</version>
  <executions>
    <execution>
      <id>app1-stub-generation</id>
      <goals>
        <goal>generate</goal>
      </goals>
      <configuration>
        <schemaDirectory>src/main/resources</schemaDirectory>
        <schemaIncludes>
          <include>*.xsd</include>
        </schemaIncludes>
        <generatePackage>com.thomson.ecom.service.bean.demo</generatePackage>
        <clearOutputDir>false</clearOutputDir>
        <generateDirectory>src/main/java</generateDirectory>
        <strict>true</strict>
      </configuration>
    </execution>
 
 
  </executions>
</plugin>

Change the include accordingly to generate for wsdl -   <include>*.wsdl</include>

Generate the sources

To generate the sources, Right click on pom.xml-->Run As-->Maven generate-sources


This will generate all the java classes to src/main/java


Wednesday, June 11, 2014

Configuring JAXB2-Maven-Plugin not to clear the outputdirectory

Configuring JAXB2-Maven-Plugin not to clear the outputdirectory

JAXB2-Maven-Plugin will help us to generate the java classes from the xsd.
By default the plugin clears the existing contents in the ouputdirectory and generate the new java classes into the outputdirectory.

Some cases we may need to generate the java classes from multiple source xsd's so we have to configure the plugin not to clear the outputdirectory.

Yo have to add <clearOutputDir>false</clearOutputDir> in the plugin configuration.

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <!-- The schema directory or xsd files. -->
                <schemaDirectory>${basedir}/src/main/resources</schemaDirectory>
                <!-- The package in which the source files will be generated. -->
                <packageName>com.service.bean.demo</packageName>
                 <clearOutputDir>false</clearOutputDir>
                <!-- The working directory to create the generated java source files. -->
                <outputDirectory>${basedir}/src/main/java</outputDirectory>
            </configuration>
        </plugin>


Tuesday, June 10, 2014

Changing the default Maven repository location in eclipse

Changing the default Maven repository location in eclipse

Sometimes we may required to modify the default maven repository location to custom location for the eclipse project.
Eclipse project will have the variable M2_REPO defined as read only.


The following steps will help as to change the default Mavan repository location.

Modify the settings.xml file in the <<USER_HOME>>/.m2 and add the localRepository value accordingly.



If the .m2 folder ia not available in the USER_HOME create the same(md .m2) and also create a settings.xml file and update the file with the following contents(change the value of localrepository and the repository url accordingly)



Wednesday, August 7, 2013

Configuring the subeclipse plugin in eclipse

Configuring the subeclipse plugin in eclipse:

Subversion is a version control system, similar to CVS. Subclipse is an Eclipse plug-in that provides the functionality to interact with a Subversion server, and to manipulate a project on a Subversion server in the Eclipse environment.

 Click on Help--> Eclipse Marketplace in eclipse editor.

Search for subeclipse in the window





Click on Install and Click Next


Accept license and click on Finish



Tuesday, October 30, 2012

The server does not support version 3.0 of the J2EE Web module specification - Eclipse

The server does not support version 3.0 of the J2EE Web module specification -  Eclipse

Sometimes we used to receive the following exception when running the web application in latest eclipse version.

The server does not support version 3.0 of the J2EE Web module specification.

The issue is when creating the web project in latest eclipse by default the web version  will be selected as 3.0 but the server what we are having is not supporting the web 3.0.

There is two options to fix this issue.

1. Upgrade your server to latest version
2.Open org.eclipse.wst.common.project.facet.core.xml file from /workspace/<Your project name>/.settings and change jst.web version to 2.5 instead 3.0

<installed facet="jst.web" version="2.5"/>