.bnd files have errors when building in IntelliJ - java

When I'm building my project in IntelliJ, I get errors for each of my .bnd files (I have no other types of errors).
I started working on a new project which works without any problems for my colleagues (which are too busy to help me do the setup).
What I've done so far:
- got the code and imported it as a maven project in IntelliJ (no errors)
- clean installed it from terminal (no errors)
- build the project from IntelliJ (425 errors - around 2 per .bnd file)
- I tried disabling the OSGi plugins (dmServerSupport and Spring OSGi)
- I tried disabling the Inspection OSGi profile
- I tried adding the file in the Compiler -> Excludes (still builds it)
What can I do to get rid of all those errors?
My OSGi Manifest (from looks like this:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Goodies
Bundle-SymbolicName: com.....osgi.goodies
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: ...
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: org.osgi.framework;version="1.7.0",
org.osgi.service.component.annotations;version="1.2.0",
org.osgi.service.event;version="1.3.0",
org.osgi.service.packageadmin;version="1.2.0"
For example, I have this .bnd file:
-classpath: target/classes
-dsannotations: *
Include-Resource: README.HTML
Private-Package: com.....pubsub.impl
Export-Package: com.....pubsub
-dsannotations: *
For the file from above, I'm getting the following errors:
Error:osgi: [pubsub] Invalid Manifest header: -classpath, pattern=[A-Za-z0-9][-a-zA-Z0-9_]+
Error:osgi: [pubsub] Invalid Manifest header: -dsannotations, pattern=[A-Za-z0-9][-a-zA-Z0-9_]+
Another example:
-classpath: target/classes
-dsannotations: *
Include-Resource: README.HTML
Private-Package: com.....security.thread.impl
Export-Package: com.....security.thread
Import-Package: oracle.jdbc;version=0,\
*
Building the project containing the .bnd file from above, will result in the following error:
Error:osgi: [security.thread] Exception: java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:406)
at java.util.jar.Manifest.read(Manifest.java:199)
at java.util.jar.Manifest.<init>(Manifest.java:69)
at aQute.bnd.osgi.Builder.build(Builder.java:116)
at org.jetbrains.osgi.jps.build.BndWrapper.doBuild(BndWrapper.java:262)
at org.jetbrains.osgi.jps.build.BndWrapper.build(BndWrapper.java:192)
at org.jetbrains.osgi.jps.build.OsgiBuildSession.doBuild(OsgiBuildSession.java:211)
at org.jetbrains.osgi.jps.build.OsgiBuildSession.build(OsgiBuildSession.java:79)
at org.jetbrains.osgi.jps.build.OsmorcBuilder.build(OsmorcBuilder.java:54)
at org.jetbrains.osgi.jps.build.OsmorcBuilder.build(OsmorcBuilder.java:33)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTarget(IncProjectBuilder.java:1023)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1004)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1065)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:956)
at org.jetbrains.jps.incremental.IncProjectBuilder.access$500(IncProjectBuilder.java:73)
at org.jetbrains.jps.incremental.IncProjectBuilder$BuildParallelizer.lambda$queueTask$0(IncProjectBuilder.java:927)

Related

Eclipse RCP: Missing required plug-in during export

When I try to export my Eclipse RCP product, I received the following error:
Processing inclusion from feature org.eclipse.pde.container.feature: Bundle org.apache.batik.dom.svg_1.6.0.v200805290154 failed to resolve.:
Missing required plug-in org.apache.batik.css_0.0.0.
Missing required plug-in org.apache.batik.dom_0.0.0.
Missing required plug-in org.apache.batik.parser_0.0.0.
Missing required plug-in org.apache.batik.util_0.0.0.
Missing required plug-in org.w3c.css.sac_0.0.0.
Missing required plug-in org.w3c.dom.smil_0.0.0.
Missing required plug-in org.w3c.dom.svg_0.0.0.
I already tried to follow the answer from this question; but it didn't work.
The required bundle inside MANIFEST.MF of the plugin org.apache.batik.dom.svg which cause the error are:
Bundle-SymbolicName: org.apache.batik.dom.svg
Require-Bundle: org.apache.batik.css;version="[1.6.0,1.7.0)",
org.apache.batik.dom;version="[1.6.0,1.7.0)",
org.apache.batik.parser;version=" [1.6.0,1.7.0)",
org.apache.batik.util;version="[1.6.0,1.7.0)",
org.w3c.css.sac;version="[1.3.0,1.4.0)",
org.w3c.dom.smil;version="[1.0.0,1.1.0)",
org.w3c.dom.svg;version="[1.1.0,1.3.0)"
Export-Package: org.apache.batik.dom.svg;version="1.6.0",
org.apache.ba tik.dom.svg12;version="1.6.0"
Bundle-Version: 1.6.0.v200805290154
Can someone help me with this error?

NoClassDefFoundError in jackcess

I am working on an RCP application which is based on eclipse plugins. In one of my plugin project I add another plugin project as dependency. Let say Project A has Project B as a dependency defined under its manifest. Project B contains jackcess.jar file as referenced library.
In Project B I have a class called Mirror.java
public Mirror(String source, String template, String target) throws SQLException, IOException {
this.sourceString=source;
this.templateFileString=template;
this.targetFileString=target;
}
inside from project A when I try to create an object of class Mirror
Mirror m = new Mirror(connectionString, "EABase_JET4_empty.eap",platformDB.getAbsolutePath());
I get the following error
java.lang.NoClassDefFoundError:
com/healthmarketscience/jackcess/ImportFilter
build.properties of Project B (containing jackcess.jar)
bin.includes = META-INF/,\
src/main/resources/lib/jackcess-1.2.6.af3.jar
The MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MirrorDbToEap
Bundle-SymbolicName: MirrorDbToEap
Bundle-Version: 1.0.0
Export-Package: .,
com.example.jetdb.mirror
Require-Bundle: CommonsIo;bundle-version="2.0.0",
org.apache.commons.lang;bundle-version="2.6.0",
org.apache.commons.logging;bundle-version="1.0.4"
Anyone having any idea what's going wrong here?
Thanks
You are not including the jackcess.jar in the bin.includes in the build.properties file so it is not being included in the RCP build.
Open the build.properties editor and select the jar in the 'Binary Build' selection.
The jar must also appear in the Bundle-ClassPath in the MANIFEST.MF. In the manifest editor in the Runtime tab add the jar to the 'Classpath' section (you should also have '.' for normal plugin code).
It seems the class which is available in compile time, is not available in run time.

Osgi java.lang.NoClassDefFoundError when trying to retrieve a service from another bundle

So, let's see, I have three bundles: Provider interface, Provider implementation and Client.
Everything is running smoothly on Eclipse, but when I export the bundles and run em, the following error appears when I try to retrieve the Provider Service:
java.lang.NoClassDefFoundError: provider/providerinterface/ProviderService
The interface is exporting his package, so there should be no errors with that. Alongside, Client is also importing the providerInterface package in its manifest.
The .jar of the Provider interface bundle does have the ProviderService class inside, so there are no error exporting either.
Provider Interface's manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: IMA_Provider
Bundle-SymbolicName: IMA_Provider
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: provider.providerinterface
Client's manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MAClient
Bundle-SymbolicName: MA_Client
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: provider.providerinterface,
org.osgi.framework;version="1.3.0",
org.osgi.util.tracker;version="1.4.2"
Provider and Client are just symbolic names, the "Client" bundle imports and uses a lot of other classes from many other bundles with no errors whatsoever. Anyway, I'm getting stuck with this one, and I can't find any reason.
Any help?
Usually there is something wrong with the build.properties file, causing the bundles to miss the actual class files. This does not matter when running directly from Eclipse, but it does matter when you export the bundles using PDE.
Things to check:
Are the classfiles really in the bundles? When checking the bundle, you should have at least at toplevel a provider/ folder and a META-INF/ folder
the build.properties file should look something like:
output.. = bin/
source.. = src/
bin.includes = META-INF/,.
Good luck, Frank
I was finally able to solve this.
There were no issues with the Manifest files or the build.properties, this was a constructor problem.
The MA_Provider implementation was lacking a void constructor; Once I added this
public ProviderImpl(){}
on the implementation class of the ProviderInterface, the OSGi bundles were able to retrieve the service.

Avoid confliction of same packages in two diffrent jars

I developed an OSGI bundle for five jars
poi-3.9 - bundle name:- org.apache.poi
poi-ooxml-3.9- bundle name:- org.apache.poi.ooxml
poi-ooxml-schemas
dom4j
xmlbeans
but when i use these jars it will give an error
NoClassDef found
org.apache.poi.ss.usermodel.WorkbookFactory
Then i realized some packages (like org.apache.poi.ss.usermodel) in
poi-3.9
poi-ooxml-3.9 jars are same
then i use
Require-Bundle:
org.apache.poi;visibility:=reexport,
org.apache.poi.ooxml;visibility:=reexport
It will give an same error
What can I do to resolve this problem
Manifest File
Bundle-ManifestVersion: 1
Bundle-Name: poi
Bundle-SymbolicName: org.apache.poi
Bundle-Version: 3.9
Bundle-Vendor: XYZ
Bundle-Localization: plugin
Import-Package: org.apache.poi.ss.usermodel
Export-Package: org.apache.poi,
org.apache.poi.common.usermodel,
org.apache.poi.ddf,
org.apache.poi.dev,
org.apache.poi.hpsf,
org.apache.poi.hpsf.extractor,
org.apache.poi.hpsf.wellknown,
org.apache.poi.hssf,
org.apache.poi.hssf.dev,
org.apache.poi.hssf.eventmodel,
org.apache.poi.hssf.eventusermodel,
org.apache.poi.hssf.eventusermodel.dummyrecord,
org.apache.poi.hssf.extractor,
org.apache.poi.hssf.model,
org.apache.poi.hssf.record,
org.apache.poi.hssf.record.aggregates,
org.apache.poi.hssf.record.cf,
org.apache.poi.hssf.record.chart,
org.apache.poi.hssf.record.common,
org.apache.poi.hssf.record.cont,
org.apache.poi.hssf.record.crypto,
org.apache.poi.hssf.record.pivottable,
org.apache.poi.hssf.usermodel,
org.apache.poi.hssf.util,
org.apache.poi.poifs.common,
org.apache.poi.poifs.crypt,
org.apache.poi.poifs.dev,
org.apache.poi.poifs.eventfilesystem,
org.apache.poi.poifs.filesystem,
org.apache.poi.poifs.nio,
org.apache.poi.poifs.property,
org.apache.poi.poifs.storage,
org.apache.poi.ss,
org.apache.poi.ss.extractor,
org.apache.poi.ss.format,
org.apache.poi.ss.formula,
org.apache.poi.ss.formula.atp,
org.apache.poi.ss.formula.constant,
org.apache.poi.ss.formula.eval,
org.apache.poi.ss.formula.eval.forked,
org.apache.poi.ss.formula.function,
org.apache.poi.ss.formula.functions,
org.apache.poi.ss.formula.ptg,
org.apache.poi.ss.formula.udf,
org.apache.poi.ss.usermodel,
org.apache.poi.ss.usermodel.charts,
org.apache.poi.ss.util,
org.apache.poi.ss.util.cellwalk,`enter code here`
org.apache.poi.util
Second Manifest
Bundle-ManifestVersion: 1
Bundle-Name: poi.ooxml
Bundle-SymbolicName: org.apache.poi.ooxml
Bundle-Version: 3.9
Bundle-Vendor: xyz
Bundle-Localization: plugin
Require-Bundle: org.apache.poi.ooxml.schemas,
org.apache.poi.dom4j,
org.apache.poi.xmlbeans
Import-Package: org.apache.poi.ss.usermodel
Export-Package: org.apache.poi,
org.apache.poi.dev,
org.apache.poi.extractor,
org.apache.poi.openxml4j.exceptions,
org.apache.poi.openxml4j.opc,
org.apache.poi.openxml4j.opc.internal,
org.apache.poi.openxml4j.opc.internal.marshallers,
org.apache.poi.openxml4j.opc.internal.signature,
org.apache.poi.openxml4j.opc.internal.unmarshallers,
org.apache.poi.openxml4j.opc.signature,
org.apache.poi.openxml4j.util,
org.apache.poi.ss.usermodel,
org.apache.poi.util,
org.apache.poi.xslf,
org.apache.poi.xslf.extractor,
org.apache.poi.xslf.model,
org.apache.poi.xslf.model.geom,
org.apache.poi.xslf.usermodel,
org.apache.poi.xslf.util,
org.apache.poi.xssf.dev,
org.apache.poi.xssf.eventusermodel,
org.apache.poi.xssf.extractor,
org.apache.poi.xssf.model,
org.apache.poi.xssf.streaming,
org.apache.poi.xssf.usermodel,
org.apache.poi.xssf.usermodel.charts,
org.apache.poi.xssf.usermodel.extensions,
org.apache.poi.xssf.usermodel.helpers,
org.apache.poi.xssf.util,
org.apache.poi.xwpf.extractor,
org.apache.poi.xwpf.model,
org.apache.poi.xwpf.usermodel
First of all: do you really need to convert the poi jars into bundles? If you use the code from only one other bundle, it may be wise to just include the jars into that bundle and adapt the bundle class path accordingly. This may save you a lot of problems, especially if you are not very familiar with converting existing jars to OSGi bundles.
I had a quick look at the poi distribution and the packages may be named the same, but the contents are not the same (split packages). This means that the simplest option here is to create a new bundle jar including all the classes from the poi and poi-ooxml jars from the distribution. Then export all packages from that bundle using the Export-Package header.

The bundle XYZ could not resolved. Reason: Missing Constraint: Import-Package: ABC; version="1.0.0" error in headless RCP standalone

I'm working on standalone headless RCP. It works without problem when I execute the application and product in eclipse IDE, but when I export and execute it, I got this error in the log file.
!ENTRY org.eclipse.equinox.ds 4 0 2013-01-16 13:27:59.132
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.ds_1.4.0.v20120522-1841 [3]" could not be resolved. Reason: Missing Constraint: Import-Package: org.eclipse.equinox.internal.util.event; version="1.0.0"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)
...
!ENTRY org.eclipse.equinox.ds 4 0 2013-01-16 13:28:00.901
!MESSAGE [SCR] Exception while activating instance org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngineManager#6b8d6157 of component org.eclipse.e4.ui.css.swt.theme
!STACK 0
java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Display
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
Referring from this post, I understand that I've got a newer version of a plug-in without its dependencies, and there is something wrong in the runtime path. However, I'm not sure exactly what might cause this error.
What might be wrong? Why I have this error only when I execute it as standalone?
ADDED
I have build.properties file
output.. = bin/
bin.includes = META-INF/,\
plugin.xml,\
.
source.. = src/
This is MANIFEST.MF file
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Refactorer
Bundle-SymbolicName: edu.utexas.seal.refactorer;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: edu.utexas.seal.refactorer.Activator
Bundle-Vendor: PROSSEEK
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
org.eclipse.jdt;bundle-version="3.8.0",
org.eclipse.jdt.core;bundle-version="3.8.2",
org.eclipse.core.resources;bundle-version="3.8.1",
org.eclipse.text;bundle-version="3.5.200",
org.eclipse.jdt.ui;bundle-version="3.8.1",
org.eclipse.jdt.core.manipulation;bundle-version="1.5.0",
org.eclipse.ltk.ui.refactoring;bundle-version="3.7.0",
org.eclipse.jdt.core.manipulation;bundle-version="1.5.0",
org.eclipse.ltk.core.refactoring;bundle-version="3.6.0",
org.eclipse.jface.text;bundle-version="3.8.1",
org.eclipse.core.expressions;bundle-version="3.4.401",
org.eclipse.core.externaltools;bundle-version="1.0.100",
org.eclipse.jface;bundle-version="3.8.101",
edu.utexas.seal.utilities;bundle-version="1.0.0",
org.eclipse.core.filebuffers;bundle-version="3.5.200"
Bundle-ClassPath: .
Export-Package: edu.utexas.seal.refactorer
I have only one item: "." in Bundle-ClassPath.
Missing org.eclipse.equinox.util
I recompiled the project first, and then checked I have all the required plugins from the complaints in the log file, and then I found that I was missing the org.eclipse.equinox.util, I guess it should have been included automatically. After the including, some of the errors are just gone and I found that I have two more errors.
The execution environment issue
I setup the "Execution Environment" as JavaSE-1.5, and this was an issue as the Java couldn't recognize #Override to cause the 'Must Override a Superclass Method' errors.
I got a hint from this site.
'Must Override a Superclass Method' Errors after importing a project into Eclipse
Runtime level
I also had to change the /ECLIPSE/configuration/config.ini file.
osgi.bundles=org.eclipse.equinox.common#2:start,org.eclipse.update.configurator#3:
start,org.eclipse.equinox.ds#3 <-- (From 2 to 3)
:start,org.eclipse.core.runtime#start
I don't know whether it's eclipse bug or not, I got a hint from this site.
Some tips that I found useful
-consoleLog was really useful, as I didn't have to open the log file all the time.
This article gave me some direction how to solve the issue.
I guess once the eclipse RCP is working on eclipse IDE as a product, we should get working standalone RCP. If not, the issues should be configuration issues that make difference between IDE and standalone.
You need to add the same to your feature.xml file.
Once you have added the same, clean the project and try re-build.
I am sure that this will resolve this issue.

Categories