RCP: JxBrowser license check failed: No valid license found - java

Today I started experimenting with JxBrowser. Starting the sample with the public static main worked as expected (and it could find the license.jar).
I added a button to a view to start the sample:
btnStart.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
new JxBrowserJavaFXSWT();
}
});
Now I'm receiving:
Caused by: java.lang.RuntimeException: JxBrowser license check failed: No valid license found.
Which is actually odd because it's added the classpath. I tried adding a new Plugin-Project (which is loaded fine) and add the license.jar to its classpath: not working.
I tried to add it to the manifest.mf, build.properties
manifest.mf
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: License
Bundle-SymbolicName: com.teamdev.jxbrowser.license
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.teamdev.jxbrowser.license.Activator
Bundle-Vendor: TEAMDEV
Require-Bundle: org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
build.properties
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
license.jar
src.includes = license.jar
jars.extra.classpath = license.jar
Question: is there a way to add the license.jar to my rcp project and/or what am I missing?
P.S.: if informations are missing to help me solve this I'll gladly add more code, etc

I received the same error, and I have a solution.
Just create a new mail ID and send a request to get a license of JX Browser using that new account, and get it and Download.
Then add that license.jar file in your project. It worked.

You probably need the license.jar in the main plugin class path - the 'Bundle-Classpath'.
Open the MANIFEST.MF editor, switch to the Runtime tab and add the license.jar to the Classpath section (you should also still have the . entry). The Bundle-Classpath should end up looking like:
Bundle-ClassPath: .,
library.jar

I can't give you a perfect answer but I can give you a hint.
First you can extract the licence.jar file to change the extension from .jar to .zip.
Then you can see the following file:
Product: JxBrowser
Version: 6.x
Licensed to:
License type: Evaluation
License info: Single-user license
Expiration date: 22-03-2099
Support expiration date: 22-03-2099
Generation date: 20-02-2017
Platforms: mac/x64;win32/x64;linux/x64;mac/x86;linux/x86;win32/x86;mac/ppc
Company name: NO COMPANY
SigB: jpg317l89241ihodylpum17e2gnk1ufx7bsql1dboldc25pp941s7ksw0wph
SigA: mdluetwphf1vcbl2yzs3ks5c4417pexopgnmap146g8ggk4r4e9ucrzmf1xo
You have to change the values of SigB and SigA.
I tried it, after changing date, but it does not work.

Related

.bnd files have errors when building in IntelliJ

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)

Package.getImplementationVersion() returns NULL

Thanks in advance for any help.
What I want to achieve is project version (Implementation-Version) is printed in a class when it is initiated so that I can trace the version from log file.
I build a JAR file containing the following classes:
com.company.core.common.ClassA
com.company.core.security.ClassB
com.company.core.sql.ClassC
In constructor of com.company.core.sql.ClassC, I want to call System.out.println() to print out the Implementation-Version stored in META-INF/MANIFEST.MF file by calling this.class.getPackage().getImplementationVersion(), but it is getting null value when the class is initiated via Maven test class.
My MANIFEST.MF file contains the following details:
Manifest-Version: 1.0
Implementation-Title: Company Core Library
Implementation-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: simon
Implementation-Vendor-Id: com.company.core
Build-Time: 2017-02-18T15:07:33Z
Class-Path: lib/sqljdbc42-4.2.jar lib/log4j-api-2.7.jar lib/log4j-core
-2.7.jar lib/json-20160810.jar lib/junit-4.12.jar lib/hamcrest-core-1
.3.jar
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_102
Implementation-Vendor: Company
Name: com/company/core/
Implementation-Vendor-Id: com.company.core
Implementation-Title: Company Core Library
Implementation-Version: 1.0
Implementation-Vendor: Company
Would I be able to get the Implementation-Version in Maven test class?
If yes, what have I missed out here?
Thanks.
Regards,
Simon.
Within the development environment all class files are found in a named folder target (e.g. within Eclipse). The package path is represented as a directory structure. For a directory structure the existance of a Manifest is not defined. Therefore the dedicated class loader will ignore all requests for a Manifest. This is the reason the call returns null.
Running in the productive environment your product is packed within a jar-file. In this case it is defined, that there is a Manifest-file. The jar file class loader knows about the manifest file and will display version information correctly.
We helped us, by providing a default of "Implementation Version" if the version is retrieved within the development environment.

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.

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