Home Navigation

Saturday, 31 March 2018

ObjectClosedException: DSRA9110E: ResultSet is closed

When you use WebSphere Application Server with an IBM DB2 database, this exception could occur:
Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null
To avoid such exceptions, you must add custom properties in WebSphere Application Server at the Application Center data source level.
Procedure

  • Log in to the WebSphere Application Server administration console.
  • Select Resources > JDBC > Data sources > Application Center DataSource name > Custom properties and click New.
  • In the Name field, enter allowNextOnExhaustedResultSet.
  • In the Value field, type 1.
  • Change the type to java.lang.Integer.
  • Click OK.
  • Click New.
  • In the Name field, enter resultSetHoldability.
  • In the Value field, type 1.
  • Change the type to java.lang.Integer.
  • Click OK and save your changes.
The possible values of resultSetHoldability are:
1 (HOLD_CURSORS_OVER_COMMIT),
2 (CLOSE_CURSORS_AT_COMMIT).

Tuesday, 2 January 2018

Debugging maven project, breakpoints don't work

By default, Maven runs your tests in a separate ("forked") process. You can use the maven.surefire.debug property to debug your forked tests remotely, like this:

mvn -Dmaven.surefire.debug test

For more information
http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html


In eclipse got to
Right click on the project -> Run As - > maven build ... -> build configuration

type "-Dmaven.surefire.debug test" in goal section

and add parameter forkCount = 0

Apply and hit debug

Sunday, 3 December 2017

Maven: How to create multiple jars from a single maven project ( maven-jar-plugin)

Two produce multiple jars from a single module project you may use maven-jar-plugin. It is pretty simple to use. In prepare-package phase under configuration you can put your configuration.

below a sample xml file.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>build-business-jar</id>
<phase>prepare-package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive>
<manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
</archive>
<includes>
<include>com/**/*</include>
<include>**/*.xml</include>
</includes>
<excludes>
<exclude>com/exclude4/**/*</exclude>
</excludes>
<finalName>jarfilename2</finalName>
</configuration>
</execution>
<execution>
<id>build-webservices-jar</id>
<goals>
<goal>jar</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<includes>
<include>com/walmart/**/*</include>
<include>**/*.xml</include>
</includes>
<excludes>
<exclude>com/exclude1/**/*</exclude>
<exclude>com/exclude2/**/*</exclude>
<exclude>com/exclude3/**/*</exclude>
</excludes>
<finalName>jarfilename2</finalName>
</configuration>
</execution>
</executions>

</plugin>

Eclipse editor won't open, Error: Plug-in org.eclipse.ui.editors was unable to load class org.eclipse.ui.editors.text.TextEditor

You might face this problem at the time of editing a jsp, xml or even a text to edit. You will be shown an error page Error: Plug-in org.eclipse.ui.editors was unable to load class org.eclipse.ui.editors.text.TextEditor

To resolve this issue you may try one of the option below.

- YOUR_WORKSPACE/.metadata/.plugins/org.eclipse.jdt.core/ There are a lot of index files, remove all of the index files
- Start eclipse with -clean option

Wednesday, 29 November 2017

Maven ant run plugin to execute ant command from maven

The example here for scp (secured copy) using ant in maven. One of the tip for this example you declare your dependency inside the plugin tag.



<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>1.8</version>
<executions>
   <execution>
<id>get-ear-from-nexus</id>
<phase>validate|clean|package|</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<scp file="file_name"
todir=" "
verbose="true" password=" " trust="true"
/>
</target>
</configuration>

</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
</plugin>

How to add multiple source file for a maven project

You might sometimes encounter a problem working with multiple source directory for a maven project. we are used to work with single source directory eg: src. what if you have src1, src2. src3 ..

Tor resolve this issue you can use maven helper build plugin.

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>build-helper-maven-plugin</artifactId>
   <version>1.9.1</version>
   <executions>
   <execution>
   <id>add-source</id>
   <phase>generate-sources</phase>
   <goals>
<goal>add-source</goal>
   </goals>
   <configuration>
   <sources>
   <source>
${basedir}/src1
   </source>
   <source>
${basedir}/src2
   </source>
   </sources>
   </configuration>
   </execution>
   </executions>
</plugin>

BDD feature/scenario execution via command line

Run all scenarios
      mvn clean test

Run specific feature file
     mvn clean test -Dcucumber.options="src/test/resources/feature/_file_name.feature"

Run specific scenario within feature file
    mvn clean test -Dcucumber.options="src/test/resources/feature/_file_name.feature:7"
    :7 - line# of the desired scenarios

Run specific scenarios within feature file
     mvn clean test -Dcucumber.options="src/test/resources/feature/_file_name.feature:7:20"

Run scenario by tag
     mvn clean test -Dcucumber.options="--tags @test"

Exclude specific tags from execution
    mvn clean test -Dcucumber.options="--tags @reports, -@tags ~@smoke"


Available environment to execute against – Dev, Test
   mvn clean test –Dcucumber.options=”--tags @test” –P test
   mvn clean test –Dcucumber.options=”--tags @test” –P dev