Posts

Maven commands and hint

svn checkout without subfolders

svn co --depth immediates URL
maven without internet(Without downloading)

mvn -o install
mvn --offline install

Force the check of the latest dependency jars
mvn -U install
mvn --update-snapshots install

*** -U option to update your snapshots

Skip the tests

mvn install -DskipTests

also use the maven.test.skip property to skip compiling the tests

mvn install -Dmaven.test.skip=true

Remote Debug

mvnDebug test
mvnDebug install


To avoid OutOfMemoryError

To avoid OutOfMemoryError when running maven, set environment variable MAVEN_OPTS as below

MAVEN_OPTS=-Xmx1024m -XX:MaxPermSize=256m


If you have issue with Maven does not find JUnit test cases to run:
By default Maven runs tests class which names start with Test or end with Test or TestCase.Do not messed up the naming convention

Introduction to OSGi - 2 (OSGi Services)

There are so many OSGi tutorials, blogs, and samples. I am going to add another OSGi sample/tutorial with my OSGi leanings. Here is my previous article regarding OSGi(Introduction to OSGi).

An OSGi Service is a java object instance which is registered with OSGi framework with set of attributes. Services can be accessed via service registry(performed via the class BundleContext). BundleActivator is to be invoked on start and stop. When BundleActivator call start method we are going to register our service. After that any bundle can access that service.

Service Bundle:

In service bundle you need to export your service and need to register it via service registry. When we are exporting service we export interface package only. As usual that is to hide the implementation from the other bundles.

I have created a sample OSGi project called HelloServcie

MANIFEST.MF
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: HelloService Bundle-SymbolicName: com.chandana.hello.HelloSer…

How to Ignore Files or Directories in Subversion

Image
We are facing a common problem when trying to commit some changes to the SVN. That is each time we have to ignore some JAR files, because those JAR files are user run time specific and if they are committed, it would not work on other local runtimes.

Here is a pretty simple solution for this problem. We can tell subversion to ignore directories or specific files as follows.

Ignore directories or specific files.
   svn propedit svn:ignore ./some_path
It will ignore all files in the specified directory. Here only wildcard indication is supported, and regular expressions are not supported.

Example wildcard supprt:
 svn propedit svn:ignore *
Example ingnore class files with wildcard:
  svn propedit svn:ignore *.class

If you are using Eclipse SubEclispe plugin,

Right Click file or folder --> Team --> Then click on svn:ignore

How to debug using Maven Jetty

Image
Debugging is a better approach to find out bugs in our programs. Here is a way to debug a maven project, and I am going to run my web application in the Jetty server.

First you need to add the following environmental variables on your Windows/Linux environment.

MAVEN_OPTS = -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y Now go to your maven web project location through command line and start the jetter server -> mvn jetty:run



Now in eclipse debug configuration, add a remote Java application instance on port 4000. Then Add some debug points to your codes  and start the remote app instance on debug mode. You can see the steps from following screen shots.





In this manner you can debug your java web apps and find out the bugs. With this way you can debug your java web app.

if you are using maven latest version( Maven 2.0.8 or later)

run the
mvnDebug command instead of
mvn and attach a debugger on port 8000.

Love to hear from yo…

Google Cloud SQL, Hibernate JPA Support

With my last post about Google Cloud SQL(Google App Engine) with Spring Hibernate, many people had encountered the same issue about HIbenrate JPA. If you are developing Hibernate JPA based applications,there is some issues with Hibernate JPA support which you need to be awared.

When you are running the application you may get an error like this:

java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
This is because Hibernate used JPA 2.0 specification. But Google App Engine only support JPA 1.0 specification. I also got the same issue, and therefore I used Spring Hibernate support (instead of Hibernate JPA).

"The App Engine Java SDK includes an implementation of JPA 1.0 for the App Engine datastore"
Google App Engine JPA : http://code.google.com/appengine/docs/java/datastore/jpa/


Love to hear from you! feedback(comments) are always welcome

Google Cloud SQL with Struts, Spring and Hibernate

With Google App engine SDK 1.5.5, Google have introduced Google Cloud SQL for GAE (Currently we can't connect any other external application with Google Cloud SQL. This can be only with Google App Engine Apps).

It's faster than connecting with Amazon RDS and other Cloud based Data solutions. No need to worry about load balancing as well. Cloud SQL supports 5 QPS read/write rate, so as long as you don't go over that, you can use cloud SQL. If you are going over this read/write rate limit, datastore might become a much more effective approach to you.If you are storing large blobs data(images, attchments and sound files, it's better storing them in the datastore or blobstore.

When Google App Engine became populer in late 2009 many people asked about Hibernate support. But with their datasore people were unable to develop Hibernate support applications with GAE. But with Google Cloud SQL developers can use Hibernate supported applications as well.

Sample Application with Google Cloud SQL

Three months ago I was able to participate in one of the Google App Engine based task management project.  However, in that project, I had to face some critical issues in searching as Google Datastore did not support many search options including LIKE search. It is known that searching is one of the essential parts of the enterprise applications.


However, Google introduced Cloud SQL last week and they approved my "Google Cloud SQL" request today (they took 5 days to approve it.:D ). Once they approved, I decided to develop a sample application with Cloud SQL. Gogole Cloud SQL database engine is MySql Version 5.1.59 and database size must be no larger than 10GB. Here I have added option to Test LIKE search. If you need more clarification, feel free to contact me.

Test Application http://securezilla.appspot.com/

PS: Added Source Code
Sample Project : http://code.google.com/p/cloudsql/ 
    Backup Link: https://github.com/cnapagoda/cloudsql

New Post : Google Cloud SQL with Spring…