Showing posts with the label Eclipse

Change Jetty Server Running Port

Jetty is one one of the best development server which I have ever used. It is easy to work with jetty server and its light weight

Here I am going to show how to change jetty server running port.  Jetty server default running port is 8080.

Port with Maven: 

 Command line:          For starting jetty server we are using mvn jetty:run command. We can change the port jetty server running by passing run time argument to it.

mvn -Djetty.port=80 jetty:run

 Using pom.xml
                By changing jetty plugin system properties as below, you can change the jetty running port.
<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <configuration> <stopPort>9966</stopPort> <stopKey>foo</stopKey> <systemProperties> <systemproperty> <name>jetty.port</name> <value>80</value> </systemproperty> </systemP…

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-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: HelloService Bundle-SymbolicName: com.chandana.hello.HelloSer…

How to Ignore Files or Directories in Subversion

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

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…