Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » ClassNotFoundException in OSGi but jars included(Problem resolving classes that apparently are included)
ClassNotFoundException in OSGi but jars included [message #989723] Fri, 07 December 2012 12:50 Go to next message
John Gymer is currently offline John Gymer
Messages: 189
Registered: November 2012
Location: UK
Senior Member
Trying to execute a RAP application from Eclipse 4.2.1 with RAP 2.0 M3 under OSGi but having problems persuading it to find all of my referenced classes.

The application runs ok as SWT Standalone.

Firstly, here is the error reported in the console:

2012-12-07 12:25:37.033:WARN:oejs.ServletHandler:ERROR:  Error for /rapide;jsessionid=k3ooqc2qng501m3x93hh6xkcv
java.lang.NoClassDefFoundError: com/ca/gen80/abrt/ABBase
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at iet.co.uk.rapide.RapideInstance.initialisePStep(RapideInstance.java:2299)
	at iet.co.uk.rapide.RapideMain.GenGUILoadPStep(RapideMain.java:194)
	at iet.co.uk.rapide.RapideMain.begin(RapideMain.java:76)
	at iet.co.uk.rapide.RapideMain.start(RapideMain.java:35)
	at iet.co.uk.rapide.RapideEntryPoint.createUI(RapideEntryPoint.java:52)
	at iet.co.uk.rapide.RapideApplication.start(RapideApplication.java:8)
	at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:186)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:298)
	at java.lang.Thread.run(Thread.java:662)
	at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)
Caused by: 
java.lang.ClassNotFoundException: com.ca.gen80.abrt.ABBase
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at iet.co.uk.rapide.RapideInstance.initialisePStep(RapideInstance.java:2299)
	at iet.co.uk.rapide.RapideMain.GenGUILoadPStep(RapideMain.java:194)
	at iet.co.uk.rapide.RapideMain.begin(RapideMain.java:76)
	at iet.co.uk.rapide.RapideMain.start(RapideMain.java:35)
	at iet.co.uk.rapide.RapideEntryPoint.createUI(RapideEntryPoint.java:52)
	at iet.co.uk.rapide.RapideApplication.start(RapideApplication.java:8)
	at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:186)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:298)
	at java.lang.Thread.run(Thread.java:662)
	at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)


My RAP application is the 'iet.co.uk.rapide' one, which references a set of classes starting 'ca.com.gen80.*'. These are in a single JAR called 'gen80rt.jar'.

Where should I be specifying the gen80rt.jar so that my RAP app can find it at runtime? gen80rt.jar is not a Plug-in or a Bundle, just a totally stand-alone JAR file. There doesn't appear to be a concept of a CLASSPATH for RAP applications (apart from the Bundle's Classpath that I've included further down in this post), which sort of makes sense since they have to define precisely what they export and what they import in the manifest, but how to actually reference this JAR?

Perhaps this is very basic, and I'm missing something fundamental, so please be patient while I get my head around it all!

I've placed gen80rt.jar into WEB-INF/lib by the way.

Basic project structure as below:
index.php/fa/12636/0/

ss from OSGi in the console gives:

ss
"Framework is launched."


id	State       Bundle
0	ACTIVE      org.eclipse.osgi_3.9.0.v20121026-132713
	            Fragments=7
1	ACTIVE      org.eclipse.equinox.preferences_3.5.0.v20120918-182152
2	ACTIVE      org.eclipse.core.databinding.observable_1.4.1.v20120521-2329
3	ACTIVE      org.apache.felix.gogo.shell_0.8.0.v201110170705
4	ACTIVE      org.eclipse.equinox.app_1.3.100.v20120522-1841
5	ACTIVE      org.eclipse.rap.ui.workbench_2.0.0.20121106-1948
6	ACTIVE      org.eclipse.equinox.console_1.0.100.v20121001-124408
7	RESOLVED    org.eclipse.equinox.servletbridge.extensionbundle_1.2.100.v20120522-2049
	            Master=0
8	ACTIVE      org.apache.felix.gogo.command_0.8.0.v201108120515
9	ACTIVE      org.eclipse.core.commands_3.6.1.v20120814-150512
10	ACTIVE      org.eclipse.rap.jface.databinding_2.0.0.20121031-1050
11	ACTIVE      org.eclipse.rap.rwt.osgi_2.0.0.20121031-1050
12	ACTIVE      org.eclipse.jetty.security_8.1.3.v20120522
13	ACTIVE      org.eclipse.equinox.http.jetty_3.0.0.v20120522-1841
14	ACTIVE      org.eclipse.equinox.http.registry_1.1.200.v20120912-125810
15	ACTIVE      org.eclipse.core.databinding_1.4.1.v20120912-132807
16	ACTIVE      org.eclipse.equinox.common_3.6.100.v20120522-1841
17	ACTIVE      org.eclipse.core.runtime_3.9.0.v20121004-163638
18	ACTIVE      javax.servlet_3.0.0.v201112011016
19	ACTIVE      org.eclipse.rap.ui_2.0.0.20121105-1706
20	ACTIVE      org.eclipse.core.databinding.beans_1.2.200.v20120523-1955
21	ACTIVE      org.eclipse.equinox.registry_3.5.300.v20120731-134527
22	ACTIVE      org.eclipse.core.expressions_3.4.401.v20120912-155018
23	ACTIVE      org.eclipse.jetty.util_8.1.3.v20120522
24	ACTIVE      iet.co.uk.rapide.runtime_1.0.0.qualifier
25	ACTIVE      org.eclipse.osgi.services_3.3.100.v20120522-1822
26	ACTIVE      org.eclipse.jetty.server_8.1.3.v20120522
27	ACTIVE      org.eclipse.core.contenttype_3.4.200.v20120523-2004
28	ACTIVE      com.ibm.icu.base_4.4.2.v20110831
29	ACTIVE      org.eclipse.jetty.http_8.1.3.v20120522
30	ACTIVE      org.eclipse.help_3.6.0.v20120521-2344
31	ACTIVE      org.eclipse.core.databinding.property_1.4.200.v20120824-092539
32	ACTIVE      org.eclipse.rap.design.example_1.5.100.20121109-0718
33	ACTIVE      org.apache.felix.gogo.runtime_0.8.0.v201108120515
34	ACTIVE      org.eclipse.jetty.continuation_8.1.3.v20120522
35	ACTIVE      org.eclipse.rap.jface_2.0.0.20121031-1050
36	ACTIVE      org.eclipse.equinox.http.servlet_1.1.300.v20120912-125810
37	ACTIVE      org.eclipse.jetty.io_8.1.3.v20120522
38	ACTIVE      org.eclipse.rap.ui.forms_1.5.100.20121105-1308
39	ACTIVE      org.eclipse.rap.rwt_2.0.0.20121112-1148
40	ACTIVE      org.eclipse.core.jobs_3.5.300.v20120912-155018
41	ACTIVE      org.eclipse.jetty.servlet_8.1.3.v20120522
42	ACTIVE      javax.xml_1.3.4.v201005080400
43	ACTIVE      org.eclipse.rap.ui.views_1.5.100.20121031-1050
osgi> 


So I can see my Bundle as ACTIVE at number 24 in this case.

My Manifest looks like this:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: iet.co.uk.rapide.runtime;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: %Bundle-Vendor
Import-Package: iet.co.uk.rapide,
 org.eclipse.rap.rwt.application;version="2.0.0",
 org.eclipse.rap.rwt.lifecycle;version="2.0.0",
 org.eclipse.rap.rwt.widgets;version="2.0.0",
 org.eclipse.swt,
 org.eclipse.swt.events,
 org.eclipse.swt.graphics,
 org.eclipse.swt.layout,
 org.eclipse.swt.widgets
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: iet.co.uk.rapide;
  uses:="com.ca.gen80.vwrt.vdf,
   eu.jgen.gen.invoke.ab.base,
   org.eclipse.swt.events,
   org.eclipse.rap.rwt.application,
   org.w3c.dom,
   org.eclipse.swt.ole.win32,
   com.ca.gen80.abrt,
   com.ca.gen80.csu.exception,
   com.ca.gen80.vwrt,
   org.eclipse.rap.rwt.lifecycle,
   org.eclipse.equinox.app,
   org.eclipse.swt.graphics,
   org.eclipse.swt.widgets"
Require-Bundle: org.eclipse.rap.ui
Bundle-ClassPath: .,
 WEB-INF/lib/gen80rt.jar


I'm not sure that I understand where the 'uses' come from, or if they are relevant?

Any suggestions as to how to get the class loader to see the Classes in gen80rt.jar?

Thanks, John


---
Just because you can doesn't mean you should

[Updated on: Fri, 07 December 2012 12:51]

Report message to a moderator

Re: ClassNotFoundException in OSGi but jars included [message #989764 is a reply to message #989723] Fri, 07 December 2012 16:08 Go to previous messageGo to next message
John Gymer is currently offline John Gymer
Messages: 189
Registered: November 2012
Location: UK
Senior Member
Ok, so I figured out that I have to have the gen80rt.jar in a Bundle, which I've done, giving MANIFEST of that project looking like this:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Gen r8.0 Runtimes
Bundle-SymbolicName: com.ca.gen80.runtimes
Bundle-Version: 8.0.0
Bundle-ClassPath: gen80rt.jar
Export-Package: com.ca.gen80.abrt,
 com.ca.gen80.abrt.cascade,
 com.ca.gen80.abrt.functions,
 com.ca.gen80.abrt.manager,
 com.ca.gen80.abrt.trace,
 com.ca.gen80.csu.MIME,
 com.ca.gen80.csu.exception,
 com.ca.gen80.csu.load,
 com.ca.gen80.csu.nls,
 com.ca.gen80.csu.resource,
 com.ca.gen80.csu.semaphore,
... (and lots more than I'd expect - various classes I need access to) ...
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: javax.xml.ws,
 javax.xml.bind,
 javax.sql,
 javax.rmi,
 javax.xml.bind.annotation.adapters,
 javax.transaction,
 javax.servlet.http; version="2.6.0",
 javax.naming,
 javax.servlet; version="2.6.0",
 javax.xml.soap


In my original RAP project where I want to use this JAR, I've added a dependency to it as follows:

index.php/fa/12638/0/

I then modify my RAP Run Configuration to include this new Bundle:

index.php/fa/12639/0/

Unfortunately nothing has changed. The browser gives the same as previous:

HTTP ERROR: 500
 
Problem accessing /rapide;jsessionid=1f3nt5siflgtg12n9k9k761xxz. Reason: 
    com/ca/gen80/abrt/ABBase
 
--------------------------------------------------------------------------------
Powered by Jetty:// 


...and the console still gives:

...
	at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)
Caused by: 
java.lang.ClassNotFoundException: com.ca.gen80.abrt.ABBase
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at iet.co.uk.rapide.RapideInstance.initialisePStep(RapideInstance.java:2299)
	at iet.co.uk.rapide.RapideMain.GenGUILoadPStep(RapideMain.java:194)
	at iet.co.uk.rapide.RapideMain.begin(RapideMain.java:76)
	at iet.co.uk.rapide.RapideMain.start(RapideMain.java:35)
	at iet.co.uk.rapide.RapideEntryPoint.createUI(RapideEntryPoint.java:52)
	at iet.co.uk.rapide.RapideApplication.start(RapideApplication.java:8)
	at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:186)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:298)
	at java.lang.Thread.run(Thread.java:662)
	at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)


...and ss in OSGi console gives:

ss
"Framework is launched."


id	State       Bundle
0	ACTIVE      org.eclipse.osgi_3.9.0.v20121026-132713
	            Fragments=5
1	ACTIVE      org.eclipse.core.runtime_3.9.0.v20121004-163638
2	ACTIVE      org.eclipse.rap.rwt_2.0.0.20121112-1148
3	ACTIVE      org.eclipse.rap.ui.workbench_2.0.0.20121106-1948
4	ACTIVE      org.apache.felix.gogo.command_0.8.0.v201108120515
5	RESOLVED    org.eclipse.equinox.servletbridge.extensionbundle_1.2.100.v20120522-2049
	            Master=0
6	ACTIVE      com.ca.gen80.runtimes_8.0.0
7	ACTIVE      org.eclipse.rap.ui.views_1.5.100.20121031-1050
8	ACTIVE      org.eclipse.jetty.io_8.1.3.v20120522
9	ACTIVE      org.eclipse.equinox.registry_3.5.300.v20120731-134527
10	ACTIVE      org.eclipse.equinox.app_1.3.100.v20120522-1841
11	ACTIVE      org.eclipse.help_3.6.0.v20120521-2344
12	ACTIVE      org.eclipse.jetty.continuation_8.1.3.v20120522
13	ACTIVE      org.eclipse.equinox.http.servlet_1.1.300.v20120912-125810
14	ACTIVE      org.eclipse.equinox.console_1.0.100.v20121001-124408
15	ACTIVE      org.apache.felix.gogo.shell_0.8.0.v201110170705
16	ACTIVE      javax.xml_1.3.4.v201005080400
17	ACTIVE      iet.co.uk.rapide.runtime_1.0.0.qualifier
18	ACTIVE      org.eclipse.rap.jface.databinding_2.0.0.20121031-1050
19	ACTIVE      org.apache.felix.gogo.runtime_0.8.0.v201108120515
20	ACTIVE      org.eclipse.equinox.http.jetty_3.0.0.v20120522-1841
21	ACTIVE      org.eclipse.jetty.servlet_8.1.3.v20120522
22	ACTIVE      com.ibm.icu.base_4.4.2.v20110831
23	ACTIVE      org.eclipse.core.databinding.observable_1.4.1.v20120521-2329
24	ACTIVE      org.eclipse.equinox.preferences_3.5.0.v20120918-182152
25	ACTIVE      org.eclipse.jetty.http_8.1.3.v20120522
26	ACTIVE      javax.servlet_3.0.0.v201112011016
27	ACTIVE      org.eclipse.jetty.server_8.1.3.v20120522
28	ACTIVE      org.eclipse.osgi.services_3.3.100.v20120522-1822
29	ACTIVE      org.eclipse.core.jobs_3.5.300.v20120912-155018
30	ACTIVE      org.eclipse.core.databinding_1.4.1.v20120912-132807
31	ACTIVE      org.eclipse.core.databinding.beans_1.2.200.v20120523-1955
32	ACTIVE      org.eclipse.jetty.security_8.1.3.v20120522
33	ACTIVE      org.eclipse.jetty.util_8.1.3.v20120522
34	ACTIVE      org.eclipse.core.contenttype_3.4.200.v20120523-2004
35	ACTIVE      org.eclipse.rap.rwt.osgi_2.0.0.20121031-1050
36	ACTIVE      org.eclipse.rap.ui.forms_1.5.100.20121105-1308
37	ACTIVE      org.eclipse.equinox.http.registry_1.1.200.v20120912-125810
38	ACTIVE      org.eclipse.core.commands_3.6.1.v20120814-150512
39	ACTIVE      org.eclipse.core.expressions_3.4.401.v20120912-155018
40	ACTIVE      org.eclipse.rap.ui_2.0.0.20121105-1706
41	ACTIVE      org.eclipse.core.databinding.property_1.4.200.v20120824-092539
42	ACTIVE      org.eclipse.equinox.common_3.6.100.v20120522-1841
43	ACTIVE      org.eclipse.rap.jface_2.0.0.20121031-1050
44	ACTIVE      org.eclipse.rap.design.example_1.5.100.20121109-0718
osgi> 


You can see both my Bundles as ACTIVE (at number 6 and 17 in the above example).

So, why can't my 'rapide' RAP application see the runtimes within gen80rt.jar (in the com.ca.gen80.runtimes Bundle)?

Please help, I'm going headless chicken with this not understanding what I'm missing!

Many thanks, John


---
Just because you can doesn't mean you should
Re: ClassNotFoundException in OSGi but jars included [message #989776 is a reply to message #989723] Fri, 07 December 2012 17:07 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger Herrmann
Messages: 565
Registered: July 2009
Senior Member
John,

ideally you would create an OSGi bundle from the gen80 library. Google
for "use library jar in osgi" or so and you'll find plenty of advise.

Alternatively you can extend the class-path of the bundle that contains
the gen08 library like so
Bundle-ClassPath: .,ren08rt.jar
and make sure that the library is listed in the build.properties file
like so:
bin.includes = .,META-INF/,gen08rt.jar

As you said that your application runs ok as SWT Standalone, are you
aware that you don't *have* to use OSGi. RWT, the SWT for the web part
of RAP, runs just fine without OSGi. See the FAQ [1] and the developer's
guide [2] for more.

HTH
Rüdiger

[1]
http://wiki.eclipse.org/RAP/FAQ#How_do_I_develop_an_RWT_standalone_application_with_RAP_.3E.3D_1.5
[2] http://eclipse.org/rap/developers-guide
On 07.12.2012 13:50, John Gymer wrote:
> Trying to execute a RAP application from Eclipse 4.2.1 with RAP 2.0 M3 under OSGi but having problems persuading it to find all of my referenced classes.
>
> The application runs ok as SWT Standalone.
>
> Firstly, here is the error reported in the console:
>
>
> 2012-12-07 12:25:37.033:WARN:oejs.ServletHandler:ERROR: Error for /rapide;jsessionid=k3ooqc2qng501m3x93hh6xkcv
> java.lang.NoClassDefFoundError: com/ca/gen80/abrt/ABBase
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
> at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> at iet.co.uk.rapide.RapideInstance.initialisePStep(RapideInstance.java:2299)
> at iet.co.uk.rapide.RapideMain.GenGUILoadPStep(RapideMain.java:194)
> at iet.co.uk.rapide.RapideMain.begin(RapideMain.java:76)
> at iet.co.uk.rapide.RapideMain.start(RapideMain.java:35)
> at iet.co.uk.rapide.RapideEntryPoint.createUI(RapideEntryPoint.java:52)
> at iet.co.uk.rapide.RapideApplication.start(RapideApplication.java:8)
> at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
> at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:186)
> at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:298)
> at java.lang.Thread.run(Thread.java:662)
> at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)
> Caused by:
> java.lang.ClassNotFoundException: com.ca.gen80.abrt.ABBase
> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
> at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> at iet.co.uk.rapide.RapideInstance.initialisePStep(RapideInstance.java:2299)
> at iet.co.uk.rapide.RapideMain.GenGUILoadPStep(RapideMain.java:194)
> at iet.co.uk.rapide.RapideMain.begin(RapideMain.java:76)
> at iet.co.uk.rapide.RapideMain.start(RapideMain.java:35)
> at iet.co.uk.rapide.RapideEntryPoint.createUI(RapideEntryPoint.java:52)
> at iet.co.uk.rapide.RapideApplication.start(RapideApplication.java:8)
> at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
> at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:186)
> at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:298)
> at java.lang.Thread.run(Thread.java:662)
> at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)
>
>
> My RAP application is the 'iet.co.uk.rapide' one, which references a set of classes starting 'ca.com.gen80.*'. These are in a single JAR called 'gen80rt.jar'.
>
> Where should I be specifying the gen80rt.jar so that my RAP app can find it at runtime? It is not a Plug-in or a Bundle, just a totally stand-alone JAR file. There doesn't appear to be a concept of a CLASSPATH for RAP applications (apart from the Bundle's Classpath that I've included further down in this post), which sort of makes sense since they have to define precisely what the export and what they import in the manifest, but how to actually reference this JAR?
>
> Perhaps this is very basic, and I'm missing something fundamental, so please be patient while I get my head around it all!
>
> I've placed gen80rt.jar into WEB-INF/lib by then way.
>
> Basic project structure as below:
>
>
> ss from OSGi in the console gives:
>
>
> ss
> "Framework is launched."
>
>
> id State Bundle
> 0 ACTIVE org.eclipse.osgi_3.9.0.v20121026-132713
> Fragments=7
> 1 ACTIVE org.eclipse.equinox.preferences_3.5.0.v20120918-182152
> 2 ACTIVE org.eclipse.core.databinding.observable_1.4.1.v20120521-2329
> 3 ACTIVE org.apache.felix.gogo.shell_0.8.0.v201110170705
> 4 ACTIVE org.eclipse.equinox.app_1.3.100.v20120522-1841
> 5 ACTIVE org.eclipse.rap.ui.workbench_2.0.0.20121106-1948
> 6 ACTIVE org.eclipse.equinox.console_1.0.100.v20121001-124408
> 7 RESOLVED org.eclipse.equinox.servletbridge.extensionbundle_1.2.100.v20120522-2049
> Master=0
> 8 ACTIVE org.apache.felix.gogo.command_0.8.0.v201108120515
> 9 ACTIVE org.eclipse.core.commands_3.6.1.v20120814-150512
> 10 ACTIVE org.eclipse.rap.jface.databinding_2.0.0.20121031-1050
> 11 ACTIVE org.eclipse.rap.rwt.osgi_2.0.0.20121031-1050
> 12 ACTIVE org.eclipse.jetty.security_8.1.3.v20120522
> 13 ACTIVE org.eclipse.equinox.http.jetty_3.0.0.v20120522-1841
> 14 ACTIVE org.eclipse.equinox.http.registry_1.1.200.v20120912-125810
> 15 ACTIVE org.eclipse.core.databinding_1.4.1.v20120912-132807
> 16 ACTIVE org.eclipse.equinox.common_3.6.100.v20120522-1841
> 17 ACTIVE org.eclipse.core.runtime_3.9.0.v20121004-163638
> 18 ACTIVE javax.servlet_3.0.0.v201112011016
> 19 ACTIVE org.eclipse.rap.ui_2.0.0.20121105-1706
> 20 ACTIVE org.eclipse.core.databinding.beans_1.2.200.v20120523-1955
> 21 ACTIVE org.eclipse.equinox.registry_3.5.300.v20120731-134527
> 22 ACTIVE org.eclipse.core.expressions_3.4.401.v20120912-155018
> 23 ACTIVE org.eclipse.jetty.util_8.1.3.v20120522
> 24 ACTIVE iet.co.uk.rapide.runtime_1.0.0.qualifier
> 25 ACTIVE org.eclipse.osgi.services_3.3.100.v20120522-1822
> 26 ACTIVE org.eclipse.jetty.server_8.1.3.v20120522
> 27 ACTIVE org.eclipse.core.contenttype_3.4.200.v20120523-2004
> 28 ACTIVE com.ibm.icu.base_4.4.2.v20110831
> 29 ACTIVE org.eclipse.jetty.http_8.1.3.v20120522
> 30 ACTIVE org.eclipse.help_3.6.0.v20120521-2344
> 31 ACTIVE org.eclipse.core.databinding.property_1.4.200.v20120824-092539
> 32 ACTIVE org.eclipse.rap.design.example_1.5.100.20121109-0718
> 33 ACTIVE org.apache.felix.gogo.runtime_0.8.0.v201108120515
> 34 ACTIVE org.eclipse.jetty.continuation_8.1.3.v20120522
> 35 ACTIVE org.eclipse.rap.jface_2.0.0.20121031-1050
> 36 ACTIVE org.eclipse.equinox.http.servlet_1.1.300.v20120912-125810
> 37 ACTIVE org.eclipse.jetty.io_8.1.3.v20120522
> 38 ACTIVE org.eclipse.rap.ui.forms_1.5.100.20121105-1308
> 39 ACTIVE org.eclipse.rap.rwt_2.0.0.20121112-1148
> 40 ACTIVE org.eclipse.core.jobs_3.5.300.v20120912-155018
> 41 ACTIVE org.eclipse.jetty.servlet_8.1.3.v20120522
> 42 ACTIVE javax.xml_1.3.4.v201005080400
> 43 ACTIVE org.eclipse.rap.ui.views_1.5.100.20121031-1050
> osgi>
>
> So I can see my Bundle as ACTIVE at number 24 in this case.
>
> My Manifest looks like this:
>
>
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: %Bundle-Name
> Bundle-SymbolicName: iet.co.uk.rapide.runtime;singleton:=true
> Bundle-Version: 1.0.0.qualifier
> Bundle-Vendor: %Bundle-Vendor
> Import-Package: iet.co.uk.rapide,
> org.eclipse.rap.rwt.application;version="2.0.0",
> org.eclipse.rap.rwt.lifecycle;version="2.0.0",
> org.eclipse.rap.rwt.widgets;version="2.0.0",
> org.eclipse.swt,
> org.eclipse.swt.events,
> org.eclipse.swt.graphics,
> org.eclipse.swt.layout,
> org.eclipse.swt.widgets
> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
> Export-Package: iet.co.uk.rapide;
> uses:="com.ca.gen80.vwrt.vdf,
> eu.jgen.gen.invoke.ab.base,
> org.eclipse.swt.events,
> org.eclipse.rap.rwt.application,
> org.w3c.dom,
> org.eclipse.swt.ole.win32,
> com.ca.gen80.abrt,
> com.ca.gen80.csu.exception,
> com.ca.gen80.vwrt,
> org.eclipse.rap.rwt.lifecycle,
> org.eclipse.equinox.app,
> org.eclipse.swt.graphics,
> org.eclipse.swt.widgets"
> Require-Bundle: org.eclipse.rap.ui
> Bundle-ClassPath: .,
> WEB-INF/lib/gen80rt.jar
>
>
> I'm not sure that I understand where the 'uses' come from, or if they are relevant?
>
> Any suggestions as to how to get the class loader to see the Classes in gen80rt.jar?
>
> Thanks, John
>
--
Rüdiger Herrmann
http://codeaffine.com
Re: ClassNotFoundException in OSGi but jars included [message #989988 is a reply to message #989776] Mon, 10 December 2012 10:59 Go to previous messageGo to next message
John Gymer is currently offline John Gymer
Messages: 189
Registered: November 2012
Location: UK
Senior Member
Thanks Rüdiger,

I do indeed have the application running as SWT Standalone, and also RWT Standalone, but wanted to get it going under OSGi as RAP because eventually I want to be able to take it to Tabris, and I thought that RAP was a necessary step to get there i.e. it must work under RAP, otherwise forget Tabris...? Have I misunderstood?

I've had a little play with the settings that you suggested for RAP, but nothing working yet... will continue to experiment, but would appreciate any further suggestions to make gen80rt.jar visible to the running RAP application.

Many thanks, John


---
Just because you can doesn't mean you should
Re: ClassNotFoundException in OSGi but jars included [message #990014 is a reply to message #989988] Mon, 10 December 2012 13:42 Go to previous messageGo to next message
John Gymer is currently offline John Gymer
Messages: 189
Registered: November 2012
Location: UK
Senior Member
Have moved on a little... I got suspicious when it transpired that other classes within that JAR (gen80rt.jar) were being found ok, and realised that ABBase was being loaded via programmatic class loader:

myABClass = myClassLoader.loadClass(className);


So, I modified my ClassLoader to include the gen80rt.jar at runtime, hard-coded for now from a specific path:

try {
  myClassLoader.addURL(new URL("file:" + appRoot + "/gen80rt.jar"));
} catch (MalformedURLException e) {
  e.printStackTrace();
}


Great, this gets around that issue, but now I have other unexpected issues with other classes in the jar, not being able to cast them as I did in SWT/RWT:

...
Caused by: 
java.lang.ClassCastException: IET.GDWBLG1_IA cannot be cast to com.ca.gen80.vwrt.IImportView
	at iet.co.uk.rapide.RapideInstance.initialisePStep(RapideInstance.java:2331)
	at iet.co.uk.rapide.RapideMain.GenGUILoadPStep(RapideMain.java:202)
	at iet.co.uk.rapide.RapideMain.begin(RapideMain.java:76)
	at iet.co.uk.rapide.RapideMain.start(RapideMain.java:55)
	at iet.co.uk.rapide.RapideEntryPoint.createUI(RapideEntryPoint.java:52)
	at iet.co.uk.rapide.RapideApplication.start(RapideApplication.java:8)
	at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:186)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:298)
	at java.lang.Thread.run(Thread.java:662)
	at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)


Why is it that I can do this cast successfully in SWT/RWT, but not under RAP?
The actual Classes noted here are not relevant, but I guess I need to understand why the ClassLoader is fussier under RAP compared to SWT/RWT...?

Thanks, John


---
Just because you can doesn't mean you should

[Updated on: Mon, 10 December 2012 14:50]

Report message to a moderator

Re: ClassNotFoundException in OSGi but jars included [message #990027 is a reply to message #990014] Mon, 10 December 2012 14:49 Go to previous messageGo to next message
Cole Markham is currently offline Cole Markham
Messages: 133
Registered: July 2009
Senior Member
John,

The problem with the ClassCastException is because of the way you added the jar to the ClassLoader. That is not something you should do in OSGi. I would suggest reading more about OSGi and how class loading works. Here are a couple of articles that may be helpful[1][2]. You will probably find more help on one of the Equniox or OSGi forums, as this is not a RAP-specific issue.

[1] http://njbartlett.name/2010/08/30/osgi-readiness-loading-classes.html
[2] http://blog.osgi.org/2011/05/what-you-should-know-about-class.html

Hope that helps,

Cole
Re: ClassNotFoundException in OSGi but jars included [message #990029 is a reply to message #990027] Mon, 10 December 2012 14:52 Go to previous messageGo to next message
John Gymer is currently offline John Gymer
Messages: 189
Registered: November 2012
Location: UK
Senior Member
Thanks Cole,
I'll take a look at those links.
In the meantime, could you confirm if I am right in thinking that I have to get RAP working before going to Tabris? If not, then I'll skip RAP altogether.
Thanks, John


---
Just because you can doesn't mean you should
Re: ClassNotFoundException in OSGi but jars included [message #990047 is a reply to message #990029] Mon, 10 December 2012 16:25 Go to previous messageGo to next message
Cole Markham is currently offline Cole Markham
Messages: 133
Registered: July 2009
Senior Member
John,

I haven't worked with Tabris, so I can't confirm that for sure. I believe the way RAP is designed, that standalone RWT should work with Tabris. Both the standard web client and the Tabris client communicate with the server using the same protocol. The widget hierarchy and application state are represented on the server, the clients are just a presentation layer. Since the web client works with RWT standalone, I don't see any reason why the Tabris client would not do the same.

Good luck,

Cole
Re: ClassNotFoundException in OSGi but jars included [message #990179 is a reply to message #990047] Tue, 11 December 2012 10:03 Go to previous messageGo to next message
Holger Staudacher is currently offline Holger Staudacher
Messages: 166
Registered: July 2009
Senior Member
Tabris works in the standalone mode without problems as long as the bootstrapping is done actively. An example how this is done can be found here: https://github.com/eclipsesource/tabris-demos/blob/master/com.eclipsesource.tabris.demos/src/com/eclipsesource/tabris/demos/Configuration.java
Re: ClassNotFoundException in OSGi but jars included [message #990440 is a reply to message #990179] Wed, 12 December 2012 13:56 Go to previous message
John Gymer is currently offline John Gymer
Messages: 189
Registered: November 2012
Location: UK
Senior Member
Thanks Cole and Holger,

I'll bookmark that Tabris bootstrapper link for later once we move into Tabris.

The links on Class Loaders were incredibly helpful, and I've restructured my whole approach to doing this now, and happily can report that my app (single-sourced) will run on SWT Standalone, SWT Exported, RWT Standalone, RAP within Eclipse IDE, RAP exported as WAR to JBoss and to WebLogic! Fabulous - this is what this technology is all about!

Here's another link that I found useful too, in describing how Class Loaders work in application servers:
http://www.theserverside.com/news/1364680/Understanding-J2EE-Application-Server-ClassLoading-Architectures#ref

The solution I used for Class Loading is to simply take a note of the Class Loader for the top-level Class in my project, and pass this down the chain, so any Classes loaded on the fly have the same starting point, and therefore the same visibility. Works brilliantly:

Top level Class:
...
genGUIClassLoader = getClass().getClassLoader();


Then genGUIClassLoader is passed down to any other Classes that need it at runtime, for example:

...
myABCClass = genGUIClassLoaderForRef.loadClass("my.class.abc");
...


Very simple - always the best.

Now, I'm not sure if there are any negative implications in the way I've done this, so I'd be interested to hear any further comments, but for now it works exactly the way I need in practise, and across all of the various target platforms, so I'm happy!

Cheers, John


---
Just because you can doesn't mean you should
Previous Topic:ControlDecoration format description
Next Topic:JPA with Eclipselink MySQL jdbc in Eclipse RAP/RCP
Goto Forum:
  


Current Time: Tue Oct 21 21:39:12 GMT 2014

Powered by FUDForum. Page generated in 0.02067 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software