Tuesday, October 20, 2015

No configuration found for the specified action: ... action defaulting message in Sturts application


In struts we use to get the message

No configuration found for the specified action: 'fnTest()' in namespace '/'...

We use to see this message in the logs whenever we navigate from one screen to another.

The primary reason for this issue was the use of <s:form tag action attribute to call a javascript function.

One solution was to use the onSubmit attribute in the <s:form tag to call the javascript function


<s:form   method="post" onsubmit="return fnTest();"  name="searchTestScreen" id="searchTestScreen">

Tuesday, October 13, 2015

Resolve DBCP database connection failure when connecting to RAC oracle database server


How to resolve the database connection issue when connecting to oracle RAC cluster servers.

Our application used DBCP (Apache Common) jar with the spring - hibernate framework to establish connection pool.

When we connected to RAC server we got the below exception.

database connection check SQL Exception : Io exception: Connection refused(DESCRIPTION=(ERR=1153)(VSNNUM=0)(ERROR_STACK=(ERROR=(CODE=1153)(EMFI=4)(ARGS='(DESCRIPTION=(address=(protocol=tcp)(host=somehost.web.com)(port=1111))(CONNECT_DATA=(CID=(PROGRAM=)(HOST=__jdbc__)(USER=))null))'))(ERROR=(CODE=303)(EMFI=1))))

After analyzing i noticed that i was using classes12.jar, which needs to be upgraded to a new version of ojdbc7.jar.

Resolution upgrade to newer version of ojdbc7.jar.


Also the RAC connection was to be made using the Service name not the SID which is a standard for this RAC cluster architecture.

Hint one the url string is 

jdbc:oracle:thin:@//somehost.web.com:portnumber/service name.

There are other ways to declare the url string which is similar to the tnsora oracle client string.

Sample standalone code for testing:

import java.sql.Connection;
import org.apache.commons.dbcp.BasicDataSource;
public class DBConnectTest {
public static void main(String args[]){
String driver = "oracle.jdbc.driver.OracleDriver";
String url ="jdbc:oracle:thin:@//somehost.web.com:portnumber/servicename";
String username = "username";
String password ="password";

 try{
   org.apache.commons.dbcp.BasicDataSource dataSource = new BasicDataSource();
   dataSource.setDriverClassName(driver);
   dataSource.setUrl(url);
   dataSource.setUsername(username);
   dataSource.setPassword(password);
   Connection basicDataSourceCon = dataSource.getConnection();
   System.out.println("\n basicDataSourceCon ::"+basicDataSourceCon);
   System.out.println("Connected to oracle DB");
    }catch(Exception e){
   System.out.println("DB Connection Exception");
   e.printStackTrace(); }
}
}

we need the following jars.
commons-dbcp-1.2.2.jar (any new version x.x.x)
commons-logging-1.1.1.jar (any new version x.x.x)
commons-pool-1.4.jar (any new version x.x)


Refer the below link too.
https://community.oracle.com/thread/358849?start=0&tstart=0

Friday, July 31, 2015

Jenkins + git continuous integration set up with local git repository and ant for an existing project.


Part 1:
1. Download the war from the below location for jenkins. (http://jenkins-ci.org/)
2. place the jenkins war in the tomcat webapps location
3. start the tomcat startup script.
4. once tomcat is up. click the url in the browser http://localhost:8080/jenkins.
5. The jenkins page will be displayed.


Part 2:  configuring the jenkins for job.
1. click manage jenkins link in the left.
   I got two messages displayed in the screen, one was related to UTF-8, to fix this i have change the    server.xml of tomcat to include the URIEncoding="UTF-8" in the <connector tag>
 <Connector connectionTimeout="20000" port="8082" URIEncoding="UTF-8"     protocol="HTTP/1.1" redirectPort="8444"/>

2. Configure system.
     jdk - java installation
      i. click the jdk, remove the default installation and set the java home path where the java is installed.
    ANT - installation
      ii. click the Ant, and select a name and provide the path of the ant home here.

3. Since we are going integrate with the Git we need to install the plugin.
     We need internet access to do it.
      If we don't have internet access we can use the to download the .hpi file.
      we need :
                 1. git-client.hpi
                 2. git.hpi and
                 3. scm-api.hpi

The plugins can be downloaded at "https://updates.jenkins-ci.org/download/plugins/"

To install the plugin, click Manage Plugins > Advanced tab > under the Upload Plugin section just upload the downloaded hpi's.


Note git.hpi has dependencies with the scm-api.hpi. if git.hpi is installed first we will display the below message.
  ava.io.IOException: Failed to dynamically deploy this plugin
 at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1328)
 at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1126)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
 at java.util.concurrent.FutureTask.run(FutureTask.java:262)
 at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:110)
 at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Failed to install git plugin
 at hudson.PluginManager.dynamicLoad(PluginManager.java:474)
 at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1324)
 ... 5 more
Caused by: java.io.IOException: Dependency scm-api (0.2) doesn't exist
 at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:480)
 at hudson.PluginManager.dynamicLoad(PluginManager.java:464)
 ... 6 more

To Set up a new Job for continuous integration we should flow the blow steps:

Once the git plugin is installed in the local system.

Click the New Item to set up the project.
give an item name and select freestyle project for all kind of project.


provide the project name
description
select the source code management version as git
    we need to set the repository.
    download the git (not the git hub),
                            > create a local repository using the git init command in git bash
                            > add the necessary folders / projects to the git master branch.
                            > in my case i used /C/user/thiru/projects/project1/code was the master branch.
                            > in the repository url, use this link (not this differs where your project is set.
                            > use the git add command to add the git folder or file
                            > use git commit -a -m "test to describe about commit" to commit the project.
                           > there should a be build.xml file. for the project.

Now we need to configure the ANT to deploy the war.
                select either the default or the installed ANT form the configured system.
                type in the target in the build.xml
                if the build.xml file is present within the project directory then select advanced and i the build file input field provide ./projectfoldername/build.xml
                                     - this will be helpful for old project which has built that way.


Once the above configurations are done, click Save.
In case of any error in the configuration we get error message upfront on clicking save.

If every thing works fine.
click the Build now, and  you could see the build history.

if there is any build error a Red color icon will be displayed clicking it will display the error details, user details.
Console output in left side menu bar, will display the step by step instruction involved in generating the war or jar. which can be used for debugging.

This is just a initial step, where we didn't use any remote repository or Linus/Unix machine.

The war will be deployed in the directory mentioned in the ant file. But in case of jenkins, the war file will be in C:/user/<username>/.jenkins/job/<project name set in jenkins>/workspace/project_name/... war location.

Next step for improvement, will be moving the war to designated location.

below are few snapshots of build history.



Executing a Windows batch command after build:
Below are the ways to use Window batch script after build is compete in jenkins. use the Build trigger section, with batch command. refer the snapshot below.



Setting up the auto deploy:

Below snap shot also has the post-build Actions section which can be used to auto deploy the war in the tomcat.

If the Add post-build action didn't have the "Deploy war/ear to a container", then we need to install the deploy.hgi plugin.

1. Ensure appropriate permissions are available in $CATALINA_HOME\conf\tomcat-user.xml
       <role rolename="manager-gui"/>
       <role rolename="admin"/>
       <role rolename="manger-script"/>
       <role rolename="manger"/>
       <user password="password" roles="manager-gui,manager" username="tomcat"/>

if there is any permission issue, the console output during build will provide the error details.



In our web application project we are not using Maven to resolve the jar dependencies.
We use to download the referenced jar and use.

I wanted to check if there is unused jars and the list of dependent and non-dependent jars.

I came across the tattletale.jar open source from JBOSS community, which provides a report on the dependencies analyzing the jars.
Link:   http://tattletale.jboss.org/

This can be configured in jenkins using the tattletale.hgi plugin, which can be downloaded from https://wiki.jenkins-ci.org/display/JENKINS/Tattletale+Plugin

1. Install the plugin in jenkins.
2. Configure the tattletale.jar and javassist.jar, which comes with the downloads of the tattletale.zip.
3. Under, Mange Jenkins -> Configure System -> Tattletale plugin section

4. Job level - project specification configure -> Invoke Tattletale, section to configure as shown below.

5. in the After post-build section enable the invoke tattletale option and provide the directory where the reports are generated.
Note when executing the tattletale.jar -jar <input directory> <output directory> will create the reports in the output directory. we will refer that output directory here.

we will be seeing the Tattletale plugin, which will give us the report.
refer the link: https://wiki.jenkins-ci.org/display/JENKINS/Tattletale+Plugin for more information.