Donnerstag, 28. Februar 2013

Error: type ServiceReference does not take parameters

When developing for an OSGi environment and especially when using Apache Felix derived projects, one may run into a strange error. It is strange, because inside Eclipse no errors are shown, but when using the Java compiler (javac), it complains like so:

[javac] .../Activator.java:53: error: type ServiceRegistration does not take parameters [javac] ServiceRegistration svcReg;

A couple of circumstances need to exist to trigger this error:

  • JDK7 is used
  • Apache Felix 4.0.2 or 4.0.3 is used
  • javac is used to compile the project

OSGi code is compiled with the -jsr14 option and that leads to problems with the JDK7 compiler. The Eclipse JDT compiler compiles it well, and therefore there is no error when building only in Eclipse.

There are updated OSGi jars available now which fix this problem (and one doesn't need to recompile). These are org.osgi.core-4.3.1.jar and org.osgi.compendium-4.3.1.jar. They are on OSGi's site or on the maven sites. (See below)

My fix for an earlier project was to build the OSGi sources (org.osgi.* packages) with JDK7 and put them before the Felix jars in the classpath. This makes the new OSGi class files being used instead of the ones which are packaged with the Felix jars.

Resources

1 Kommentar:

  1. Ich habe nicht ein solches Problem auftreten. Aber ich möchte Sie mit Lösungen für das Problem DLL-Dateien zu helfen. Hier ist ein Link, wo Sie sie einfach herunterladen können http://de.fix4dll.com/ . Vielen Dank für Ihre Aufmerksamkeit.

    AntwortenLöschen