Wednesday, August 7, 2013

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value - iBatis

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value - iBatis

Sometimes we will be receiving the following exception when executing the iBatis queries.

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.tr.spm.app.persistence.mybatis.clientmgmt.ClientManagmentMapper.getTntGrpid
        at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:178)
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.tr.spm.app.persistence.mybatis.clientmgmt.ClientManagmentMapper.getTnt
        at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:775)

The issue is due to server could not able to locate the mapper xml file.

Approaches to fix the issue

This might be due to multiple reason, the following are the some of the ways the issue can be fixed.

1. Make sure the mapper xml file is in the same location as the mapper interface



2. Make sure the mapper interface java class name and the mapper xml file is same.

3. When u are using maven make sure the xml files are getting copied when packaging. Make sure we have added the below resource entry under resources section in pom.xml

         <resource>
                <directory>src/main/java</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.xml</include>
                </includes>
          </resource>



Monday, August 5, 2013

Changing the Default Maven Repository Location in Eclipse

Changing the Default Maven Repository Location in Eclipse

Sometimes we may need to change the default repository location of the maven in eclipse, the following steps will help us to do the same.

Steps to change the default repository location of the maven in eclipse

Change the repository path(location of the local repository path) in $MAVEN_HOME\conf\settings.xml file


Change the Settings.xml location in eclipse preferences

Browse the settings.xml file automatically the repository path will be displayed,Click on Apply then Click on Ok.





Setting up the Data Source in TOMCAT with Oracle Universal Connection Pool

Setting up the Data Source in TOMCAT with Oracle Universal Connection Pool :

Download ojdbc6_g.jar and ucp.jar and copy the same to $TOMCAT_HOME/lib folder.

Add the Data Source setup in $TOMCAT_HOME/conf/server.xml as follows under 

<GlobalNamingResources> tag.

  <GlobalNamingResources>

  <Resource
       name="jdbc/SampleConnectionPool"
       auth="Container"
       factory="oracle.ucp.jdbc.PoolDataSourceImpl"
       type="oracle.ucp.jdbc.PoolDataSource"
       description="Pas testing UCP Pool in Tomcat"
       connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource"
       minPoolSize="2"
       maxPoolSize="5"
       inactiveConnectionTimeout="20"
       user="Sample"
       password="Sample"
       url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
            (HOST=localhost)(PORT=1522))(CONNECT_DATA=
            (SERVICE_NAME=SAMPLE)))"
       connectionPoolName="SampleConnectionPool"
       validateConnectionOnBorrow="true"
       sqlForValidateConnection="select 1 from DUAL" />


</GlobalNamingResources>


Change the database details accordingly.

Add Resource Link for the global JNDI resource in $TOMCAT_HOME/conf/context.xml file under <Context>.

<ResourceLink global="jdbc/SampleConnectionPool" name="jdbc/SampleConnectionPool" type="oracle.jdbc.pool.OracleDataSource"/>

Now jdbc/SampleConnectionPool can be used in the code to get the database connection.


Setting up HTTPD Server in Oracle Linux

Setting up HTTPD Server in Oracle Linux:


Pre-Requisite:

Down load tomcat-connectors-1.2.37-src.tar.gz(or latest version) and copy the file to the server

Steps to setup HTTPD Server

Login as root user(or create user for httpd an provide all the access required to install httpd) to server and execute the following commands

                             yum install httpd httpd-devel gcc gcc-c++
                             yum install make
                             yum install glibc-devel.x86_64 --disablerepo=adobe\*

CD to the folder where tomcat-connectors-1.2.37-src.tar.gz file is copied and execute the following commands
                             gunzip < tomcat-connectors-1.2.37-src.tar.gz | tar xvf –

cd /<<Base Dir >>/tomcat-connectors-1.2.37-src/native and execute the following commands

                          ./configure --with-apxs=/usr/sbin/apxs --enable-api-compatibility
                          make
                          make install

The httpd server is successfully setup now.

Start/Stop the httpd instance:

Login as root user(or the user that used to install httpd server) to server and execute
                         /etc/init.d/httpd start
                        /etc/init.d/httpd stop

The server can be accessed through http://<<Server IP>>/



Sunday, August 4, 2013

Populating DOJO dropdown list based on JSON Data

Populating DOJO dropdown list based on JSON Data:

<select data-dojo-type=dijit.form.Select data-dojo-props='name:"dcDistcode"' missingMessage="Enter the Distict code" style="width: 180px" id="dcDistcode"></select>

var data ={"identifier":"value","items":[],"label":"distcode"};
            var len = newContent.length;   
            data.items.push(dojo.mixin({"distcode": "--SELECT--"},{"value": ""}));           
               
            for(var i=0; i < len ; ++i){       
                data.items.push(dojo.mixin({"distcode": newContent[i].dcDistcode+' - '+newContent[i].dcDistname},{"value": newContent[i].dcDistcode}));           
            }
             var distStore = dojo.data.ItemFileReadStore({data: data});
             dijit.byId("dcDistcode").setStore(distStore);


identifier specifies the value for the drop down list,  label specifies the display label for the drop down list.

newContent is the JSON data received from the server.