• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to build a jar file for use in OSGi environment

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to follow along with the examples in the book Enterprise OSGi In Action by Holly Cummins and Tim Ward.  I have successfully installed and have running the Apache Aries examples download (http://archive.apache.org/dist/aries/samples-1.0.0-source-release.zip).  I want to create a simple jar that contains one servlet class.  The directory structure contains two directories

1) META-INF which contains the MANIFEST.MF
2) WEB-INF which contains web.xml and the compiled simple servlet class

I am using Eclipse IDE for Java Developers Version 2019-03 (4.11.0).  I know that I need to first create a new project.  When I do File->New in the eclipse IDE, I am presented with many options.  I do not know which one to choose so that I can successfully write my tiny servlet class and build the jar.



I want the WEB-INF/web.xml to look like this:



And I want the MANIFEST-MF file to look like this:



I chose the Java Plug-in project for File->New.  I have the following errors in my project that I do not know how to resolve.

Image showing error

Can anyone help me to understand how to create the simple jar and resolve these errors?  Thank you.
 
Saloon Keeper
Posts: 24315
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, a webapp is normally a WAR file, not a JAR. A WAR is a JAR that contains not only the standard JAR components, but also a WEB-INF directory. And, more importantly, has the file extension ".war".

OSGI servers can act as webapp servers, but I haven't looked closely at the details to know how they like their webapps to be packaged. Mostly webapps are deployed to webapp servers, after all.

As far as getting Eclipse to do your packaging, that's a touchy thing. Eclipse is more about editing and debugging code. I use a separate package-building tool such as Ant, Maven, or Gradle. These tools understand how to build complex packages such as JARs, WARs, EARs, and so forth. And you can get Eclipse plugins to run them.
 
Robin Z. Clark
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instructions in the book are very specific about creating this as a .jar file instead of a .war file.  I gave up on using eclipse and just compiled the class at the command line and created a jar.  But when I try to deploy it in the OSGi environment it gives me an error that I don't understand.  Is there a forum group related to OSGi enterprise users where I can post the errors that I am getting?
 
Saloon Keeper
Posts: 7100
165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This forum is appropriate. Post the full error message you got.
 
Tim Holloway
Saloon Keeper
Posts: 24315
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the official docs on webapps in OSGi: https://osgi.org/specification/osgi.cmpn/7.0.0/service.war.html

But we do need the error messages.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic