deploying a war with dependencies in bundled jars

classic Classic list List threaded Threaded
39 messages Options
12
Reply | Threaded
Open this post in threaded view
|

deploying a war with dependencies in bundled jars

jefoy1101
Good day,

I am trying to research on my war implementation to karaf, my war has 3 jar dependencies that I installed as a bundle in my karaf, the way I did this is thru custom_install_myconfig.cfg

I added a folder {karaf_base}/my_lib and put all my jar dependencies in that folder, once I start karaf all the jars are started and install as a bundle

Then I deployed my war by copying my war file in the deploy folder, but im getting am exception

Caused by: java.lang.ClassNotFoundException: com.myproject.className not found by ag [104]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)[org.apache.felix.framework-4.2.1.jar:]

the class  com.myproject.className is already deployed as a bundle inside my my_lib folder

How can I make this work? is there a better way to achieve my goal, basically I want to deploy my war in karaf with my jar dependencies to be osgi bundle so i could update them anytime I want

Thanks in advance



Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

Achim Nierbeck
Hi, 

does your war also import those packages?
Does the bundle in question actually export the required Package?

regards, Achim 


2014-12-30 23:22 GMT+01:00 jefoy1101 <[hidden email]>:
Good day,

I am trying to research on my war implementation to karaf, my war has 3 jar
dependencies that I installed as a bundle in my karaf, the way I did this is
thru custom_install_myconfig.cfg

I added a folder {karaf_base}/my_lib and put all my jar dependencies in that
folder, once I start karaf all the jars are started and install as a bundle

Then I deployed my war by copying my war file in the deploy folder, but im
getting am exception

Caused by: java.lang.ClassNotFoundException: com.myproject.className not
found by ag [104]
        at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)[org.apache.felix.framework-4.2.1.jar:]

the class  com.myproject.className is already deployed as a bundle inside my
my_lib folder

How can I make this work? is there a better way to achieve my goal,
basically I want to deploy my war in karaf with my jar dependencies to be
osgi bundle so i could update them anytime I want

Thanks in advance







--
View this message in context: http://karaf.922171.n3.nabble.com/deploying-a-war-with-dependencies-in-bundled-jars-tp4037488.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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
1. My pom.xml have the ff

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${maven-bundle-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Export-Package>
                            *;version=${project.version}
                        </Export-Package>
                        <Import-Package>
                            *
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>


2. not sure on this, mywar.war have the ff, i put provided so that it will not be having the jar files inside my war, I copy the domain.jar from my maven repo and put it in ag_lib, not really sure if my bundle is actually exporting it or not, and also I was trying to find the manifest.mf of mywar.war but i cant find it, I apologize as I'm not sure about it

        <dependency>
                        <groupId>com.myproject</groupId>
                        <artifactId>domain</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
        <dependency>
                        <groupId>com.myproject</groupId>
                        <artifactId>client</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
        <dependency>
                        <groupId>com.myproject</groupId>
                        <artifactId>service1</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

Achim Nierbeck
Hi, 

you can use the karaf shell to find those details. 
for example bundle:headers should give you the details about the exporting/Importing. 

regarding your POM I'm not sure this will work corectly for your war. I think this is probably your issue, it's not a OSGi war yet. 

regards, Achim 
 

2014-12-31 0:18 GMT+01:00 jefoy1101 <[hidden email]>:
1. My pom.xml have the ff

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${maven-bundle-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>

<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Export-Package>
                            *;version=${project.version}
                        </Export-Package>
                        <Import-Package>
                            *
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>


2. not sure on this, mywar.war have the ff, i put provided so that it will
not be having the jar files inside my war, I copy the domain.jar from my
maven repo and put it in ag_lib, not really sure if my bundle is actually
exporting it or not, and also I was trying to find the manifest.mf of
mywar.war but i cant find it, I apologize as I'm not sure about it

        <dependency>
                        <groupId>com.myproject</groupId>
                        <artifactId>domain</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
        <dependency>
                        <groupId>com.myproject</groupId>
                        <artifactId>client</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
        <dependency>
                        <groupId>com.myproject</groupId>
                        <artifactId>service1</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>




--
View this message in context: http://karaf.922171.n3.nabble.com/deploying-a-war-with-dependencies-in-bundled-jars-tp4037488p4037491.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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
Here are the headers I have

ag (104)
--------
Manifest-Version = 1.0
Bnd-LastModified = 1419974794717
Archiver-Version = Plexus Archiver
Tool = Bnd-2.2.0.20130927-173417
Originally-Created-By = Apache Maven 3.0.5
WAR-URL = file:/<path>/apache-karaf-3.0.2/deploy/ag.war
Built-By = jeffreyjarin
Web-ContextPath = /ag
Generated-By-Ops4j-Pax-From = file:/<path>/apache-karaf-3.0.2/deploy/ag.war
Build-Jdk = 1.7.0_21
Created-By = 1.7.0_21 (Oracle Corporation)

Bundle-Name = ag
Bundle-SymbolicName = ag
Bundle-Version = 0.0.0
Bundle-ManifestVersion = 2
Bundle-ClassPath = WEB-INF/classes,WEB-INF/lib/commons-codec-1.6.jar,WEB-INF/lib/commons-pool-1.6.jar,WEB-INF/lib/hornetq-core-client-2.2.13.Final.jar,WEB-INF/lib/hornetq-jms-client-2.2.13.Final.jar,WEB-INF/lib/httpclient-4.3.2.jar,WEB-INF/lib/httpcore-4.3.1.jar,WEB-INF/lib/infinispan-cdi-6.0.2.Final.jar,WEB-INF/lib/infinispan-client-hotrod-6.0.2.Final.jar,WEB-INF/lib/infinispan-commons-6.0.2.Final.jar,WEB-INF/lib/infinispan-core-6.0.2.Final.jar,WEB-INF/lib/jackson-annotations-2.3.0.jar,WEB-INF/lib/jackson-core-2.3.0.jar,WEB-INF/lib/jackson-databind-2.3.0.jar,WEB-INF/lib/javax.inject-1.jar,WEB-INF/lib/jboss-as-build-config-7.1.1.Final.jar,WEB-INF/lib/jboss-ejb-api_3.1_spec-1.0.1.Final.jar,WEB-INF/lib/jboss-ejb-client-1.0.5.Final.jar,WEB-INF/lib/jboss-jms-api_1.1_spec-1.0.0.Final.jar,WEB-INF/lib/jboss-logging-3.1.2.GA.jar,WEB-INF/lib/jboss-marshalling-1.4.4.Final.jar,WEB-INF/lib/jboss-marshalling-river-1.4.4.Final.jar,WEB-INF/lib/jboss-remote-naming-1.0.2.Final.jar,WEB-INF/lib/jboss-remoting-3.2.3.GA.jar,WEB-INF/lib/jboss-sasl-1.0.0.Final.jar,WEB-INF/lib/jboss-transaction-api_1.1_spec-1.0.1.Final.jar,WEB-INF/lib/jcl-over-slf4j-1.7.5.jar,WEB-INF/lib/jgroups-3.4.1.Final.jar,WEB-INF/lib/jul-to-slf4j-1.7.5.jar,WEB-INF/lib/log4j-1.2.17.jar,WEB-INF/lib/lz4-1.2.0.jar,WEB-INF/lib/perf4j-0.9.16.jar,WEB-INF/lib/slf4j-api-1.7.5.jar,WEB-INF/lib/slf4j-log4j12-1.7.5.jar,WEB-INF/lib/snappy-java-1.0.5.jar,WEB-INF/lib/xnio-api-3.0.3.GA.jar,WEB-INF/lib/xnio-nio-3.0.3.GA.jar

Import-Package =
        javax.servlet,
        javax.servlet.http,
        javax.annotation;resolution:=optional,
        javax.crypto;resolution:=optional,
        javax.crypto.spec;resolution:=optional,
        javax.enterprise.context;resolution:=optional,
        javax.enterprise.context.spi;resolution:=optional,
        javax.enterprise.event;resolution:=optional,
        javax.enterprise.inject;resolution:=optional,
        javax.enterprise.inject.spi;resolution:=optional,
        javax.enterprise.util;resolution:=optional,
        javax.interceptor;resolution:=optional,
        javax.jmdns;resolution:=optional,
        javax.mail;resolution:=optional,
        javax.mail.internet;resolution:=optional,
        javax.management;resolution:=optional,
        javax.naming;resolution:=optional,
        javax.naming.spi;resolution:=optional,
        javax.net;resolution:=optional,
        javax.net.ssl;resolution:=optional,
        javax.security.auth;resolution:=optional,
        javax.security.auth.callback;resolution:=optional,
        javax.security.auth.login;resolution:=optional,
        javax.security.auth.x500;resolution:=optional,
        javax.security.sasl;resolution:=optional,
        javax.servlet.annotation;resolution:=optional,
        javax.sql;resolution:=optional,
        javax.swing;resolution:=optional,
        javax.swing.border;resolution:=optional,
        javax.swing.event;resolution:=optional,
        javax.swing.table;resolution:=optional,
        javax.swing.text;resolution:=optional,
        javax.swing.tree;resolution:=optional,
        javax.xml.bind;resolution:=optional,
        javax.xml.datatype;resolution:=optional,
        javax.xml.namespace;resolution:=optional,
        javax.xml.parsers;resolution:=optional,
        javax.xml.rpc.handler;resolution:=optional,
        javax.xml.stream;resolution:=optional,
        javax.xml.transform;resolution:=optional,
        javax.xml.transform.dom;resolution:=optional,
        javax.xml.transform.stream;resolution:=optional,
        javax.xml.validation;resolution:=optional,
        javax.xml.xpath;resolution:=optional,
        org.xml.sax;resolution:=optional,
        org.xml.sax.helpers;resolution:=optional,
        org.w3c.dom;resolution:=optional,
        org.w3c.dom.bootstrap;resolution:=optional,
        org.w3c.dom.ls;resolution:=optional,
        org.slf4j.helpers;resolution:=optional;provider=paxlogging,
        org.apache.commons.logging;resolution:=optional;provider=paxlogging,
        org.slf4j;resolution:=optional;provider=paxlogging,
        javax.servlet.jsp.el;resolution:=optional,
        org.apache.commons.logging.impl;resolution:=optional;provider=paxlogging,
        org.apache.log4j.xml;resolution:=optional;provider=paxlogging,
        org.slf4j.spi;resolution:=optional;provider=paxlogging,
        javax.servlet.jsp;resolution:=optional,
        com.myproject.framework;resolution:=optional,
        org.apache.log4j;resolution:=optional;provider=paxlogging,
        org.apache.log4j.spi;resolution:=optional;provider=paxlogging


How do I make my pom.xml osgi war?

I package it using the ff

        <modelVersion>4.0.0</modelVersion>

        <name>Ad Gateway Framework</name>
        <groupId>com.myproject</groupId>
        <artifactId>myproject-framework</artifactId>
        <packaging>war</packaging>
        <version>3.0.1-SNAPSHOT</version>

        <properties>
                <java.version>1.7</java.version>
                <httpclient.version>4.3.2</httpclient.version>
                <slf4j.version>1.7.5</slf4j.version>
                <log4j.version>1.2.17</log4j.version>
                <junit.version>4.11</junit.version>
                <maven.enforcer.plugin>1.2</maven.enforcer.plugin>
                <maven.version.range>[3.0.4,)</maven.version.range>
                <infinispan.version>6.0.2.Final</infinispan.version>
                <jackson.version>2.3.0</jackson.version>
                <maven-bundle-plugin.version>2.4.0</maven-bundle-plugin.version>
        <osgi.version>5.0.0</osgi.version>
        </properties>

        <dependencies>
    <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>${osgi.version}</version>
            <scope>provided</scope>
        </dependency>   
Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

Achim Nierbeck
Ok, 
a couple of things, the war you deployed wasn't osgi ready, mostly due to the war packaging. 
It's been auto osgi-fyed by the war deployer. 
You should also make sure you don't have those logging related jars inside the war, that will screw up your logging. 
For building a war with osgi headers take look at the samples of the pax-web project [1]
or if you have the Apache Karaf Cookbook at hand read chapter 4. 

regards, Achim 


2014-12-31 0:38 GMT+01:00 jefoy1101 <[hidden email]>:
Here are the headers I have

ag (104)
--------
Manifest-Version = 1.0
Bnd-LastModified = 1419974794717
Archiver-Version = Plexus Archiver
Tool = Bnd-2.2.0.20130927-173417
Originally-Created-By = Apache Maven 3.0.5
WAR-URL = file:/<path>/apache-karaf-3.0.2/deploy/ag.war
Built-By = jeffreyjarin
Web-ContextPath = /ag
Generated-By-Ops4j-Pax-From = file:/<path>/apache-karaf-3.0.2/deploy/ag.war
Build-Jdk = 1.7.0_21
Created-By = 1.7.0_21 (Oracle Corporation)

Bundle-Name = ag
Bundle-SymbolicName = ag
Bundle-Version = 0.0.0
Bundle-ManifestVersion = 2
Bundle-ClassPath =
WEB-INF/classes,WEB-INF/lib/commons-codec-1.6.jar,WEB-INF/lib/commons-pool-1.6.jar,WEB-INF/lib/hornetq-core-client-2.2.13.Final.jar,WEB-INF/lib/hornetq-jms-client-2.2.13.Final.jar,WEB-INF/lib/httpclient-4.3.2.jar,WEB-INF/lib/httpcore-4.3.1.jar,WEB-INF/lib/infinispan-cdi-6.0.2.Final.jar,WEB-INF/lib/infinispan-client-hotrod-6.0.2.Final.jar,WEB-INF/lib/infinispan-commons-6.0.2.Final.jar,WEB-INF/lib/infinispan-core-6.0.2.Final.jar,WEB-INF/lib/jackson-annotations-2.3.0.jar,WEB-INF/lib/jackson-core-2.3.0.jar,WEB-INF/lib/jackson-databind-2.3.0.jar,WEB-INF/lib/javax.inject-1.jar,WEB-INF/lib/jboss-as-build-config-7.1.1.Final.jar,WEB-INF/lib/jboss-ejb-api_3.1_spec-1.0.1.Final.jar,WEB-INF/lib/jboss-ejb-client-1.0.5.Final.jar,WEB-INF/lib/jboss-jms-api_1.1_spec-1.0.0.Final.jar,WEB-INF/lib/jboss-logging-3.1.2.GA.jar,WEB-INF/lib/jboss-marshalling-1.4.4.Final.jar,WEB-INF/lib/jboss-marshalling-river-1.4.4.Final.jar,WEB-INF/lib/jboss-remote-naming-1.0.2.Final.jar,WEB-INF/lib/jboss-remoting-3.2.3.GA.jar,WEB-INF/lib/jboss-sasl-1.0.0.Final.jar,WEB-INF/lib/jboss-transaction-api_1.1_spec-1.0.1.Final.jar,WEB-INF/lib/jcl-over-slf4j-1.7.5.jar,WEB-INF/lib/jgroups-3.4.1.Final.jar,WEB-INF/lib/jul-to-slf4j-1.7.5.jar,WEB-INF/lib/log4j-1.2.17.jar,WEB-INF/lib/lz4-1.2.0.jar,WEB-INF/lib/perf4j-0.9.16.jar,WEB-INF/lib/slf4j-api-1.7.5.jar,WEB-INF/lib/slf4j-log4j12-1.7.5.jar,WEB-INF/lib/snappy-java-1.0.5.jar,WEB-INF/lib/xnio-api-3.0.3.GA.jar,WEB-INF/lib/xnio-nio-3.0.3.GA.jar

Import-Package =
        javax.servlet,
        javax.servlet.http,
        javax.annotation;resolution:=optional,
        javax.crypto;resolution:=optional,
        javax.crypto.spec;resolution:=optional,
        javax.enterprise.context;resolution:=optional,
        javax.enterprise.context.spi;resolution:=optional,
        javax.enterprise.event;resolution:=optional,
        javax.enterprise.inject;resolution:=optional,
        javax.enterprise.inject.spi;resolution:=optional,
        javax.enterprise.util;resolution:=optional,
        javax.interceptor;resolution:=optional,
        javax.jmdns;resolution:=optional,
        javax.mail;resolution:=optional,
        javax.mail.internet;resolution:=optional,
        javax.management;resolution:=optional,
        javax.naming;resolution:=optional,
        javax.naming.spi;resolution:=optional,
        javax.net;resolution:=optional,
        javax.net.ssl;resolution:=optional,
        javax.security.auth;resolution:=optional,
        javax.security.auth.callback;resolution:=optional,
        javax.security.auth.login;resolution:=optional,
        javax.security.auth.x500;resolution:=optional,
        javax.security.sasl;resolution:=optional,
        javax.servlet.annotation;resolution:=optional,
        javax.sql;resolution:=optional,
        javax.swing;resolution:=optional,
        javax.swing.border;resolution:=optional,
        javax.swing.event;resolution:=optional,
        javax.swing.table;resolution:=optional,
        javax.swing.text;resolution:=optional,
        javax.swing.tree;resolution:=optional,
        javax.xml.bind;resolution:=optional,
        javax.xml.datatype;resolution:=optional,
        javax.xml.namespace;resolution:=optional,
        javax.xml.parsers;resolution:=optional,
        javax.xml.rpc.handler;resolution:=optional,
        javax.xml.stream;resolution:=optional,
        javax.xml.transform;resolution:=optional,
        javax.xml.transform.dom;resolution:=optional,
        javax.xml.transform.stream;resolution:=optional,
        javax.xml.validation;resolution:=optional,
        javax.xml.xpath;resolution:=optional,
        org.xml.sax;resolution:=optional,
        org.xml.sax.helpers;resolution:=optional,
        org.w3c.dom;resolution:=optional,
        org.w3c.dom.bootstrap;resolution:=optional,
        org.w3c.dom.ls;resolution:=optional,
        org.slf4j.helpers;resolution:=optional;provider=paxlogging,
        org.apache.commons.logging;resolution:=optional;provider=paxlogging,
        org.slf4j;resolution:=optional;provider=paxlogging,
        javax.servlet.jsp.el;resolution:=optional,
        org.apache.commons.logging.impl;resolution:=optional;provider=paxlogging,
        org.apache.log4j.xml;resolution:=optional;provider=paxlogging,
        org.slf4j.spi;resolution:=optional;provider=paxlogging,
        javax.servlet.jsp;resolution:=optional,
        com.myproject.framework;resolution:=optional,
        org.apache.log4j;resolution:=optional;provider=paxlogging,
        org.apache.log4j.spi;resolution:=optional;provider=paxlogging


How do I make my pom.xml osgi war?

I package it using the ff

        <modelVersion>4.0.0</modelVersion>

        <name>Ad Gateway Framework</name>
        <groupId>com.myproject</groupId>
        <artifactId>myproject-framework</artifactId>
        <packaging>war</packaging>
        <version>3.0.1-SNAPSHOT</version>

        <properties>
                <java.version>1.7</java.version>
                <httpclient.version>4.3.2</httpclient.version>
                <slf4j.version>1.7.5</slf4j.version>
                <log4j.version>1.2.17</log4j.version>
                <junit.version>4.11</junit.version>
                <maven.enforcer.plugin>1.2</maven.enforcer.plugin>
                <maven.version.range>[3.0.4,)</maven.version.range>
                <infinispan.version>6.0.2.Final</infinispan.version>
                <jackson.version>2.3.0</jackson.version>
                <maven-bundle-plugin.version>2.4.0</maven-bundle-plugin.version>
        <osgi.version>5.0.0</osgi.version>
        </properties>

        <dependencies>
         <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>${osgi.version}</version>
            <scope>provided</scope>
        </dependency>



--
View this message in context: http://karaf.922171.n3.nabble.com/deploying-a-war-with-dependencies-in-bundled-jars-tp4037488p4037495.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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
In reply to this post by jefoy1101
ok will this example work?

https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/war/pom.xml

how do i point my war to my bundle domain.jar inside my ag_lib folder?

Thanks for the suggestion on the logs





Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

Achim Nierbeck
Hi, 

no more like the one in [1].

and you don't need to point your war to the other bundle, just do the package import/export thing right :-)

regards, Achim 



2014-12-31 1:17 GMT+01:00 jefoy1101 <[hidden email]>:
ok will this example work?

https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/war/pom.xml

how do i point my war to my bundle domain.jar inside my ag_lib folder?

Thanks for the suggestion on the logs









--
View this message in context: http://karaf.922171.n3.nabble.com/deploying-a-war-with-dependencies-in-bundled-jars-tp4037488p4037497.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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
Thank Achim I really appreciate it, but does my example will not work? I'm seeing a couple of examples for the war file, as I am not really implementing any spring I just want to know, what is the requirement of making my war osgi fyed and make it runnable in karaf? also how can i import the external bundle from my pom.xml?
Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
In reply to this post by Achim Nierbeck
Hi Achim,

i have osgi fyed my war but im not able to link my jar bundle to my war, How can i correctly import/export my bundle jar to my war files/

Thanks
Jeff
Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

Achim Nierbeck
Hi, 

add an dependency to the jar in the war project, usually the maven-bundle-plugin will take care of the right imports. 

So in your case you should already have a dependency to the jar bundle in the pom, make sure it is a provided dependency. 
Now use some of the classes in your project, the maven-bundle-plugin will take care of the required import-package declaration. 

regards, Achim 
 

2015-01-02 19:09 GMT+01:00 jefoy1101 <[hidden email]>:
Hi Achim,

i have osgi fyed my war but im not able to link my jar bundle to my war, How
can i correctly import/export my bundle jar to my war files/

Thanks
Jeff



--
View this message in context: http://karaf.922171.n3.nabble.com/deploying-a-war-with-dependencies-in-bundled-jars-tp4037488p4037541.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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
This post was updated on .
Hi Achim,

I already have these on my dependency

<dependencies>
                <dependency>
                        <groupId>org.osgi</groupId>
                        <artifactId>org.osgi.core</artifactId>
                        <version>${osgi.version}</version>
                        <scope>provided</scope>
                </dependency>
                <dependency>
                        <groupId>com.myproject.adgateway</groupId>
                        <artifactId>domain</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
                <dependency>
                        <groupId>com.myproject.adgateway.provider</groupId>
                        <artifactId>provider</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
                <dependency>
                        <groupId>com.myproject.adgateway.client</groupId>
                        <artifactId>client-7UL</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
<dependencies>

and have this on the plugings section

<plugin>
                                <groupId>org.apache.felix</groupId>
                                <artifactId>maven-bundle-plugin</artifactId>
                                <extensions>true</extensions>
                                <configuration>
                                        <supportedProjectTypes>
                                                <supportedProjectType>jar</supportedProjectType>
                                                <supportedProjectType>bundle</supportedProjectType>
                                                <supportedProjectType>war</supportedProjectType>
                                        </supportedProjectTypes>
                                        <instructions>
                                                <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
                                                <Bundle-Version>${project.version}</Bundle-Version>
                                                <Import-Package>
                                                        *; resolution:=optional
                                                </Import-Package>
                                                <Export-Package>com.myproject.*,!*</Export-Package>
                                                <Bundle-Classpath>
                                                        WEB-INF/classes
                                                </Bundle-Classpath>
                                                <Web-ContextPath>agwar</Web-ContextPath>
                                                <Embed-Dependency>*; artifactId=!org.osgi.compendium;
                                                        scope=compile; type=!pom; inline=true</Embed-Dependency>
                                                <Embed-Transitive>true</Embed-Transitive>
                                                <_removeheaders>
                                                        Include-Resource,
                                                        Private-Package,
                                                        Embed-Dependency,
                                                        Embed-Transitive,
                                                        Ignore-Package
                                                </_removeheaders>
                                        </instructions>
                                </configuration>
                                <executions>
                                        <execution>
                                                <id>generate-manifest</id>
                                                <phase>process-classes</phase>
                                                <goals>
                                                        <goal>manifest</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>
                        <plugin>
                                <artifactId>maven-war-plugin</artifactId>
                                <configuration>
                                        <archive>
                                                <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                                        </archive>
                                </configuration>
                        </plugin>


SO I have my etc/mycnfg.cfg that actually install all the jars and put it in karaf as bundles, once karaf started they are all being installed and then I will just have to copy and paste my war file to the deploy folder

but still getting the noclassfound error from one of the dependency

Caused by: java.lang.ClassNotFoundException: <ClassName> not found by com.XXXX.framework [110]
Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

Achim Nierbeck
Is it the war file or one of the others that doesn't resolve?
Does the war actually contain the generated manifest?
How do you reference that package, is it included in your Import-Package of the manifest 
is there actually a bundle available that exports it?

regards, Achim 


2015-01-02 22:05 GMT+01:00 jefoy1101 <[hidden email]>:
Hi Achim,

I already have these on my dependency

<dependencies>
                <dependency>
                        <groupId>org.osgi</groupId>
                        <artifactId>org.osgi.core</artifactId>
                        <version>${osgi.version}</version>
                        <scope>provided</scope>
                </dependency>
                <dependency>
                        <groupId>com.pinsight.adgateway</groupId>
                        <artifactId>domain</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
                <dependency>
                        <groupId>com.pinsight.adgateway.provider</groupId>
                        <artifactId>provider</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
                <dependency>
                        <groupId>com.pinsight.adgateway.client</groupId>
                        <artifactId>client-7UL</artifactId>
                        <version>3.0.1-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
<dependencies>

and have this on the plugings section

<plugin>
                                <groupId>org.apache.felix</groupId>
                                <artifactId>maven-bundle-plugin</artifactId>
                                <extensions>true</extensions>
                                <configuration>
                                        <supportedProjectTypes>
                                                <supportedProjectType>jar</supportedProjectType>
                                                <supportedProjectType>bundle</supportedProjectType>
                                                <supportedProjectType>war</supportedProjectType>
                                        </supportedProjectTypes>
                                        <instructions>
                                                <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
                                                <Bundle-Version>${project.version}</Bundle-Version>
                                                <Import-Package>
                                                        *; resolution:=optional
                                                </Import-Package>
                                                <Export-Package>com.pinsightmedia.*,!*</Export-Package>
                                                <Bundle-Classpath>
                                                        WEB-INF/classes
                                                </Bundle-Classpath>
                                                <Web-ContextPath>agwar</Web-ContextPath>
                                                <Embed-Dependency>*; artifactId=!org.osgi.compendium;
                                                        scope=compile; type=!pom; inline=true</Embed-Dependency>
                                                <Embed-Transitive>true</Embed-Transitive>
                                                <_removeheaders>
                                                        Include-Resource,
                                                        Private-Package,
                                                        Embed-Dependency,
                                                        Embed-Transitive,
                                                        Ignore-Package
                                                </_removeheaders>
                                        </instructions>
                                </configuration>
                                <executions>
                                        <execution>
                                                <id>generate-manifest</id>
                                                <phase>process-classes</phase>
                                                <goals>
                                                        <goal>manifest</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>
                        <plugin>
                                <artifactId>maven-war-plugin</artifactId>
                                <configuration>
                                        <archive>

<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                                        </archive>
                                </configuration>
                        </plugin>


SO I have my etc/mycnfg.cfg that actually install all the jars and put it in
karaf as bundles, once karaf started they are all being installed and then I
will just have to copy and paste my war file to the deploy folder

but still getting the noclassfound error from one of the dependency

Caused by: java.lang.ClassNotFoundException: <ClassName> not found by
com.XXXX.framework [110]




--
View this message in context: http://karaf.922171.n3.nabble.com/deploying-a-war-with-dependencies-in-bundled-jars-tp4037488p4037544.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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
Hi Achim, Yes I tried to extract my war file and here is the manifest fileMANIFEST.MF

I am invoking that class from my framework, it is defined in provider.jar

Im seeing this in my manifest in export section

version="3.0.1.SNAPSHOT",com.pinsightmedia.adgateway.dsp.a
 dmarvel;uses:="com.amazonaws,com.pinsightmedia.adgateway.dsp,com.pins

but I think not all the class were exported, and in the import section there is no entry on my 3 jars

Thanks
Jeff
Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

Achim Nierbeck
Hi, 

ok the good thing, the manifest is actually one generated by the maven-bundle-plugin and not by the deployer :-)

About the expor/import thing. You'll never see any classes imported/exported only the corresponding Packages. 
If the package you are looking for in the war isn't exported by the bundle you expect it to, you'll need to take a closer look on 
the bundle that actually should export those. 
Might be you have the packages in question marked as private-package, in those cases these packages aren't exported. 

You'll need to dig in that direction now, the consuming part seems to be fixed. 


regards, Achim 

2015-01-05 6:04 GMT+01:00 jefoy1101 <[hidden email]>:
Hi Achim, Yes I tried to extract my war file and here is the manifest file
MANIFEST.MF <http://karaf.922171.n3.nabble.com/file/n4037586/MANIFEST.MF>

I am invoking that class from my framework, it is defined in provider.jar

Im seeing this in my manifest in export section

version="3.0.1.SNAPSHOT",com.pinsightmedia.adgateway.dsp.a
 dmarvel;uses:="com.amazonaws,com.pinsightmedia.adgateway.dsp,com.pins

but I think not all the class were exported, and in the import section there
is no entry on my 3 jars

Thanks
Jeff



--
View this message in context: http://karaf.922171.n3.nabble.com/deploying-a-war-with-dependencies-in-bundled-jars-tp4037488p4037586.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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
Hi Achim, I believe I have the correct import and export but not sure why I'm still having this errors


Errors

domain

framework

provider


I tried to play around with the import/export and look into the it's manifest file

And I think I have the intended jar dependencies in my framework  as it shows in the screenshot

but unfortunately im getting an error attached on one of the amazon library, the aws-java-sdk-1.9.13.jar is already in the ag_lib together with the 3 jars

Thank you in advance for the replies I really appreciate it



Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

Achim Nierbeck
Hi, 

according to the screenshots, the bundles of yours don't export any packages regarding the amazon one. 
So 1) do you have the amazon lib deployed and 2) is it actually exporting the required packages?

regards, Achim 


2015-01-05 23:24 GMT+01:00 jefoy1101 <[hidden email]>:
Hi Achim, I believe I have the correct import and export but not sure why I'm
still having this errors


Errors
<http://i1049.photobucket.com/albums/s385/jefoy1101/error_zps40dbbaab.png>

domain
<http://i1049.photobucket.com/albums/s385/jefoy1101/domain_zps3659e9ee.png>

framework
<http://i1049.photobucket.com/albums/s385/jefoy1101/framework_zps11850cf9.png>

provider
<http://i1049.photobucket.com/albums/s385/jefoy1101/provider_zps3314de97.png>


I tried to play around with the import/export and look into the it's
manifest file

And I think I have the intended jar dependencies in my framework  as it
shows in the screenshot

but unfortunately im getting an error attached on one of the amazon library,
the aws-java-sdk-1.9.13.jar is already in the ag_lib together with the 3
jars

Thank you in advance for the replies I really appreciate it







--
View this message in context: http://karaf.922171.n3.nabble.com/deploying-a-war-with-dependencies-in-bundled-jars-tp4037488p4037614.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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
http://i1049.photobucket.com/albums/s385/jefoy1101/ScreenShot2015-01-05at84406PM_zpsd0695a68.png

1. I have that installed as a bundle from my ag_lib folder using fileinstall config
2. from the screen shot I believe the domain package, dsp, package and the client package is exported




Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

Achim Nierbeck
From the screenshot you've given, those jars aren't OSGi bundles and are auto-wrapped. 
Never the less those auto-wrapped bundles don't export any packages you are looking for so
it looks like this is your root cause. Make sure you have those packages in some way exported. 
For example use the servicemix bundles for aws instead [1]. 

regards, Achim 



2015-01-06 3:43 GMT+01:00 jefoy1101 <[hidden email]>:
http://i1049.photobucket.com/albums/s385/jefoy1101/ScreenShot2015-01-05at84406PM_zpsd0695a68.png
<http://i1049.photobucket.com/albums/s385/jefoy1101/ScreenShot2015-01-05at84406PM_zpsd0695a68.png>

1. I have that installed as a bundle from my ag_lib folder using fileinstall
config
2. from the screen shot I believe the domain package, dsp, package and the
client package is exported








--
View this message in context: http://karaf.922171.n3.nabble.com/deploying-a-war-with-dependencies-in-bundled-jars-tp4037488p4037619.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/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Reply | Threaded
Open this post in threaded view
|

Re: deploying a war with dependencies in bundled jars

jefoy1101
MANIFEST.MF

Hi AChim here is my updated MANIFEST

but I'm still getting this ClassNotFoundException eventhough I already have the jar and the package exported

2015-01-06 11:41:02,402 | ERROR | pool-8-thread-2  | RegisterWebAppVisitorWC          | 91 - org.ops4j.pax.web.pax-web-extender-war - 3.1.2 | Registration exception. Skipping.
java.lang.ClassNotFoundException: com.pinsightmedia.adgateway.framework.AdMarvelPerfFilter not found by com.pinsightmedia.adgateway.framework [158]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)[org.apache.felix.framework-4.2.1.jar:]
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)[org.apache.felix.framework-4.2.1.jar:]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_21]
        at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1844)[org.apache.felix.framework-4.2.1.jar:]
        at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:937)[org.apache.felix.framework-4.2.1.jar:]
        at org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176)[84:org.ops4j.pax.web.pax-web-spi:3.1.2]
        at org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:194)[84:org.ops4j.pax.web.pax-web-spi:3.1.2]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_21]
        at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorHS.loadClass(RegisterWebAppVisitorHS.java:244)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorWC.visit(RegisterWebAppVisitorWC.java:261)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.ops4j.pax.web.extender.war.internal.model.WebApp.accept(WebApp.java:652)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.register(WebAppPublisher.java:237)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:182)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:135)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)[karaf-org.osgi.core.jar:]
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864)[karaf-org.osgi.core.jar:]
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[karaf-org.osgi.core.jar:]
        at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)[karaf-org.osgi.core.jar:]
        at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:317)[karaf-org.osgi.core.jar:]
        at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)[karaf-org.osgi.core.jar:]
        at org.ops4j.pax.web.extender.war.internal.WebAppPublisher.publish(WebAppPublisher.java:101)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.ops4j.pax.web.extender.war.internal.WebObserver.deploy(WebObserver.java:213)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.ops4j.pax.web.extender.war.internal.WebObserver$1.doStart(WebObserver.java:175)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.ops4j.pax.web.extender.war.internal.extender.SimpleExtension.start(SimpleExtension.java:58)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender$1.run(AbstractExtender.java:266)[91:org.ops4j.pax.web.pax-web-extender-war:3.1.2]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_21]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_21]
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_21]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_21]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_21]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_21]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_21]
        at java.lang.Thread.run(Thread.java:722)[:1.7.0_21]
12