Home » Eclipse Projects » Remote Application Platform (RAP) » com.google.gson doesn't work with RAP(NoClassDefFoundError in Tomcat, but it works in Jetty)
com.google.gson doesn't work with RAP [message #910570] |
Mon, 10 September 2012 02:25 |
Mark Leone Messages: 69 Registered: April 2012 |
Member |
|
|
I have a RAP app consisting of two plug-ins, each with a dependency on plugin com.google.gson, a Json translater library. The app runs fine in jetty in the IDE, but when I deploy it as a WAR file and run it in Tomcat (7.0.21), the RWT code throws a NoClassDefFoundError when it executes one of my callbacks that refers to com.google.gson.Gson.
Each plug-in declares a dependency on com.google.gson. I build the WAR file using warproducts. I add com.google.gson to the warproducts configuration, and after Tomcat expands the WAR file I verify that the plug-in is present in the plugins folder and listed in config.ini. I also tried exporting the dependency on com.google.gson in each of my plugins. No matter what I do, the NoClassDefFoundError is thrown.
Plugin com.google.gson has no external dependencies. The Gson class imports code from the jdk (java.io, java.lang, java.math, and java.util), and from gson packages in the plugin. I verified in the target and the Plugins view that there are no other instances of the Gson class defined anywhere. I also verified that the tomcat lib folder does not have another instance of this plug-in, since strange class loader problems are sometimes caused by multiple class loaders loading the same class.
I don't know what else I can do to enable RWT to resolve this class. I hope someone else has some ideas.
|
|
|
Re: com.google.gson doesn't work with RAP [message #910873 is a reply to message #910570] |
Mon, 10 September 2012 14:42 |
Ivan Furnadjiev Messages: 2429 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Mark,
in order to debug it please enable the osgi console in your web.xml and
run the "ss" command. Post the result of the command here.
Best,
Ivan
On 9/10/2012 5:25 AM, Mark Leone wrote:
> I have a RAP app consisting of two plug-ins, each with a dependency on
> plugin com.google.gson, a Json translater library. The app runs fine
> in jetty in the IDE, but when I deploy it as a WAR file and run it in
> Tomcat (7.0.21), the RWT code throws a NoClassDefFoundError when it
> executes one of my callbacks that refers to com.google.gson.Gson.
>
> Each plug-in declares a dependency on com.google.gson. I build the WAR
> file using warproducts. I add com.google.gson to the warproducts
> configuration, and after Tomcat expands the WAR file I verify that the
> plug-in is present in the plugins folder and listed in config.ini. I
> also tried exporting the dependency on com.google.gson in each of my
> plugins. No matter what I do, the NoClassDefFoundError is thrown.
>
> Plugin com.google.gson has no external dependencies. The Gson class
> imports code from the jdk (java.io, java.lang, java.math, and
> java.util), and from gson packages in the plugin. I verified in the
> target and the Plugins view that there are no other instances of the
> Gson class defined anywhere. I also verified that the tomcat lib
> folder does not have another instance of this plug-in, since strange
> class loader problems are sometimes caused by multiple class loaders
> loading the same class.
>
> I don't know what else I can do to enable RWT to resolve this class. I
> hope someone else has some ideas.
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
| |
Re: com.google.gson doesn't work with RAP [message #910943 is a reply to message #910925] |
Mon, 10 September 2012 17:00 |
Ivan Furnadjiev Messages: 2429 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Mark,
the org.eclipse.equinox.console bundle depends on org.apache.felix.gogo
bundles. Please make sure that they are included in your WAR Product
configuration.
HTH,
Ivan
On 9/10/2012 7:29 PM, Mark Leone wrote:
> Ivan,
>
> Thanks for your reply. I have used the osgi console with rap before,
> but for some reason it's not working now. This is what I have in the
> relevant portion of the web.xml for my RAP app:
>
> <init-param>
> <param-name>commandline</param-name>
> <param-value>-registryMultiLanguage -console -ws
> rap</param-value> </init-param>
>
> Assuming that's correct, can you suggest other things I could look at
> to get the osgi console when I launch tomcat? I'm executing
> $CATALINA_HOME/bin/startup.sh from the command line. I see the context
> for my RAP app deployed, but the osgi console prompt does not appear
> as it has in past instances when I launched a RAP app with console
> enabled. Tomcat just continues to run in the foreground, and control
> is not returned to the command line.
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Re: com.google.gson doesn't work with RAP [message #910949 is a reply to message #910943] |
Mon, 10 September 2012 17:27 |
Mark Leone Messages: 69 Registered: April 2012 |
Member |
|
|
Ivan,
Thanks, it looks like that was the problem with osgi console. I added org.apache.felix.gogo plugins (command, runtime and shell are what I had available in the RAP target I'm using). I get the osgi prompt now, but when I type ss I get gogo: CommandNotFoundException: Command not found: ss .
I'm starting tomcat in a limited unix environment on a Windows machine at work (i.e. moba xterm). Are the gogo plugins perhaps depending on underlying unix commands that may not be available? If so, I can try it at home this evening, where I run directly in a full Unix environment. I can also try here to run tomcat directly in Windows. I have an issue doing that, relevant to my specific app, which I may be able to overcome.
regards,
-Mark
[Updated on: Mon, 10 September 2012 17:28] Report message to a moderator
|
|
| |
Re: com.google.gson doesn't work with RAP [message #911009 is a reply to message #910969] |
Mon, 10 September 2012 20:03 |
Mark Leone Messages: 69 Registered: April 2012 |
Member |
|
|
I discovered I was missing org.eclipse.equinox.console in my warproducts config. (I was wondering why I didn't see the apache gogo plug-ins show up when I clicked "Add Required Plug-ins. Now I realize I was actually missing the equinox console plugin itself, which was my root oversight.)
Below is the short status now after deploying the rap app. Nothing further appears on the console when I access the app, but the NoClassDefFoundError is captured by the logger when I access the app. I've also included below that stack trace.
The plug-in that is throwing the Error is owf.rap.core.
osgi> ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.8.0.v20120529-1548
Fragments=29
1 ACTIVE com.google.gson_2.2.2
2 ACTIVE com.ibm.icu.base_4.4.2.v20110831
3 ACTIVE com.ibm.icu.base.source_4.4.2.v20110831
4 ACTIVE org.apache.felix.gogo.command_0.8.0.v201108120515
5 ACTIVE org.apache.felix.gogo.command.source_0.8.0.v201108120515
6 ACTIVE org.apache.felix.gogo.runtime_0.8.0.v201108120515
7 ACTIVE org.apache.felix.gogo.runtime.source_0.8.0.v201108120515
8 ACTIVE org.apache.felix.gogo.shell_0.8.0.v201110170705
9 ACTIVE org.apache.felix.gogo.shell.source_0.8.0.v201110170705
10 ACTIVE org.apache.log4j_1.2.15.v201012070815
11 ACTIVE org.eclipse.core.commands_3.6.1.v20120521-2329
12 ACTIVE org.eclipse.core.contenttype_3.4.200.v20120523-2004
13 ACTIVE org.eclipse.core.databinding_1.4.1.v20120521-2329
14 ACTIVE org.eclipse.core.databinding.beans_1.2.200.v20120523-1955
15 ACTIVE org.eclipse.core.databinding.observable_1.4.1.v20120521-2329
16 ACTIVE org.eclipse.core.databinding.property_1.4.100.v20120523-1955
17 ACTIVE org.eclipse.core.expressions_3.4.400.v20120523-2004
18 ACTIVE org.eclipse.core.jobs_3.5.200.v20120521-2346
19 ACTIVE org.eclipse.core.runtime_3.8.0.v20120521-2346
20 ACTIVE org.eclipse.equinox.app_1.3.100.v20120522-1841
21 ACTIVE org.eclipse.equinox.common_3.6.100.v20120522-1841
22 ACTIVE org.eclipse.equinox.console_1.0.0.v20120522-1841
23 ACTIVE org.eclipse.equinox.http.registry_1.1.200.v20120522-2049
24 ACTIVE org.eclipse.equinox.http.servlet_1.1.300.v20120522-1841
25 ACTIVE org.eclipse.equinox.http.servletbridge_1.0.300.v20120522-2049
26 ACTIVE org.eclipse.equinox.preferences_3.5.0.v20120522-1841
27 ACTIVE org.eclipse.equinox.registry_3.5.200.v20120522-1841
28 ACTIVE org.eclipse.equinox.servletbridge_1.2.200.v20120522-2049
29 RESOLVED org.eclipse.equinox.servletbridge.extensionbundle_1.2.100.v20120522-2049
Master=0
30 ACTIVE org.eclipse.help_3.6.0.v20120521-2344
31 ACTIVE org.eclipse.osgi.services_3.3.100.v20120522-1822
32 ACTIVE org.eclipse.rap.jface_1.5.0.20120612-1458
33 ACTIVE org.eclipse.rap.jface.databinding_1.5.0.20120612-1458
34 ACTIVE org.eclipse.rap.rwt_1.5.0.20120612-1458
35 ACTIVE org.eclipse.rap.rwt.osgi_1.5.0.20120612-1458
36 ACTIVE org.eclipse.rap.ui_1.5.0.20120612-1458
37 ACTIVE org.eclipse.rap.ui.workbench_1.5.0.20120612-1458
38 ACTIVE org.junit_3.8.2.v3_8_2_v20100427-1100
39 ACTIVE owf.rap.core_1.0.0.201209101548
40 ACTIVE owf.rap.examples_1.0.0.201209101548
41 ACTIVE owf.rap.help_1.0.0.201209101548
osgi>
And here is the stack trace from the tomcat log:
2012-09-10 15:59:02,057 [http-bio-8443-exec-10] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/rap].[equinoxbridgeservlet]- Servlet.service() for servlet [equinoxbridgeservlet] in context with path [/rap] threw exception [Servlet execution threw an exception] with root cause
java.lang.NoClassDefFoundError: com/google/gson/Gson
at owf.rap.core.internal.OWFInitializePhaseListener.beforePhase(OWFInitializePhaseListener.java:39)
at org.eclipse.rwt.internal.lifecycle.PhaseListenerManager.notifyBeforePhase(PhaseListenerManager.java:70)
at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.continueLifeCycle(RWTLifeCycle.java:149)
at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:288)
at java.lang.Thread.run(Thread.java:722)
at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)
[Updated on: Mon, 10 September 2012 20:03] Report message to a moderator
|
|
| | |
Re: com.google.gson doesn't work with RAP [message #911130 is a reply to message #911040] |
Tue, 11 September 2012 03:25 |
Mark Leone Messages: 69 Registered: April 2012 |
Member |
|
|
Steve, thanks for the long shot suggestion. The osgi props command shows that the framework is running in a Java 6 environment.
I did find the problem, however. Running diag in the console showed that the gson plugin had no resolution conflicts, but when executing the "which" command it would still fail to load any class in the bundle. So I took a look at the deployed bundle in the expanded war file, and all it contained was the META-INF directory and the enclosed MANIFEST.MF file-- no class files.
So of course the problem was in build.properties. I was just looking at the build tab of the plug-in editor, which didn't have anything awry. But when I looked at the source for build.properties, the bin.includes value was missing the all-important dot . I don't know if that's the way it came, or if it got corrupted somehow on my project. So I added a comma and a dot, and two days troubleshooting has come to a successful conclusion. It's often the case that the really vexing and pernicious problems are caused by a very basic and silly error, and that was certainly the case here.
I'm still wondering why it worked in jetty and not in tomcat, however. Obviously since jetty is running in the IDE, it was executing class files produced by the eclipse Java builder, while tomcat was using jar files generated by the warproducts tool. But wouldn't both the eclipse builder and the warproducts builder both rely on the same build.properties file for their respective builds? I'd like to know what made it work in jetty and not tomcat, since clearly there is something about the eclipse build system I'm not understanding properly.
But it's great to finally have it working, and I appreciate the help that led me to the solution.
|
|
|
Goto Forum:
Current Time: Sat Jan 25 00:36:30 GMT 2025
Powered by FUDForum. Page generated in 0.04317 seconds
|