1 2 3 Previous Next 43 Replies Latest reply on Jul 12, 2010 10:56 AM by dknox Go to original post
      • 15. Re: Mapping HttpService to JBossWeb

        The discussion is internal to the Enterprise OSGi Expert Group (EEG)


        For our purposes the enterprise jar is a superset of the compendium. Specifically, we currently don't need any service APIs from the compendium (on the left) that are not part of enterprise (on the right).





        For your initial HttpService prototype however, you can work with compendium and ignore enterprise for now.



        • 16. Re: Mapping HttpService to JBossWeb

          Hi David,

          David Knox wrote:


          where is that discussion? My searches didn't produce it.  The reason I ask is the contents of osgi.enterprise.jar and osgi.cmpn.jar are not mutually exclusive.  Maybe reading the discussion will help clear this up.



          The discussion is here: https://mail.osgi.org/pipermail/eeg/2010-April/006437.html if you work for a member company you can easily get a username/password and participate!


          Work is currently underway to get the enterprise.jar in maven central.


          WRT to the enterprise jar not being a subset/superset of the compendium jar... It will probably be a subset in the future. The compendium jar contains all the interfaces for all the compendium specifications and the compendium specs are normally all the specifications that aren't in the core - this includes all the enterprise specifications.

          The reason the enterprise specs aren't in the compendium right now is simply because the enterprise release was ready about 6 months after the compendium spec.


          The enterprise.jar and OSGi 4.2 Enterprise Specs are a focused set of specifications aimed at enterprise usage.

          • 17. Re: Mapping HttpService to JBossWeb

            Hi, After a couple of weeks of build magic, I'm able to begin this again.   


            Status: Current code is in http://github.com/jbosgi/jbosgi-http.git

            The code starts a tomcat7 server. I think I'm ready to begin integrating with the osgi framework more completely.


            First, I'm using an ant script to build locally, this was a simple way to start. But now, the build for jbosgi-http should start fitting into the project. I'm not very familiar with maven...  


            I've run mvn install and I can see straight away that the servlet3.0 and tomcat7 libraries need to be added to the pom. The new dependencies need to be in the maven repository, right?

            • 18. Re: Mapping HttpService to JBossWeb

              Hi David,


              The servlet 3.0 API from Sun/Oracle is distributed through CDDL (I think), which might be an issue. You can get an apache licensed version of this from here: http://repo1.maven.org/maven2/org/apache/geronimo/specs


              WRT to Tomcat, I thought 6.0.x was the latest, but I might have missed something there This one is available from here: http://repo1.maven.org/maven2/org/apache/tomcat/


              Since this is the maven central repo, you shouldn't have to do anything special to include them in the build. Just specify the dependencies (the exact groupId/artifactId/version can be found in the poms under the locations above) and maven should pull them in.


              Hope this helps...

              • 19. Re: Mapping HttpService to JBossWeb

                Hi David,

                Initially we wanted to use the Servlet3.0 API to dynamically create servlets and add/remove resources. Tomcat7 is distributed with and uses the Servlet3.0 api.


                I don't have deep knowledge regarding Maven, but maybe I can use a local repository for the tomcat libs.

                • 20. Re: Mapping HttpService to JBossWeb

                  I would always try to use the artefacts from maven central or some other centralized maven repo rather than running your own, if possible. Sure you can use (controlled) mirrors, but if you run your own repo with artefacts that might also exist somewhere else is increases the chance of duplicates appearing in your local .m2 directory or worse, on your build path...

                  • 21. Re: Mapping HttpService to JBossWeb

                    Hi David,

                    Yep, I agree the best option would be to use the artifacts from a centralized and common repo. Whether we do or not includes the question of building on the Servlet 3.0 api. An HttpService can certainly be built on Tomcat6 using the catalina APIs. However, the Servlet 3.0 API does make it easier and cleaner. It was also the decison early in this topic. If the HttpService is built on tomcat6, there are more questions: (1) which tomcat6 distro to use?; (2) which distros are we constrained to by the repo?


                    I'm assuming the best option would constrain things too much, limiting our options, and prefer to stick to tomcat7 with the Servlet3 api.


                    Another option that I think is the most practical: use a basic ant build script for the time being, and integrate with maven later. The maven repo discussion is moot in that case until a later time. 

                    • 22. Re: Mapping HttpService to JBossWeb

                      Hi David,

                      I read you are using Tomcat for this development at the moment. Actually, you must be using the JBoss Web artifact from Maven (see the artifact used in AS). The API is quite similar, if not identical for what you are using, so the transition should be fine.


                      • 23. Re: Mapping HttpService to JBossWeb


                        I've added [1] to the project's pom.xml dependencies. Maven fails during the compile and I learned that jetty is pulling in the earlier 2.5 servlet api while I'm trying to pull in servlet-api-3.0.0-beta-2. We have two servlet specs in the build.


                        I'm not sure how to fix this. If jetty is removed as a dependency there will be problems with org.xml.sax and other packages.  I ran maven -X and confirmed that the libraries for the artifacts in [1] are on the build Classpath.


                        What does [2] do? I ask because I suspect that the javax.servlet package should be moved into <Import-Packages>



                        -- dave


                             [2]    <_exportcontents>
                                      <!-- javax.servlet*;version=2.5,-->


                        Any ideas welcomed.




                        • 24. Re: Mapping HttpService to JBossWeb

                          Hi David,

                          If jetty is pulling in servlet 2.5 and you don't want that, you should be able to disable the transitive dependency by using an exclusion, something like:








                                <artifactId>the unwanted servlet dep</artifactId>

                                <groupId>its group ID</groupId>




                          You can figure out what to exclude by running mvn dependency:tree.


                          <_exportcontents> is used to export a package that is inside en embedded library without copying it to the bundle classes as well. I suspect that the bundle you're building contains the servlet jar inside (or at least did at some point). If you do just Export-Package it will take all the classes from the servlet.jar and copy them to the bundle classes location. <_exportcontents> prevents that duplication while still exporting the packages.

                          For more info see here: http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html


                          If you don't embed the servlet.jar 3.0 you definitely need to import it using <Import-Package>.


                          However if you decide to embed the 3.0 servlet.jar you're making life easier for other people in that they don't have to install that interfaces bundle themselves. In many cases an OSGi HTTP Service implementation embeds this library so that people can simply take the HTTP Service bundle, install it and it works. In this case you should both Import-Package and Export-Package the javax.servlet* packages! While this may sound a bit funny for interfaces packages this is what you should do to maximize the possibility of class-space consistency across bundles if there is another bundle that also exports the same version of javax.servlet*.


                          As an example I'm developing a bundle that implements a servlet, hence I'm implementing javax.servlet.Servlet (directly or indirectly). I can pick up that interface from any bundle that exports it. If your http implementation does not Export-Package javax.servlet I will not be able to load the servlet class from you and hence you won't be able to use my servlet as javax.servlet.Servlet has been loaded from another bundle (even though the class might be identical, you will get a classcastexception). Both exporting and importing a package solves this issues.

                          • 25. Re: Mapping HttpService to JBossWeb


                            I was not able to solve the problem with exclusions. It's possible the groupId and/or artifactId are not correct.



                            Export-Package and Import-Package includes the jbossweb packages. The packages are also Embedded-Dependency-s.


                            There is a work-around for the time being: by changing the order of the dependencies and putting the jbossweb packages before the jetty package which changes the order of jars in the build classpath. The changes have been checked in. I attached the bundle/pom.xml here for convenience.


                            Next week I'll work on fixing the junit test.

                            • 26. Re: Mapping HttpService to JBossWeb

                              Just curious, what is the output of mvn dependency:tree?

                              • 27. Re: Mapping HttpService to JBossWeb

                                Hi David,

                                The output is posted below. A synopsis: By changing the order in the dependency tree, i.e. placing the jbossweb-3.0-beta2 dependency before the jetty dependency, the build works. If the jetty dependency is placed before jbossweb in the dependencies, the build fails because the servlet 2.5 lib is included in jetty (org.ops4j.pax.web:pax-web-jetty-bundle:jar). The exact error is a "symbol not found" on javax.servlet.ServletContext.


                                I put two exclusions in the jetty dependency. It appears that the jasper exclusion is working because those classes aren't in pax-web-jetty-bundle-0.7.2.jar. The servlet-api exclusion isn't working. The javax.servlet classes are in pax-web-jetty-bundle-0.7.2.jar



                                [dknox@localhost jbosgi-http-git]$ cd bundle
                                [dknox@localhost bundle]$ ~/bin/apache-maven-2.2.1/bin/mvn dependency:tree
                                [INFO] Scanning for projects...
                                [INFO] Searching repository for plugin with prefix: 'dependency'.
                                [INFO] ------------------------------------------------------------------------
                                [INFO] Building JBossOSGi Http Bundle
                                [INFO]    task-segment: [dependency:tree]
                                [INFO] ------------------------------------------------------------------------
                                [INFO] [dependency:tree {execution: default-cli}]
                                [INFO] org.jboss.osgi.http:jboss-osgi-http:bundle:1.0.0-SNAPSHOT
                                [INFO] +- org.jboss.osgi:jboss-osgi-spi:jar:1.0.7-SNAPSHOT:compile
                                [INFO] |  +- args4j:args4j:jar:2.0.12:compile
                                [INFO] |  +- org.jboss.logging:jboss-logging-spi:jar:2.1.0.GA:compile
                                [INFO] |  +- org.jboss.osgi.jmx:jboss-osgi-jmx-api:jar:1.0.5:compile
                                [INFO] |  |  \- org.apache.aries.jmx:org.apache.aries.jmx.api:jar:0.1-incubating-20100329:compile
                                [INFO] |  +- org.jboss.osgi.vfs:jboss-osgi-vfs:jar:1.0.0:compile
                                [INFO] |  +- org.jboss.shrinkwrap:shrinkwrap-impl-base:jar:1.0.0-alpha-7:compile
                                [INFO] |  |  +- org.jboss.shrinkwrap:shrinkwrap-api:jar:1.0.0-alpha-7:compile
                                [INFO] |  |  \- org.jboss.shrinkwrap:shrinkwrap-spi:jar:1.0.0-alpha-7:compile
                                [INFO] |  \- junit:junit:jar:4.6:compile
                                [INFO] +- jboss.web:el-api:jar:3.0.0-beta-2:compile
                                [INFO] +- jboss.web:jasper-jdt:jar:3.0.0-beta-2:compile
                                [INFO] +- jboss.web:jbossweb:jar:3.0.0-beta-2:compile
                                [INFO] +- jboss.web:jsp-api:jar:3.0.0-beta-2:compile
                                [INFO] +- jboss.web:servlet-api:jar:3.0.0-beta-2:compile
                                [INFO] +- org.ops4j.pax.web:pax-web-jetty-bundle:jar:0.7.2:compile
                                [INFO] +- org.osgi:org.osgi.core:jar:4.2.0:provided
                                [INFO] \- org.osgi:org.osgi.compendium:jar:4.2.0:provided
                                [INFO] ------------------------------------------------------------------------
                                [INFO] BUILD SUCCESSFUL
                                [INFO] ----------------------------------------------------------


                                • 28. Re: Mapping HttpService to JBossWeb

                                  I was able to find more by running mvn -X install. I don't know enough about maven yet to figure it out but, there's enough to google on though. I posted a few of the details below. Question: It seems awkward to me that we are importing jetty into our own httpservice. JBossWeb provides javax.servlet, jasper, etc. and jmx is part and parcel of jdk1.6. Would it be practical to jettison jetty?




                                  The first sign of a problem is:


                                  [WARNING] Warning building bundle org.jboss.osgi.http:jboss-osgi-http:bundle:1.0.0-SNAPSHOT : Split package javax/servlet
                                  Use directive -split-package:=(merge-first|merge-last|error|first) on Export/Private Package instruction to get rid of this warning
                                  Package found in   [Jar:jsp-api, Jar:servlet-api, Jar:pax-web-jetty-bundle]
                                  Reference from     /home/dknox/.m2/repository/org/ops4j/pax/web/pax-web-jetty-bundle/0.7.2/pax-web-jetty-bundle-0.7.2.jar
                                  Classpath          [Jar:., Jar:jboss-osgi-spi, Jar:args4j, Jar:jboss-logging-spi, Jar:jboss-osgi-jmx-api, Jar:org.apache.aries.jmx.api, Jar:jboss-osgi-vfs, Jar:shrinkwrap-impl-base, Jar:shrinkwrap-api, Jar:shrinkwrap-spi, Jar:junit, Jar:el-api, Jar:jasper-jdt, Jar:jbossweb, Jar:jsp-api, Jar:servlet-api, Jar:pax-web-jetty-bundle, Jar:org.osgi.core, Jar:org.osgi.compendium]


                                  The fatal bit is:

                                  [WARNING] Warning building bundle org.jboss.osgi.http:jboss-osgi-http:bundle:1.0.0-SNAPSHOT : Superfluous export-package instructions: [javax.servlet*, org.apache.catalina*, org.apache.el*, org.apache.jasper*, org.apache.cometd*, org.jboss.web*, org.apache.coyote*, org.apache.tomcat*]
                                  [ERROR] Error building bundle org.jboss.osgi.http:jboss-osgi-http:bundle:1.0.0-SNAPSHOT : Unresolved references to [javax.annotation, javax.annotation.security, javax.ejb, javax.el,......

                                  • 29. Re: Mapping HttpService to JBossWeb

                                    I've worked out the error and warnings. I don't think this solves the collision with jetty. Both mvn install and mvn compile are working. The plan this week is to work on mvn test and get that working.





                                    changed Embed-Dependency to -



                                    <_exportcontents> contains only javax.servlet*;version=3.0.0-beta-2,


                                    The JBossWeb and Tomcat classes are included in <Import-Package> as is javax.servlet.*