You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by parker <pa...@yahoo.com> on 2014/07/16 23:43:09 UTC

Transform a big WAR project in OSGI

Hello,

To use a .WAR project in OSGi I need : Pax web or IAS WAR to WAB.
That transform a .WAR project in one OSGi bundle.

I have a big WAR project . How to  to use this big WAR in Karaf ?
I think the best way is to shrink the big war in many small WAR projects and
to deploy each small projects in Apacke Karaf. 

What do you think ?

How OSGi using apache Karaf can help me with a big WAR project ? 

Thanks, 

P.





--
View this message in context: http://karaf.922171.n3.nabble.com/Transform-a-big-WAR-project-in-OSGI-tp4034260.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Transform a big WAR project in OSGI

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

I'd start with a simple
bundle:install -s
webbundle:groupId/artifactID/version/war?Web-ContextPath=artifactID&Bundle-SymbolicName=artifactID

if that's successful and everything is working as desired, fine.

After that, create a WAB from it, by using the maven-bundle-plugin.
again install it, test if it works.

after that. remove dependencies from the WEB-INF/lib folder of your war and
import those dependencies.
That 'll give you a much smaller war-bundle, and usually you re-use
existing bundles, leaving you with a smaller footprint already.

Last Optimization is to modularize your web-application, so you end up with
a bunch of smaller wars and maybe plain bundles that take care of the
business logic.

regards, Achim




2014-07-16 23:43 GMT+02:00 parker <pa...@yahoo.com>:

> Hello,
>
> To use a .WAR project in OSGi I need : Pax web or IAS WAR to WAB.
> That transform a .WAR project in one OSGi bundle.
>
> I have a big WAR project . How to  to use this big WAR in Karaf ?
> I think the best way is to shrink the big war in many small WAR projects
> and
> to deploy each small projects in Apacke Karaf.
>
> What do you think ?
>
> How OSGi using apache Karaf can help me with a big WAR project ?
>
> Thanks,
>
> P.
>
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Transform-a-big-WAR-project-in-OSGI-tp4034260.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: Transform a big WAR project in OSGI

Posted by kiffer <ch...@kiffer.ltd.uk>.
If your war has been correctly registered it will also show up in the
web:list command output as Deployed, with a Web-ContextPath; and the
individual servlets will show in in the http:list command output. If they
are not visible then something fundamental is missing: perhaps you need to
install the "war" feature in Karaf, for example? ("feature:install war")

BTW it is very unhelpful to write "it's not working" when for a couple of
picojoules more effort you could write "I get 404 Not found" or whatever it
is you get.

As regards splitting up a big war, I would suggest try first to draw a
boundary between the "servlet" code and the "services" it uses; you can then
move all the non-webby code into a separate bundle. Having done that you may
be able to see clear fault-lines in one or other bundle, e.g. the servlets
clearly fall into two or three functional area which don't interact very
much or some services are only used by one servlet. How easy it will be will
depend very much on how big a mess the current code is: in my experience if
a large body of code has been developed without regard to modularity then it
will be one big mess. That being said, IMHO OSGi is far and away the best
tool around for creating and sustaining modularity. Courage!




--
View this message in context: http://karaf.922171.n3.nabble.com/Transform-a-big-WAR-project-in-OSGI-tp4034260p4034316.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Transform a big WAR project in OSGI

Posted by Achim Nierbeck <bc...@googlemail.com>.
Sorry, your mail did end up in my spam folder, that's why I didn't see it
before.

You need to call http://localhost:8181/sample/hello for this sample war.

regards, Achim


2014-07-18 0:06 GMT+02:00 parker <pa...@yahoo.com>:

> Thank you for your answer, I have done from
> http://karaf.apache.org/manual/latest/users-guide/webcontainer.html I have
> done karaf@root()> bundle:install -s
> "webbundle:
> http://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war?Bundle-SymbolicName=tomcat-sample&Web-ContextPath=/sample
> ",
> it's not working .
>
>
>
>
> karaf@root()> bundle:install -s
> "webbundle:
> http://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war?Bundle-SymbolicName=tomcat-sample&Web-ContextPath=/sample
> "
> Bundle ID: 123
> karaf@root()> list |grep tom
> 123 | Active |  80 | 0                    | tomcat-sample
>
> But When I go to  http://localhost:8181/sample it's not working , why ???
>
> Thank you
>
> Parker.
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Transform-a-big-WAR-project-in-OSGI-tp4034260p4034277.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: Transform a big WAR project in OSGI

Posted by parker <pa...@yahoo.com>.
Thank you for your answer, I have done from
http://karaf.apache.org/manual/latest/users-guide/webcontainer.html I have
done karaf@root()> bundle:install -s
"webbundle:http://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war?Bundle-SymbolicName=tomcat-sample&Web-ContextPath=/sample",
it's not working .




karaf@root()> bundle:install -s
"webbundle:http://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war?Bundle-SymbolicName=tomcat-sample&Web-ContextPath=/sample" 
Bundle ID: 123
karaf@root()> list |grep tom
123 | Active |  80 | 0                    | tomcat-sample          

But When I go to  http://localhost:8181/sample it's not working , why ???

Thank you

Parker.



--
View this message in context: http://karaf.922171.n3.nabble.com/Transform-a-big-WAR-project-in-OSGI-tp4034260p4034277.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Transform a big WAR project in OSGI

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

you don't need to transform the war as a WAB.

You can directly deploy the war using the webbundle URL:

karaf@root()> bundle:install -s 
"webbundle:http://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war?Bundle-SymbolicName=tomcat-sample&Web-ContextPath=/sample"

However, you don't leverage OSGi in that case.

If you want to leverage OSGi (like splitting the war in small bundles 
providing services, and just provide a small wab without anything in the 
web-inf/lib thanks to the import package, etc), you have to refactore 
your application.

Regards
JB

On 07/16/2014 11:43 PM, parker wrote:
> Hello,
>
> To use a .WAR project in OSGi I need : Pax web or IAS WAR to WAB.
> That transform a .WAR project in one OSGi bundle.
>
> I have a big WAR project . How to  to use this big WAR in Karaf ?
> I think the best way is to shrink the big war in many small WAR projects and
> to deploy each small projects in Apacke Karaf.
>
> What do you think ?
>
> How OSGi using apache Karaf can help me with a big WAR project ?
>
> Thanks,
>
> P.
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Transform-a-big-WAR-project-in-OSGI-tp4034260.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com