Tuesday, July 6, 2010

Configuration to mount MySQL data sources on a standalone tomcat server

There are loads of google searches for $Title.So following steps will guide you ,how to do that with a sample testing web app.

1. Gather requirements :
  • Tomcat 5.5 or above
  • MySQL database server
  • Connector: mysql-connector-java-3.1.7-bin.jar
2. Place the mysql connector in CATALINA_HOME/common/lib

3. Create your own sample web app say "myApp".

4. Then place this XML Context tag entry in server.xml (CATALINA_HOME/conf/server.xml) inside .........



Note that ,the username ,password are your MySQL credentials.

5.Then we have to tell the server container where is our jdbc data source is , when running our web app.So for that we have to enter the following resource ref tag entry in your web.xml.


6. Then you only have to do is make a datasource and get a connection with a MySQL DB in your webapp ,say inside a jsp and call it.Here is the code

/**


*/

THATS IT.SIMPLE............ENJOY J2EE.......!


Wednesday, June 23, 2010

Webservices and Axis

These days web services are becoming so popular and used in a wide area.Putting up a web service is not something like rocket science. Basically what it does is exchanging data through the Internet in a XML based format which we call "SOAP" (Simple Object Access Protocol).SOAP is meant for exchanging data in a distributed environment, and SOAP is built on XML

So we can say SOAP is a mechanism for inter-application communication between systems written in arbitrary languages, across the Internet. SOAP usually exchanges messages over HTTP.These SOAP messages exchange structured information between SOAP systems and they consist of one or more SOAP elements inside an envelope, Headers and the SOAP Body.So here Axis is an Open Source SOAP server and client which is an Apache project.

Axis implements the JAX-RPC API, one of the standard ways to program Java services.Here we will be talking more about JWS which stands for Java Web Services.

For instance lets say ,a java class which has a method "adder" to add two supplied values.At the end of this article you will find it really easy to expose this adder as a web service.

Lets get in to the action :Now we are going to deploy a web service with Axis.

Step-1:

You need to download and install Axis.For this please follow the install.html under docs directory in your binary distribution of axis.In brief what you have to do is that , copy the axis directory inside your Axis downloaded distribution in to your current web server's webapp directory (it is recommended to have a Apache Tomcat web server)

Step-2:

Also you have to copy any XML parser in to the axis/WEB-INF/lib directory .It is also recommended that to use Apache Xerces parcer and you can download it from here.

Step-3:

Start your web server.And you can simply check whether the installation has succeeded by simply requesting for http://localhost:8080/axis .

Thats it for now.

Above steps are to setup the axis environment.But how we deploy our web service.

Lets take a look at this sample Adder class .

public class Adder {

public int adder(int a, int b) {

return a+b;
}
}

Only you have to do here is that , create this class and name it as Adder.java and copy it in to axis directory and rename it as Adder.jws.This is how your "adder" method becomes a web service under axis framework.

Lets implement a small client to connect to the web service and invoke it.Here is a simple client class for you to run and test how this works.


import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

import java.net.*;

public class AdderServiceClient {
public static void main(String [] args) throws Exception {

Service service = new Service();
Call call = (Call)service.createCall();

String endpoint = "http://localhost:8080/axis/Adder.jws";
call.setTargetEndpointAddress(new URL(endpoint));
call.setOperationName(new QName("getCount"));

int a = 12;
int b = 13;
int count = 0;

int total = (Integer)call.invoke(new Object [] {new Integer(a), new Integer(b)});

System.out.println("Got result : " + total);
}
}


Please note that ,what we need to specify is the URL of the jws-file and the name of the method to invoke. Of course we also need to give the two strings with the division and team names. The convention is that they must be given as an Object array.

Now you will see the result as "Got result : 25"

This is a very simple demonstration of how JWS works.

Regards
/subash

Thursday, May 20, 2010

Compiz keyboard short cuts

Desktop Effects1 Keyboard Shortcuts
Rotate Cube Mousewheel on Desktop
Switcher2 Alt + Tab
Shift Switcher3 Super + Tab (2 modes: flip and cover)
Ring Switcher Super + Tab – overrides Shift Switcher
Expo Super + E (toggle)
Film Effect Ctrl + Alt + Down Arrow4
Rotate Cube Manually Ctrl + Alt + Left Mouse Button
Scale Windows Alt + Shift + Up Arrow
Show/Clear Desktop Ctrl + Alt + D (toggle)
Snapping Windows Move a window across workspaces5
Screenshot Super + Left Mouse Button
Zoom In/Out Super + Mousewheel
Transparent Window Alt + Mousewheel
Resize Window Alt + F8
Move Window Alt + F7
Add Helper Super + P
Widget Layer F9 (toggle)
Water Effects Shift + F9 (toggle)
Fire Effects: On Super + Shift + Left Mouse Button
Fire Effects: Clear Super + Shift + C
Annotate: Draw Super + Left Mouse Button
Annotate: Start Super + 1
Annotate: End Super + 3
Group: Select Window(s) Super + S
Group: Group Windows Super + T
Group: Ungroup Windows Super + U
Group: Flip Windows Super + Right or Left Arrow

Friday, May 14, 2010

Problems in connecting with E1550 mobile BB in Ubuntu 10.04

Sometimes Mobile BB ,say E1550 mount it self but doesn't seems to connect or we even can't see it is there.
So the solution for this problem is...:
Do the following steps after plug in your mobile BB.

1. Create a new rule for udev:

$ sudo vi /etc/udev/rules.d/15-huawei-155x.rules

2. Then type the following:

SUBSYSTEM=="usb",
ATTRS{idProduct}=="1446",
ATTRS{idVendor}=="12d1",
RUN+="/lib/udev/modem-modeswitch --vendor 0x$attr{idVendor} --product 0x$attr{idProduct} --type option-zerocd"

And now go to System>Preference>Network Connections and configure your service provider settings.


And enjoy surfing through the WEB with Lucid Linux

Visit http://tinyurl.com/37gkkx4/index.php?u=2618288

Thursday, May 13, 2010

How to setup and test a custom JCR implementation with JCR TCK

JCR TCK stands for Java Content Repository Technology Compatible Kit.

This will guide to test your JCR implementation with JCR2 (JSR 283) TCK.

This example shows how to test WSO2 Governance Registry JCR implementation with JCR TCK.

It is really easy if we can setup a java project (suppose an IDEA project) for testing purposes.

1.Create a new IntellijIDEA project

2.Add the following jars as dependencies to the above created IDEA project.

- jcr-2.0-b114.jar - Download
- jcr-tck-2.0.0.jar - Download
- junit.jar - Download
- org.osgi.core-4.1.0.jar - Download
- jars of your JCR implementation(ex: /.../carbon/components/registry/org.wso2.carbon.registry.jcr/target)
- any other required jars for your impl (for instance in WSO2 greg implementation ,it is better to do an ant inside /..../carbon/products/greg/ modules/distribution/target/wso2greg-3.5.0-SNAPSHOT/bin and add all jars inside /repository/lib and /lib )

3.Then set the following parameters in your test project

- Main Class : junit.swingui.TestRunner
- VM parameters : -Djavax.jcr.tck.properties=/home/subash/aaa/aaa.properties -Dcarbon.home=/home/subash/carbon/core/distribution/target/ wso2carbon-3.0.0-SNAPSHOT.
(Here note that aaa.properties file contains the name (as a value for the key javax.jcr.tck.repository_stub_impl) of your class which extends RepositoryStub ,which is used to return your RepositoryImpl to start the test ,also we have to set the carbon home to the above path ,carbon core)

- Programme parameters : org.apache.jackrabbit.test.api.NodeTest :This is the test class which you are going to test (actually you can change the test class you want , by simply changing this param)
- Working Directory : Set the working dir to your repository product home dir (for instance in this case: /..../carbon/products/greg/modules/distribution/target/wso2greg-3.5.0-SNAPSHOT)

4.Thats it.But remember ,you have to create your own class RepositoryStubImpl (any name which is the value for the key javax.jcr.tck.repository_stub_impl)
and implement getRepository() method such that you return your JCR RepositoryImpl instance.

Wednesday, May 5, 2010

Problems when installing JRE in Lucid Linux

With ubuntu 10.04 repo might get not updated.That is the main reason for this issue.

Simply what you have to do is :type these commands in your terminal step by step

1. sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

2. sudo apt-get update

3. Now install what you want : sudo apt-get install sun-java6-jre or sudo apt-get install sun-java6-jdk

Friday, March 19, 2010

Problems in installing Moodle

Moodle is an open source project which is basically a Content Management System (CMS).

  • You have to download moodle latest version from the moodle website. http://download.moodle.org/. (Remember when you download ,it will have many versions.But always try to use a stable version of it.For instance don't use "moodle-version+" .Because they are updating weekly.Normally for latest versions ,you need to have PHP 4.3.0, MySQL 4.1.16 or Postgres 8.0 or MSSQL 9.0 or Oracle 9.0)
  • Above user guide lines won't enough .Some problems may occur.So you have to explicitly rename the config---.php file in to config.php which is there in your downloaded .zip file and make the following changes in the config.php file.
  • Suppose you have installed wamp server(or any compatible server as mentioned above) at C:\wamp\
  • $CFG->dbtype = 'mysql'; // mysql or postgres7 (for now)
  • $CFG->dbhost = 'localhost'; // eg localhost or db.isp.com
  • $CFG->dbname = 'moodle'; // database name, eg moodle
  • $CFG->dbuser = 'root'; // your database username
  • $CFG->dbpass = ''; // your database password
  • $CFG->prefix = 'mdl_';
  • $CFG->wwwroot = 'http://localhost/moodle' //your root folder
  • $CFG->dirroot = 'C:\wamp\www\moodle' // your working directory (if you really work with )
  • $CFG->dataroot = 'E:\wamp\www\moodledata' // directory where moodle keeps your custom data

  • Then go to local host from your browser and you only have to do some clicks of next,next,next...And enjoy moodle. A pretty useful CMS.