Tuesday, July 8, 2014

Caused by: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

Exception :- 
Caused by: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource


First ensure that you have included commons-collections and  commons-dbcp jar in classpath. Click here to download
commons-collections and  commons-dbcp jar

If you are using maven then add following dependency in pom.xml 

<dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.1</version>
</dependency>


<dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    <version>1.4</version>
</dependency>


org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource

Exception :-
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/demo-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReade

First ensure that you have included aopalliance jar in classpath. Click here to download aopalliance-1.0.jar 

If you are using maven then add following dependency in pom.xml
 
<dependency>
    <groupId>aopalliance</groupId>
    <artifactId>aopalliance</artifactId>
    <version>1.0</version>
</dependency>

Friday, July 4, 2014

java.lang.ClassNotFoundException: javassist.util.proxy.MethodFilter

Exception :- 
Caused by: java.lang.ClassNotFoundException: javassist.util.proxy.MethodFilter 
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer] 
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister 


First ensure that you have included javassist jar in classpath. Click here to download javassist jar 

If you are using maven then add following dependency in pom.xml
<dependency>
    <groupId>javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.12.1.GA</version>
</dependency>

 

Thursday, July 3, 2014

java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/Log

Please ensure that you have included standred.jar in classpath. Click here to download  standred.jar - See more at: http://makecodeeasy.blogspot.in/2014/07/javautilconcurrentexecutionexception.html#sthash.0Um7PGLr.dpuf
Exception :- java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/Log

First ensure that you have included commons-logging-xxx.jar in classpath.
Click here to download 
commons-logging-xxx.jar

If you are using maven then add following dependency in pom.xml
<dependency> 
    <groupId>commons-logging</groupId> 
    <artifactId>commons-logging</artifactId> 
    <version>1.1.1</version> 
</dependency>
The Commons Logging provides a Log interface that is intended to be both light-weight and an independent abstraction of other logging toolkits. It provides the middleware/tooling developer with a simple logging abstraction, that allows the user (application developer) to plug in a specific logging implementation.

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]

Exception :- java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]

Please ensure that you have included standred.jar in classpath.
Click here to download  standred.jar

If you are using maven then add following dependency in pom.xml
 <dependency>  
   <groupId>taglibs</groupId>  
   <artifactId>standard</artifactId>  
   <version>1.1.2</version>  
 </dependency>  

standard.jar (taglib) library is used to enable the JSTL expression language in JSP page, and it’s always used together with the jstl.jar together.
 
 <dependency> 
    <groupId>taglibs</groupId> 
    <artifactId>standard</artifactId> 
    <version>1.1.2</version> 
</dependency> 

Saturday, June 28, 2014

Drag and Drop using jQuery JavaScript in HTML

Using jQuery you can create simple Drag & Drop features easily and manage them well. jQuery UI provides with a vast suite of APIs that can create a UI with Drag Drop functionality.
Steps :-

1. Create a HTML file which includes css, jquery & javascript libraries .

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Drag and drop</title>

<LINK REL=StyleSheet HREF="css/makecodeeasy.css" TYPE="text/css">
<link rel="stylesheet"
    href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

</head>
<body>

    <div>
        <fieldset id="shop" class="draggableContainer">
            <legend>Draggable component</legend>
            <img class="component" id="1" src="image/1.jpg"> 
            <img class="component" id="2" src="image/2.jpg"> 
            <img class="component" id="3" src="image/3.jpg"> 
            <img class="component" id="4" src="image/4.jpg">
        </fieldset>
    </div>

    <div>
        <fieldset>
            <legend>dropZone</legend>
            <div class="dropZone" id="dropZone"></div>
        </fieldset>
    </div>

    <script src="js/makecodeeasy.js"></script>

</body>
</html>

2. Create Javascript file (makecodeeasy.js)
var dropArea = document.querySelector('#dropZone');

var conponents = document.querySelectorAll('.component');
for ( var i = 0; i < conponents.length; i++) {
    conponents[i].setAttribute('draggable', 'true');
    conponents[i].addEventListener('dragstart', function(evnt) {
        evnt.dataTransfer.effectAllowed = 'copy';
        evnt.dataTransfer.setData('text', this.id);
        return false;
    }, false);
}

dropArea.addEventListener('dragover', function(evnt) {
    if (evnt.preventDefault)
        evnt.preventDefault();
    evnt.dataTransfer.dropEffect = 'copy';
    return false;
}, false);


dropArea.addEventListener('drop', function(evnt) {
    if (evnt.stopPropagation)
        evnt.stopPropagation();
    var id = evnt.dataTransfer.getData('text');
    var theitem = document.getElementById(id);

    if (theitem == null) {
        evnt.preventDefault();
        return;
    }
    var y = document.createElement('img');
    y.src = theitem.src;
    dropArea.appendChild(y);
    evnt.preventDefault(); // for Firefox
    return false;
}, false);

3. Create css file (makecodeeasy.css) 
body {
    padding: 40px;
}

.draggableContainer {
    border-radius: 6px;
}


.component {
    border: 3px solid white;
}

.component:hover {
    border: 3px solid red;
    cursor: move;
}

#dropArea {
    position: relative;
    height: 200px;
    width: 100%;
    float: left;
    border: 1px dotted #999;
}


.dropZone {
    width:100%;
    height:100px
}

4.  Demo  

Draggable component
dropZone
5.  Try the code & Enjoy :) 
     jsfiddle link :- http://jsfiddle.net/zBhD7/

Saturday, October 5, 2013

Amazing Light - Beautiful piece of art


Brick laying machine


Tiger-Stone, the amazing machine can create an instant road wherever it travels, laying out bricks in formation to create perfect paving. Its secret lies in a smartly designed gravity-based system.


Virtual wall concept to protect pedestrians



Pedestrian/motor vehicle crashes are a serious problem throughout the world and the India has a particular problem with pedestrian deaths and injuries.
Almost two-thirds of the 1.2 million people killed annually in road traffic crashes worldwide are pedestrians.


The sequence of events in a car-pedestrian accident

Traffic accidents are among the major causes of death in India. Every year increased the pedestrian accidents at pedestrian crossing zone. And I thought that crossing zone is sharing space between pedestrian and driver. But drivers are never care which pedestrian’ safety in the real world. Even drivers are sometimes switching to pedestrian. And nowadays, urban sites got the problem that disturbance of traffic signal. We are surrounded such a crazy commercials and crowd environment near the road space.


That’s a one of reason that many drivers losing attention and difficulty of awareness into traffic signal. And, I’d like to make wall up on the car’ stop line at the moment. Virtual Wall, It’s really effective in driver awareness. Because Virtual Wall can get bigger image and better look.


the inventor of this concept is  Hanyoung  Lee, got  awarded for this  creation work. this can be implemented in all zones for a better safety of pedestrians the concept work like this : at the junctions some two poles are fixed and when the pedestrians crossing the road these poles produces some rays which are visible to naked eye looks like a wall infront of them so this will gives more safety for the pedestrians.

Saturday, June 1, 2013

Two Datasource in Spring/Hiberate

We can create two datasource in a single spring/hibernate application.

There are following steps required to implement this:-

Create JNDI Datasource while using Tomcat :- 
  1. Resource entry in server.xml under <GlobalNamingResources> for both datasources
    You can find server.xml in following path in Tomcat folder :-
     c://Tomcat/conf/server.xml
  2. <globalnamingresources>
        <resource name="jdbc/first"  driverclassname="com.microsoft.sqlserver.jdbc.SQLServerDriver" maxwait="5000" password="makecodeeasy" type="javax.sql.DataSource" url="jdbc:sqlserver://localhost:1433;DatabaseName=DataTest" username="makecodeeasy" validationquery="select 1">
        </resource>
    
     <resource name="jdbc/second"  driverclassname="com.microsoft.sqlserver.jdbc.SQLServerDriver" maxwait="5000" password="123" type="javax.sql.DataSource" url="jdbc:sqlserver://192.182.21.66:1433;DatabaseName=Second" username="sa" validationquery="select 1">
        </resource>
     </globalnamingresources>
    
    Note :- Database used here in MS Sql server 2008. You can use any database. You need to change driverClassname, url, username and password according to  database.
  3. Do the entry in web.xml for both resources
    You can find web.xml in WEB-INF folder of your application
  4. <resource-ref>
      <description>DB Connection Pooling</description> 
      <res-ref-name>java:comp/env/jdbc/first</res-ref-name> 
      <res-type>javax.sql.DataSource</res-type> 
      <res-auth>Container</res-auth> 
      <res-sharing-scope>Shareable</res-sharing-scope> 
    </resource-ref>
    
    
    <resource-ref>
      <description>DB Connection Pooling</description> 
      <res-ref-name>java:comp/env/jdbc/second</res-ref-name> 
      <res-type>javax.sql.DataSource</res-type> 
      <res-auth>Container</res-auth> 
      <res-sharing-scope>Shareable</res-sharing-scope> 
    </resource-ref>
    
  5. Use datasource in applicationContext or spring context file
  6. <bean id="firstDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="java:comp/env/jdbc/first" /> 
      <property name="resourceRef" value="true" /> 
    </bean>
    <bean id="secondDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="java:comp/env/jdbc/second" /> 
      <property name="resourceRef" value="true" /> 
    </bean> 
  7. Create two session factory for using two datasource.
    <bean id="firstSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" p:dataSource-ref="firstDataSource" p:configLocation="${hib.config}" p:packagesToScan="com.org.xyz.domain">
    </bean>
    <bean id="secondSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" p:dataSource-ref="secondDataSource" p:configLocation="${hib.config}" p:packagesToScan="com.org.abc.domain">
    </bean>

  8. Now these session factories can be used in Hibernate application.

Sunday, May 19, 2013

JNDI Datasource in spring

There are two sources of database connections - either a  DataSource or a  DriverManager.

JNDI
The Java Naming and Directory Interface (JNDI) is part of the Java platform, providing applications based on Java technology with a unified interface to multiple naming and directory services. You can build powerful and portable directory-enabled applications using this industry standard.

Create JNDI Datasource while using Tomcat :- 
  1. Resource entry in server.xml under <GlobalNamingResources>
    You can find server.xml in following path in Tomcat folder :-
     c://Tomcat/conf/server.xml
  2. <globalnamingresources>
        <resource name="jdbc/test"  driverclassname="com.microsoft.sqlserver.jdbc.SQLServerDriver" maxwait="5000" password="makecodeeasy" type="javax.sql.DataSource" url="jdbc:sqlserver://localhost:1433;DatabaseName=DataTest" username="makecodeeasy" validationquery="select 1">
        </resource>
    </globalnamingresources>
    Note :- Database used here in MS Sql server 2008. You can use any database. You need to change driverClassname, url, username and password according to  database.
  3. Do the entry in web.xml
    You can find web.xml in WEB-INF folder of your application
  4. <resource-ref>
      <description>DB Connection Pooling</description> 
      <res-ref-name>java:comp/env/jdbc/test</res-ref-name> 
      <res-type>javax.sql.DataSource</res-type> 
      <res-auth>Container</res-auth> 
      <res-sharing-scope>Shareable</res-sharing-scope> 
    </resource-ref>
    
  5. Use datasource in applicationContext or spring context file
  6. <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="java:comp/env/jdbc/test" /> 
      <property name="resourceRef" value="true" /> 
    </bean>
    
  7. Your Datasource is ready to use. It can also be used in hibernate.

Saturday, May 18, 2013

Browser CSS Hacks


CSS Hacks

/***** Selector Hacks ******/

/* IE6 and below */
* html #mydiv  { color: red }

/* IE7 */
*:first-child+html #dos { color: red }

/* IE7, FF, Saf, Opera  */
html>body # mydiv  { color: red }

/* IE8, FF, Saf, Opera (Everything but IE 6,7) */
html>/**/body # mydiv  { color: red }

/* Opera 9.27 and below, safari 2 */
html:first-child # mydiv  { color: red }

/* Safari 2-3 */
html[xmlns*=""] body:last-child #seis { color: red }

/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:nth-of-type(1) #mydiv  { color: red }

/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:first-of-type #mydiv  {  color: red }

/* saf3+, chrome1+ */

@media screen and (-webkit-min-device-pixel-ratio:0) {

 #mydiv  { color: red  }
}

/* iPhone / mobile webkit */
@media screen and (max-device-width: 480px) {
 #mydiv  { color: red  }
}


/* Safari 2 - 3.1 */
html[xmlns*=""]:root #mydiv  { color: red  }

/* Safari 2 - 3.1, Opera 9.25 */
*|html[xmlns*=""] #mydiv  { color: red  }

/* Everything but IE6-8 */
:root *> #mydiv  { color: red  }

/* IE7 */
*+html #mydiv  {  color: red }

/* Firefox only. 1+ */
#mydiv ,  x:-moz-any-link  { color: red }

/* Firefox 3.0+ */
#mydiv ,  x:-moz-any-link, x:default  { color: red  }

/* FF 3.5+ */
body:not(:-moz-handler-blocked) #mydiv { color: red; }


/***** Attribute Hacks ******/

/* IE6 */
#mydiv { _color: blue }

/* IE6, IE7 */
#mydiv { *color: blue; /* or #color: blue */ }

/* Everything but IE6 */
#mydiv { color/**/: blue }

/* IE6, IE7, IE8 */
#mydiv { color: blue\9; }

/* IE7, IE8 */
#mydiv { color/*\**/: blue\9; }

/* IE6, IE7 -- acts as an !important */
#mydiv { color: blue !ie; } /* string after ! can be anything */

/* IE8, IE9 */
#mydiv  {color: blue\0/;} /* must go at the END of all rules */


Some More Hacks :-

#mydiv {
    width:89px; (common for all)
    margin-left/*\**/:90px\9; ( For IE8)
    margin-top/*\**/:-31px\9;
}

#
mydiv  {
    width:89px;
    margin-left/*\**/: 180px\9;
    margin-top/*\**/:-32px\9;
   
}
(only IE6)
* html #
mydiv  {
    margin-left:95px;
    margin-top:-33px;
}

*html #
mydiv  {
    margin-left:186px;
    margin-top:-30px;
}
(only IE7)
*:first-child+html #
mydiv  {
    margin-left:90px;
    margin-top:-30px;
}

*:first-child+html #
mydiv  {
    margin-left:180px;
    margin-top:-27px;
}

(SAFARI)
body:last-child:not(:root:root) #
mydiv  {
    margin-left:90px;
    margin-top:-31px;
}

body:last-child:not(:root:root) #
mydiv  {
    margin-left:180px;
    margin-top:-31px;
}

/* body:first-of-type #
mydiv  {
    margin-left:90px;
    margin-top:-31px;
}

body:first-of-type #
mydiv  {
    margin-left:180px;
    margin-top:-31px;
}
*/

/*::root #
mydiv  {
    margin-left:90px;
    margin-top:-31px;
}

::root #
mydiv  {
    margin-left:180px;
    margin-top:-31px;
}
*/

/* @media screen and (-webkit-min-device-pixel-ratio:0){
    #
mydiv  {
        margin-left:90px;
        margin-top:-31px;
    }
    #
mydiv  {
        margin-left:180px;
        margin-top:-31px;
    }

}
*/




ShareThis