Friday, 29 January 2010

Deploy an application in context root on Tomcat

How to Deploy an application in context root on Tomcat?

Suppose my web application with name MyApp, I created a WAR file and deployed in Tomcat. Now you can access the application as http://localost:port/MyApp/…

How can you change the context root in URL to some thing else?


Very Simple ,

1. Go to Tomcat Installation dir/conf/server.xml

2. Under Add (or Edit if is already existing) See image for xmls

Now your URL will be http://localhost:port/

You can change path to anything you want

See image for xmls

3. AND remove the ROOT webapp, or it will use that instead.

Wednesday, 20 January 2010

3 most commonly faced challenges to use Tapestry service (IOC)

  1. How to initialize one tapestry5 service at startup? Use Eager Load for this. eg: bind(MyServiceInterface.class, MyServiceImpl.class).eagerLoad();
2. How to use a tapestry5 service inside another T5 service which is eager loaded
Pass the service through the contructor, which will prevent from getting null pointer exceptions.
3. How to use multiple versions of a same service concurrently?
Can be done by using withId and withMarker attributes.
{ PARAMETER, FIELD }) @Retention(RUNTIME) @Documented public @interface Clustered {  }  @Target( { PARAMETER, FIELD }) @Retention(RUNTIME) @Documented public @interface InProcess {  }   public class MyModule {   public static void bind(ServiceBinder binder)   {     binder.bind(JobScheduler.class, ClusteredJobSchedulerImpl.class).withId("ClusteredJobScheduler").withMarker(Clustered.class);     binder.bind(JobScheduler.class, SimpleJobSchedulerImpl.class).withId("InProcessJobScheduler").withMarker(InProcess.class);   } }