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] |
Sun, 09 September 2012 22:25  |
Eclipse User |
|
|
|
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 10:42   |
Eclipse User |
|
|
|
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 #910949 is a reply to message #910943] |
Mon, 10 September 2012 13:27   |
Eclipse User |
|
|
|
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 13:28] by Moderator
|
|
| | | | |
Re: com.google.gson doesn't work with RAP [message #911130 is a reply to message #911040] |
Mon, 10 September 2012 23:25  |
Eclipse User |
|
|
|
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: Fri Jul 04 11:29:07 EDT 2025
Powered by FUDForum. Page generated in 1.04870 seconds
|