You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Paul Spencer <pa...@apache.org> on 2014/08/19 11:30:04 UTC

Migrate 1 war with 3 instance from Tomcat to Karaf?

Karaf 2.3.5+
I have a web based application running on Tomcat that I would like to migrate to Karaf.  There are three instances of the application installed on one Tomcat server with each instance sharing a common war but configured in its own context.  As shown below, The <Parameter> and <Envronment> tags in the context are used to customize each instance of the application. How do I migrate the application with three instance to one Karaf server?

** Instance 1:
URL:  http://example.com/app_instance_1
Context File:  ${CATALINA_BASE}/conf/Catalina/localhost/app_instance_1.xml
 <Context path=“/app_instance_1” docbase=“{catalina.base}/wars/app.war”>
  <Parameter    name=“config.param” value=“instance_1” override=“false”/>
  <Environment  name=“config.name”  value=“Instance 1” override=“false” type=“java.lang.String”/>
 </Context>

** Instance 1:
URL:  http://example.com/app_instance_2
Context File:  ${CATALINA_BASE}/conf/Catalina/localhost/app_instance_2.xml
 <Context path=“/app_instance_2” docbase=“{catalina.base}/wars/app.war”>
  <Parameter    name=“config.param” value=“instance_2” override=“false”/>
  <Environment  name=“config.name”  value=“Instance 2” override=“false” type=“java.lang.String”/>
 </Context>

** Instance 3:
URL:  http://example.com/app_instance_3
Context File:  ${CATALINA_BASE}/conf/Catalina/localhost/app_instance_3.xml
 <Context path=“/app_instance_3” docbase=“{catalina.base}/wars/app.war”>
  <Parameter    name=“config.param” value=“instance_3” override=“false”/>
  <Environment  name=“config.name”  value=“Instance 3” override=“false” type=“java.lang.String”/>
 </Context>

Paul Spencer







Re: Migrate 1 war with 3 instance from Tomcat to Karaf?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Paul,

This does work without changing the code, you only need to add it to your
Manifest, or the URL when installing.
The jetty.xml can be found at [1].
For your use-case it's enough just to follow the description in [2], the
other one about usage via whiteboard is a different use-case.


regards, Achim

[1] -
https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/jetty-config-fragment/src/main/resources/jetty.xml
[2] -
http://notizblog.nierbeck.de/2013/01/bind-certain-web-applications-to-specific-httpconnectors/



2014-08-20 4:44 GMT+02:00 Paul Spencer <pa...@apache.org>:

> Achim,
> I was hoping for a solution where I could add instance without changing
> code.  The Activator has the list of instance hard code, although I see the
> instances could be calculated based on a pattern.  Also I do not see an
> example of jetty.xml in the whiteboard-extender project.
>
> Thank you,
> Paul Spencer
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Migrate-1-war-with-3-instance-from-Tomcat-to-Karaf-tp4034828p4034833.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>

Software Architect / Project Manager / Scrum Master

Re: Migrate 1 war with 3 instance from Tomcat to Karaf?

Posted by Paul Spencer <pa...@apache.org>.
Achim,
I was hoping for a solution where I could add instance without changing
code.  The Activator has the list of instance hard code, although I see the
instances could be calculated based on a pattern.  Also I do not see an
example of jetty.xml in the whiteboard-extender project.

Thank you,
Paul Spencer



--
View this message in context: http://karaf.922171.n3.nabble.com/Migrate-1-war-with-3-instance-from-Tomcat-to-Karaf-tp4034828p4034833.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Migrate 1 war with 3 instance from Tomcat to Karaf?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Paul,

since Karaf uses Pax Web/Jetty you'll need to switch to a Jetty like
configuration.
At my blog you'll find a description on how to do something like you want.
[1], [2]
But you'll need to switch to Karaf 3.0.1 for this to work as a newer
version of Pax Web is needed to support this.
A sample application can also be found at the samples of Pax Web. [3]

As quick outline, you'll need to define special connectors in the jetty.xml
that can be found in the etc folder of your Karaf
and need to reference this connector with a specialized manifest entry:
Web-Connectors

Btw. if you define multiple connectors and have no Web-Connectors manifest
entry the web application will be bound to all available.

regards, Achim


[1] -
http://notizblog.nierbeck.de/2013/01/bind-certain-web-applications-to-specific-httpconnectors/
[2] -
http://notizblog.nierbeck.de/2013/05/bind-certain-web-applications-to-specific-httpconnectors-ii/
[3] -
https://github.com/ops4j/org.ops4j.pax.web/blob/pax-exam-3.0.x/samples/whiteboard-extended/src/main/java/org/ops4j/pax/web/extender/samples/whiteboard/internal/Activator.java


2014-08-19 11:30 GMT+02:00 Paul Spencer <pa...@apache.org>:

> Karaf 2.3.5+
> I have a web based application running on Tomcat that I would like to
> migrate to Karaf.  There are three instances of the application installed
> on one Tomcat server with each instance sharing a common war but configured
> in its own context.  As shown below, The <Parameter> and <Envronment> tags
> in the context are used to customize each instance of the application. How
> do I migrate the application with three instance to one Karaf server?
>
> ** Instance 1:
> URL:  http://example.com/app_instance_1
> Context File:  ${CATALINA_BASE}/conf/Catalina/localhost/app_instance_1.xml
>  <Context path=“/app_instance_1” docbase=“{catalina.base}/wars/app.war”>
>   <Parameter    name=“config.param” value=“instance_1” override=“false”/>
>   <Environment  name=“config.name”  value=“Instance 1” override=“false”
> type=“java.lang.String”/>
>  </Context>
>
> ** Instance 1:
> URL:  http://example.com/app_instance_2
> Context File:  ${CATALINA_BASE}/conf/Catalina/localhost/app_instance_2.xml
>  <Context path=“/app_instance_2” docbase=“{catalina.base}/wars/app.war”>
>   <Parameter    name=“config.param” value=“instance_2” override=“false”/>
>   <Environment  name=“config.name”  value=“Instance 2” override=“false”
> type=“java.lang.String”/>
>  </Context>
>
> ** Instance 3:
> URL:  http://example.com/app_instance_3
> Context File:  ${CATALINA_BASE}/conf/Catalina/localhost/app_instance_3.xml
>  <Context path=“/app_instance_3” docbase=“{catalina.base}/wars/app.war”>
>   <Parameter    name=“config.param” value=“instance_3” override=“false”/>
>   <Environment  name=“config.name”  value=“Instance 3” override=“false”
> type=“java.lang.String”/>
>  </Context>
>
> Paul Spencer
>
>
>
>
>
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>

Software Architect / Project Manager / Scrum Master