GWT: Using External Jar - eclipse

I am trying to figure out how to use external jar in GWT project.
I referred http://www.vogella.com/articles/GWTModules/article.html and it worked perfectly.
But the example explained using another project being included in the GWT project's build path instead of including the jar of that project.
I know this should not make a difference but when I created the jar of the external project (including sources) and used it in the client GWT gave me following error:
The import com.person cannot be resolved
What would be the problem?

For using external gwt library jar file in your gwt eclipse project you have to add that jar file in library tab from java build path:

If you want to use external jar and use that jar classes in your client side. you have to inherit module package entry in client gwt module.gwt.xml
Just example a. com.test.Module2.xml so you have do entry like
<inherits name='com.test.Module2'/>

Related

Using external jars in GWT projects (server-side)

I am trying to use an external jar in a Google Web Toolkit project.
The jar is for use only on the server side. For reference it is the jbcrypt jar packaged as org.mindrot.jbcrypt.
I have included the jar in my project's build path, and eclipse finds it and resolves the BCrypt class in my project.
When I try to use the service that relies on this jar (a login service that extends RemoteServiceServlet), I get a com.google.gwt.user.server.rpc.UnexpectedException which is caused by a NoClassDefFoundError for org.mindrot.jbcrypt.BCrypt.
Does the development server need the jar to be somewhere else? What should I do? Thanks.
Turns out, it goes in project/war/WEB-INF/lib

How to create a java project as a jar for GWT

I'm wanting to use some java code as a reusable component jar in my GWT 2.4 application.
I need access to that code on the client side, so I've read that the steps involved are to
add an entry in the main projects gwt.xml file pointing to this project,
include a gwt.xml file in the jar
and put the java code under a client folder.
I assume that this has to be a gwt project itself, otherwise there would be no need to add the inherits entry or is it not possible to use a regular java project client-side?
Is there anything else I need to do for this (other than ensure the libraries in the jar fall under the JRE Emulation Reference list)?
We don't use the plugin functionality in Eclipse, but to use another project in your GWT project all you need to do is define a .gwt.xml module file in your project that you want to use in your GWT project and reference that module file with <inherits.../> in your main GWT project. You will also obviously need to add that project as a reference in the build path in Eclipse, so you don't get compilation errors. And all of that is besides the fact that your referenced project has to comply to the JRE emulation reference so it can be fully GWT compilable.

How to create a GWT Library jar from existing GWT Project?

I have a working GWT project library which I include to other GWT projects that need to use it. So far its been useful enough, however I need to make it a library jar, what is the process of doing it?
I tried to export the jar using File->Export->JAR File process with Eclipse however when I included the jar file in the same projects where I used to include the project file, it won't work.
Any ideas?
Make sure you package *.java along with *.class. Module gwt.xml should also be placed in correct package.
See an example here.
In eclipse export wizard, make sure "Export Java Source files and resources" checkbox is checked.

My first GWT Module

I created a module to share code across a couple of projects.
I created a GWT project: Framework. I then created a module com.framework.Framework within the project. The Framework project contains both client code, in the com.framework.client packages, and server code in the com.framework.server packages.
I try to consume this by
- Adding the project to the Java Build Path
- Adding to the module's definition
When I run the consuming project, I get NoClassDefFoundErrors for Framework classes I use in the module's server code.
What am I missing?
If I jar up the Framework project's WEB-INF\classes contents and put it into the consuming project's WEB-INF\lib folder, as well as add it to the Build Path it seems to work, but I don't see a way to keep the framework classes up to date in the consuming project(s).
Please make sure that you create gwt.xml file via menu New->Module, and in this gwt.xml file, you must declare your entry point class.

Using external Jars on GWT server-side

Im new to GWT. Im using the eclipse plugin
and started tweaking google's 'hello, world!' project: greetServlet.
Im trying to build a webapp that will use XML (de)serializing.
I chose XStream library for the relative easiness.
my classpath includes the xstream.jar. I also manually copied the jar to the WEB-INF/lib folder
(Is this a mistake? is there a way in which eclipse will copy external jars by itself to the deployment folder?).
I added a single line to GreetingServiceImpl.greetServer
XStream xs = new XStream(); and this is where it fails.
It throws an exception on RPC call to greetServer.
Why? What's the matter?
Is this specific to XStream or am I mising some thing in adding an external jar?
If you are running in the development mode in eclipse, it could be that XStream is not supported by the Google Appengine whitelist.
http://code.google.com/intl/es-AR/appengine/docs/java/jrewhitelist.html
If this is your problem, you can run your application in a Tomcat.