How to share folders between Windows Host, and Linux Guest OS on VMWare (Workstation)?


First Way

  1. On Windows Host, Right Click > Properties > Share (with Everyone)
  2. On Linux Host: Applications > File Browser > File > Connect to Server > Service Type: Windows Share , Server:  Give-Desktop-IP > Connect.
  3. On being prompted enter windows username/group/password – Thats it, your shared folder will show up


Second Way

  • You could always run a Web-Server on your Windows Host, and access it from Linux Host (either browser or wget). Not exactly file sharing, but files can be downloaded from Windows Host to Linux this way (just in case nothing else is working for you!)


Third Way

  • With VMWare Tools – it should be possible too… have not got it to work yet.

Error Message: No suitable driver found for jdbc:mysql:.. in a maven jpa/hibernate/mysql project

Problem Statement

In your maven project, with appropriate dependencies for Hibernate/MySQL, you get the following error – when jpa-hibernate code is invoked:

WARN : org.hibernate.connection.DriverManagerConnectionProvider – no JDBC Driver class was specified by property hibernate.connection.driver_class
WARN : org.hibernate.cfg.SettingsFactory – Could not obtain connection to query metadata
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/somedb


The solution is in the warning itself. Note the line that says:  no JDBC Driver class was specified by property hibernate.connection.driver_class

In your persistence.xml file add the following line:
<property name=”hibernate.connection.driver_class” value=”com.mysql.jdbc.Driver” />

That’s It!

How to resolve: Maven Error: [ERROR] No plugin found for prefix ‘archetype’ in the current project…

Problem Statement

You get this error while doing  maven build:

[ERROR] No plugin found for prefix ‘archetype’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the
repositories [local (C:\Documents and Settings\<user>\.m2\repository), central (


Very likely, your proxy settings are the problem. If you are behind a firewall setup your proxy correctly.
Proxy settings are in settings.xml config file of maven. This file usually exists in two places:

  • <MAVEN_HOME>\conf
  • c:\documents and settings\<user>\.m2

Thats it!

Simple image (widget for) zoom, rotate?


Here is an example (only zoom, fit etc.. for rotate see iviewer website):

<!DOCTYPE html>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>jquery.iviewer test</title>
<script type=”text/javascript” src=”imgtest/jquery.js” ></script>
<script type=”text/javascript” src=”imgtest/jqueryui.js” ></script>
<script type=”text/javascript” src=”imgtest/jquery.ui.core.js” ></script>
<script type=”text/javascript” src=”imgtest/jquery.mousewheel.min.js” ></script>
<script type=”text/javascript” src=”imgtest/jquery.iviewer.js” ></script>
<script type=”text/javascript”>
var $ = jQuery;
var iv1 = $(“#viewer”).iviewer({
src: “test_image.jpg”,
update_on_resize: false,
zoom_animation: false,
mousewheel: false,
onMouseMove: function(ev, coords) { },
onStartDrag: function(ev, coords) { return false; }, //this image will not be dragged
onDrag: function(ev, coords) { }

$(“#in”).click(function(){ iv1.iviewer(‘zoom_by’, 1); });
$(“#out”).click(function(){ iv1.iviewer(‘zoom_by’, -1); });
$(“#fit”).click(function(){ iv1.iviewer(‘fit’); });
$(“#orig”).click(function(){ iv1.iviewer(‘set_zoom’, 100); });
$(“#update”).click(function(){ iv1.iviewer(‘update_container_info’); });

iv1.iviewer(‘loadImage’, “imgtest/test_image2.jpg”);
return false;
<link rel=”stylesheet” href=”imgtest/jquery.iviewer.css” />
width: 80%;
height: 800px;
border: 1px solid black;
position: relative;

overflow: hidden;
<h1>JQuery.iviewer test</h1>
<!– wrapper div is needed for opera because it shows scroll bars for reason –>
<div class=”wrapper”>
<a id=”in” href=”#”>+</a>
<a id=”out” href=”#”>-</a>
<a id=”fit” href=”#”>fit</a>
<a id=”orig” href=”#”>orig</a>
<a id=”update” href=”#”>update</a>
<a href=”#” id=”chimg”>Change Image</a>
<div id=”viewer” class=”viewer”></div>

How to create Collapsible (Sliding) Div using JQuery?

Here is an example:

<script type=”text/javascript” src=””></script&gt;

p.content-one {
p.content-two {


<div class=”sitesection” style=”border:1px solid black; width:900px; background-color:LightGrey”>
<a href=”#” class=”expand-one”>Expand</a>
<SELECT id=”u131″ class=”u131″>
<OPTION selected value=”1″>A</OPTION>
<OPTION value=”2″>B</OPTION>
<OPTION value=”3″>C</OPTION>
<OPTION value=”4″>D</OPTION>
<p class=”content-one”>
<img src=””/>&nbsp;&nbsp;
<img src=””/&gt;
<div class=”sitesection” style=”border:1px solid black; width:900px; background-color:LightGrey”>
<a href=”#” class=”expand-two”>Expand</a>
<SELECT id=”u131″ class=”u131″ data-label=”Loan Selector” >
<OPTION selected value=”11″>AA</OPTION>
<OPTION value=”22″>BB</OPTION>
<OPTION value=”33″>CC</OPTION>
<OPTION value=”44″>DD</OPTION>
<p class=”content-two”>
<img src=””/>&nbsp;&nbsp;
<img src=””/&gt;
<script type=”text/javascript”>

How to create a curved div/rectangle (with JQuery)?


Here is an example:

<META content=”text/html; charset=utf-8″ http-equiv=Content-Type>

<SCRIPT type=text/javascript src=”jslib/jquery-1.2.6.min.js”></SCRIPT>
<SCRIPT type=text/javascript src=”jslib/jquery.curvycorners.min.js”></SCRIPT>

<SCRIPT type=text/javascript>
tl: { radius: 10 },
tr: { radius: 10 },
bl: { radius: 10 },
br: { radius: 10 }});

<DIV style=”border: 1px solid”>
Inside a Curved Div…<br>

How to select an image area and find its coordinates or crop an image?

JCrop lets you do these:

  • URL (This is JQuery Plugin, and you can download and use it.)
  • You can select an area by dragging your mouse over the image and it will give out coordinates of the area (rectangle)
  • To actually crop (cut) an image, this can be done too here, but for that there is backend php which does this job.

This is also called Image Mapping.

How to highlight image area, on mouseover of the area, or from a (external) text link?

This can be done by using JQuery Map Highlight Plugin (jquery.maphilight.js).

Here’s the complete code:

<!DOCTYPE html>
<meta charset=”utf-8″>
<script type=”text/javascript” src=””></script&gt;
<script type=”text/javascript” src=”jquery.maphilight.js”></script>
<script type=”text/javascript”>$(function() {


<a id=”Area1Link” href=”#” onmouseover=”$(‘#area1′).trigger(‘mouseover’);” onmouseout=”$(‘#area1′).trigger(‘mouseout’);”>Area 1</a><br/>
<a id=”Area2Link” href=”#” onmouseover=”$(‘#area2′).trigger(‘mouseover’);” onmouseout=”$(‘#area2′).trigger(‘mouseout’);”>Area 2</a>
<td><img src=”demo_simple.png” width=”420″ height=”300″ class=”map” usemap=”#simple”></td>
<map name=”simple”>
<area id=”area2″ href=”#” shape=”poly” coords=”47,62,106,61,134,72,135,118,30,116″ alt=”Link” title=”Default behavior”>
<area href=”#” shape=”poly” coords=”32,157,133,157,127,192,127,211,28,211″ alt=”Link” data-maphilight=’{“strokeColor”:”0000ff”,”strokeWidth”:5,”fillColor”:”ff0000″,”fillOpacity”:0.6}’ title=”Metadata’d up a bit”>
<area id=”area1″ href=”#” shape=”circle” coords=”290,102,30″ alt=”Octoface” data-maphilight=’{“stroke”:false,”fillColor”:”ff0000″,”fillOpacity”:0.6}’ title=”Metadata’d up a bit”>
<area href=”#” shape=”poly” coords=”219,190,225,175,237,157,239,148,245,142,251,140,263,140,265,139,310,139,311,145,364,182,363,201,343,221,333,213,329,181,313,177,330,234,295,231,292,174,279,176,282,204,269,220,255,206,267,167,235,193″ alt=”Legs” data-maphilight=’{“stroke”:false,”fillColor”:”000000″,”fillOpacity”:1,”alwaysOn”:true}’ title=”Metadata’d up a bit”>


The JavaScript Library is available here:

The above code is a slight modification, of simple demo found here: 

You can find the coordinates to use in ‘area’ tag above by using a Image Mapper software.
For eg

The image used for the above example is:


How to configure JBoss datasource (Oracle/RAC/Re-Connect)?

<local-tx-datasource> vs <xa-datasource>

  • <local-tx-datasource> is used for a single JBoss App Server.
  • <xa-datasource> is used in a clustered JBoss App Server environment.
  • Note that both <local-tx-datasource> and <xa-datasource> handle distributed transactions involving multiple data source\

Preventing Stale Connections

For this you can add the following to the datasource (-ds.xml):

select 1 from dual

The above has performance implications:

  • The check-valid-connection-sql, wil be invoked everytime a Connection is borrowed from the Pool.
  • Therefore, this should not be used in heavy load scenarios.

Fail-Over with Oracle RAC

This is possible via one of these ways:

  • FCF – Fast Connection Failover.
  • TAF – Transparent Application Failover.


  • This is possible using JDBC-Thin (Type 4) driver (typically used with this).
  • It is event based, and supports load-balancing across nodes.
  • Works with help of ONS – Oracle Notification Service. A Service that runs in Oracle Database notifying interested parties about Oracle RAC Node status
  • On the client side you need: ojdbcN.jar and ons.jar
  • Do we need ons.config file?
  • A datasource that supports Fast Connection Failover is needed. (it will use ons internally to achieve this?)
  • Tomcat datasource configuration provides support for this. JBoss datasource configuration (eg. oracle-ds.xml) support is not known.
  • Perhaps you can programatically setup the datasource and achieve this.
  • Read Steps here:
  • What happens to the Connection Pool when a node goes down, does it automatically get refreshed?
  • What is the role of ucp here?

Tomcat datasource config:

<Resource name="JDBC/Pool" auth="Container"
 description="FCF Datasource"
"(InitialLimit=5, MinLimit=5, MaxLimit=20, ConnectionWaitTimeout=30)"
 user="username" password="password"
 url="jdbc:oracle:thin:@(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))


Spring Datasource Configuration:

<beans xmlns=""

    <orcl:pooling-datasource id="racDataSource"
        fast-connection-failover-enabled="true" 1
        ONS-configuration="rac1:6200,rac2:6200"/> 2

    <bean id="transactionManager" 
        <property name="dataSource" ref="racDataSource"/>



  • This is possible only using Oracle OCI Thick Client.
  • The fail-over happens from within OCI driver.
  • The tnsnames.ora file has the necessary configuration for fail-over across nodes.
  • The failover is configured in tnsnames.ora file, the TAF settings are placed in CONNECT_DATA section of the tnsnames.ora using FAILOVER_MODES parameters.
  • Your datasource configuration (in tomcat or say in jboss oracle-ds.xml) remains same as what it would be to connect via OCI driver.
  • Only SELECT Queries can be retried in case of fail-over. DML (insert/update/delete) are not retried, instead Exception is thrown to the application.

Example Config:



  • SESSION: Ideal for OLTP systems where transactions are small. In case of failover, a new session is automatically created for the user on the backup node.
  • SELECT: If the connection is lost, Oracle Net establishes a connection to another node and re-executes the SELECT statements with cursor positioned on the row on which it was positioned prior to the failover. This mode involves overhead on the client side and Oracle NET keeps track of SELECT statements. This approach is best for data warehouse systems, where the transactions are big and complex.
  • NONE: Default. Prevents failover.


Java program to change Active Directory user password (over SSL)?

Note, that to change Active Directory user password, connection must be made over SSL.

To enable SSL on Active Directory, and get hold of ssl certificate,  see instructions for that here.

The program:

import javax.naming.*;
import javax.naming.ldap.*;
import java.util.*;

public class ADPasswdChange {
DirContext ldapContext;
String baseName = ",CN=Users,DC=mydomain,DC=local";
String serverIP = "localhost";

public ADPasswdChange() {

try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "Simple");
//NOTE: Replace the user and password in next two lines, this user should have privileges to change password.
//NOTE: This is NOT the user whose password is being changed.
env.put(Context.SECURITY_PRINCIPAL, "powerfuluser@mydomain.local");
env.put(Context.SECURITY_CREDENTIALS, "whateverpassword");
//NOTE: Replace localhost in next line with actual ldap host:
env.put(Context.PROVIDER_URL, "ldap://localhost:636");
env.put(Context.SECURITY_PROTOCOL, "ssl");
ldapContext = new InitialLdapContext(env, null);

catch (Exception e) {
System.out.println(" bind error: " + e);

public void updatePassword(String username, String password) {
try {

String quotedPassword = "\"" + password + "\"";
char unicodePwd[] = quotedPassword.toCharArray();
byte pwdArray[] = new byte[unicodePwd.length * 2];
for (int i=0; i&lt;unicodePwd.length; i++) {
pwdArray[i*2 + 1] = (byte) (unicodePwd[i] &gt;&gt;&gt; 8);
pwdArray[i*2 + 0] = (byte) (unicodePwd[i] &amp; 0xff);

ModificationItem[] mods = new ModificationItem[1];
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
new BasicAttribute("UnicodePwd", pwdArray));

ldapContext.modifyAttributes("CN=" + username + baseName, mods);

catch (Exception e) {
System.out.println("update password error: " + e);

public static void main(String[] args) {
// the keystore that holds trusted root certificates
//NOTE: Replace with path to ssl certificate keystore file below.
System.setProperty("", "C:/mydir/keystore.jks");
//NOTE: Replace with keystore password that was used while converting .cer to .jks file.
System.setProperty("", "thekeypasswd");
System.setProperty("", "all");
ADPasswdChange adc = new ADPasswdChange();
//NOTE: Replace below with username whose password has to be changed and the desired password.
adc.updatePassword("user1", "change$2pass");

The above program is a slightly modified version of the one mentioned here:


Get every new post delivered to your Inbox.