sobota 1. února 2014

@Focus annotated method raised before @PostConstruct method

I had a problem with my application today. NPE occured in @Focus annotated method on one of my parts. I found out that @PostConstruct annotated method wasn't called at all. It was caused by wrong imported package javax.inject. Obviously there is one such package contained in JRE/JDK so you need to import bundled one. The difference is in min. version. Example of wrong and correct configuration can be seen below:
Correct configuration
Wrong configuration


pondělí 27. ledna 2014

"Profile id _SELF_ is not registered" error

Following error occurred when I exported product which was trying to install new bundles from the repository:
java.lang.IllegalArgumentException: Profile id _SELF_ is not registered.
 at org.eclipse.equinox.internal.p2.director.ProfileChangeRequest.createByProfileId(ProfileChangeRequest.java:47)
 at org.eclipse.equinox.p2.operations.InstallOperation.computeProfileChangeRequest(InstallOperation.java:74)
 at org.eclipse.equinox.p2.operations.ProfileChangeOperation.makeResolveJob(ProfileChangeOperation.java:165)
 at org.eclipse.equinox.p2.operations.ProfileChangeOperation.resolveModal(ProfileChangeOperation.java:113)
 at com.example.e4.rcp.todo.handlers.InstallHandler$1.run(InstallHandler.java:93)
 at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
It is working when I try to run the example in Eclipse IDE but after the product is exported, this exception is thrown.
Solution (working for me):

  • it is enough to create also p2 repository for the product

sobota 25. ledna 2014

Installing and starting bundles in OSGI on windows

In most tutorials, you can find that similar to the following command for installing new bundles should work:

osgi>install file:c:\temp\bundles\plugins\org.eclipse.equinox.ds.jar

But when I tried this, I encountered the error: gogo: BundleException: An error occurred trying to read the bundle

So in such case, the following change helped me:
osgi>install file:c:///Temp//bundles//plugins//org.eclipse.equinox.ds.jar

Original command will work on Linux system.

pátek 24. ledna 2014

Running OSGI console

Necessary plugins to run console for org.eclipse.osgi_<version>.jar:

Since equinox 3.8, following bundles are needed to be loaded for running osgi console:

  • org.apache.felix.gogo.command_0.8.0v<version>.jar
  • org.apache.felix.gogo.runtime_0.8.0v<version>.jar
  • org.apache.felix.gogo.shell_0.8.0v<version>.jar
  • org.eclipse.equinox.console_1.0.0v<version>.jar

It is enough to use configuration file for OSGI:

  • copy files mentioned above from your eclipse installation/plugins folder to the folder with osgi bundle
  • create file "configuration\config.ini" in the folder where the osgi JAR file is placed
  • insert following context to the file (replace file names with the real names or rename jar files):
osgi.bundles=org.eclipse.equinox.console.jar@start,org.apache.felix.gogo.command.jar@start,org.apache.felix.gogo.runtime.jar@start,org.apache.felix.gogo.shell.jar@start
Now you can test the OSGI console with:

  •  java -jar org.eclipse.osgi_<version>.jar -console

Sources:
org.osgi.framework.BundleException: Could not find bundle: org.eclipse.equinox.console