Wednesday, 11. October 2006

hacking for nepomuk: getting SOAP to run in Eclipse's OSGI

We are building the desktop semantic web server for Nepomuk at the moment, and I had a look how to use OSGI to start Java services as SOAP services.

At the end, we will start a RDF database, some ontology matchers, text indexing, Data Crawling (Aperture and Beagle++) and many other things using this code, so wait a little and you get a really cool Semantic Desktop platform. If everything works fine, it should be cooler than gnowsis ;-)

The code will be open-source in December or January, but if you are really interested, I may bundle this as a zipfile for you (its not Nepomuk relevant, its only a hassle with Eclipse)

UPDATE (12.10.2006): Below oddysee is really odd, today Christopher Tuot informed me where the compiled bundles of knopflerfish are, the are in knopflerfish.org\osgi\jars\axis-osgi\axis-osgi_all-0.1.0.jar, I saw them but didn't realize they were bundles. So if I just imported this bundle to the Eclipse plugins, it would have worked probably within one hour. Although I still don't know how to add these precompiled bundles to a developing project like we have.

here is my oddysee:

Running SOAP services from OSGI

_The plan was to run SOAP services from OSGI, as announced:_

  • use Tomcat as webserver (a http server) on port X
  • wrap Tomcat as OSGI service (done already by eclipse)
  • start services as web-applications (done by tomcat)
  • let components (excample: comp-rdfdatabase) start inside this VM and register objects as services: the component registers a web-service (SOAP server object) using AXIS

Mikhail has already submitted some service for points one and two - this package might help me:
https://dev.nepomuk.semanticdesktop.org/browser/trunk/java/org.ungoverned.osgi.bundle.http

_Result: It works, checkout the newest NEPOMUK from https://dev.nepomuk.semanticdesktop.org/repos/trunk/java/_

It took me exactly three hours, here is the steps I took.

Step: read the documentation provided by Christopher Tuot.

good to read, sounds exactly what we need.

  • publish SOAP services
  • use SOAP services as client
  • create WSDL files

Step: checkout the SVN sources using eclipse from the SVN

ha - the SVN is exactly where the doc came from, thats easy:

I decide to checkout the whole SOAP branch somewhere to my disk, outside eclipse. I go for the whole package, because there is an ANT file inside the parent folder of the sub-packages, which seems to indicate that they all belong together.

svn checkout https://www.knopflerfish.org/svn/knopflerfish.org/trunk/osgi/bundles_opt/soap

its 5.81 MB, 195 files, thats nothing.

Step: Legal Check - is the license ok?

at this point, I check if Knoplerfish has a compatible license - they use BSD, ok, no problem here.

Step: look inside axis-osgi

  • this package contains AXIS and WSDL stuff, very small, neat.
  • the bundle.manifest doesn't require that many knoplerfish things. These two sound bad:
    • Import-Package:
    • org.knopflerfish.service.log,
    • org.knopflerfish.service.axis,

Step: import to eclipse/Nepomuk

I try to run the build.xml in the main soap dir. Fails, it needs the other knoplerfish dependencies "commons-logging"
  • I decide to ignore this and try to import it myself using eclipse.
  • I think again and checkout commons-logging from knoplerfish
  • 68kb, 29 files. nothing.
  • ok, now I have to stop: "java.io.FileNotFoundException: C:\ant\bundlebuild_include.xml (Das System kann den angegebenen Pfad nicht finden)" - the thingy seems to have weird dependencies. But wait, perhaps it just needs all of knoplerfish
  • I download the latest knopflerfish source distro, to get this running quicker (doing this via SVN may cause heavy server load for these guys, I avoid it)
  • At this moment, I notice I downloaded OSGI Knopflerfish already on 27.10.2005, when Mikhail Kotelnikov and I first talked about OSGI :-)
    • I delete my old knopflerfish 1.3.4 and replace it with the newer 2.0
  • I notice they did not include the optional bundles (where SOAP is in) and I move my previously checkout of SVN to the right place. knopflerfish.org\osgi\bundles_opt
  • ANT still fails - BCEL misses. They said I needed it, but never trust them. Downloading BCEL.
  • OK - knopflerfish compiles: knopflerfish.org\osgi\bundles_opt\soap>ant
    • BUILD SUCCESSFUL
    • Total time: 19 seconds
  • The generated output is in knopflerfish.org\osgi\out and knopflerfish.org\osgi\out\jars

PROBLEMS ok, after all this rubble, I go for Graphical user interface and just start knopflerfish to start the HTTP services using Knopflerfish. Ok, this works and I can install HTTP and AXXIS using some clicks on bundles there: knopflerfish.org\osgi>java -jar framework.jar

Step: rethink how to get Knopflerfish stuff working in Eclipse

All that hassle says: someone did this before.

I decide to make new plugins for Eclipse OSGI, using the Eclipse IDE, and copy the sources and manifest files from knopflerfish.

at this point, I realise, that the Knopflerfish people use Eclipse to code Knopflerfish, so I install the Eclipse IDE plugin to see what it can do for me:

Revelation: all this Knopflerfish testing was useless

but I learned a lot.

I found no straightforward way to compile Knopflerfish into plugins that can be used conveniently from inside eclipse, so I just take the sourcecode of the plugins and make new Eclipse plugins from that, copying the Manifest files into the Eclipse manifests.

  • I copy the code now
  • this took me about 30 minutes, but surely was quicker than all above.
  • if knopflerfish has great new stuff, we cannot easily put it into Nepomuk, until someone finds a way to bundle their bundles as plugins for equinox/eclipse. but 30 minutes effort is affordable.

Step: finishing this and starting a soap service

Ok, until now I have these OSGI bundles in my eclipse:
  • the SOAP service in org.knopflerfish.bundle.axis-soap
  • the log service in org.knopflerfish.log
  • the rdfrepository in org.semanticdesktop.nepomuk.comp.rdfrepository

All of them seem to work, I only get one nullpointerexception when starting the axis-soap:

java.lang.NullPointerException
	at org.knopflerfish.bundle.axis.Activator.setupAxis(Activator.java:109)
This is easy, he wants to find the AXIS configuration in resource resources/axis/server-config.wsdd

I add this to the build.properties of the soap bundle, using the classy graphical editor of Eclipse, rocks.

bin.includes = META-INF/,\
...
resources/axis/

It seems the Eclipse building works differently from the Knopflerfish building process, so I move the contents of resources to the root of the plug-in, most important the resources/axis/.. is now axis/....

  • this makes the product not start, OSGI does not even show the console. We had this before. I delete the "run..." config for the product and start again, ok it starts.
  • now it doesn't start because commons-logging misses, I notice that we probably have the commons logger already in Mikhail's logging plugin and faithfully delete this plugin dependency from
  • start/stop

Step: Commit all to SVN

  • I commit the knopflerfish wrapped packages to our Nepomuk SVN. We can fix this later (tm)
  • I also updated the server product and the server app to start SOAP now

_DONE: We can start Java objects as SOAP services_
Go here to see the started SOAP services:

Go here to see the automatically created WSDL files for out example RDF repository component:

Summary

All in all this took three hours. It was hard, but not impossible. I would recon that it proves that our SOAP in OSGI approach can rock so hard the keyboards will fly. No guarantee that everything will workout, but this is the only code you have to write to start a SOAP service now:

// inside your Bundle Activator

 public void start(BundleContext context) throws Exception {
    // assume RDFRepositoryImpl is your Java Object that should be accessible via SOAP
    ServiceReference srRA = registerObject("remoteFW", new RDFRepositoryImpl(context));
 }

 private ServiceReference registerObject(String name, Object obj) {
    Hashtable ht = new Hashtable();     
    ht.put("SOAP.service.name", name);
    return (context.registerService(obj.getClass().getName(), obj, ht)).getReference();
 }

QR barcode by i-nigma.com/CreateBarcodes
aldo (guest) - 20. Apr, 11:05

where can i find the jar file of eclipse/axis?

ue (guest) - 27. Apr, 08:40

i have used axis bundles from knopflerfish, the web service works!

can anyone tell me how can i create a web service client as bundle? i dont know how can i begin with it...
leobard - 1. May, 15:23

no idea

sorry, have no idea about the client approach

george22 - 1. Dec, 07:57

[ tip ] Help soothe separation and stranger anxiety by giving baby time to get comfortable around new people before actually letting them hold her. It's easier for her to warm up to new people once they've smiled at her, talked to her, and simply been nearby for a little while.fitted leather jacket classic leather jacket big and tall leather jackets trench coat trenchcoat winter jackets quilted jacket leather coats

icon

semantic weltbild 2.0

Building the Semantic Web is easier together

and then...

foaf explorer
foaf

Geo Visitors Map
I am a hard bloggin' scientist. Read the Manifesto.
www.flickr.com
lebard's photos More of lebard's photos
Skype Me™!

Search

 

Users Status

You are not logged in.

I support

Wikipedia Affiliate Button

Archive

October 2006
Sun
Mon
Tue
Wed
Thu
Fri
Sat
 1 
 2 
 3 
 4 
 8 
10
15
16
21
22
24
25
26
27
29
31
 
 
 
 
 

Credits


austriaca
Chucknorrism
digitalcouch
gnowsis
Jesus
NeueHeimat
route planning
SemWeb
travel
zoot
Profil
Logout
Subscribe Weblog