Using external Jars on GWT server-side - gwt

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.

Related

Vaadin on Netbeans -- which jar?

i'm looking to use Vaadin on Netbeans 8.
I installed the Vaadin plug-in on Netbeans.
Followed the instructions on https://vaadin.com/wiki/-/wiki/Main/Getting+Started+on+NetBeans.
The jar i'm using is vaadin-all-7.3.8.
I assigned Tomcat to the project.
However - com.vaadin isn't recognized for all what it has in the environment-- com.vaadin.ui and com.vaadin.Application aren't seen.
I'm getting checked errors to
import com.vaadin.Application;
and
import com.vaadin.ui.*;
, but not to
import com.vaadin.*;
What more do i need for Vaadin on Netbeans??
TIA.
//=======================
EDIT:
Pls note: Saw Using Vaadin on NetBeans WITHOUT Maven along with some other discussions.
Also note: We're looking to avoid Vaadin-on-Maven. have already had issues with that one as well.
Be sure to read the readme in the zip file that tells you which jar files you need to include in your project:
Copy all vaadin-* files except vaadin-client and vaadin-client-compiler to WEB-INF/lib in your project
Copy lib/*.jar to WEB-INF/lib in your project
Copy vaadin-client and vaadin-client-compiler to a lib folder which is on your classpath but will not be deployed. These files are only needed when compiling a module (widget set) to Javascript.
What issues did you have with maven? Typically I would recommend using a dependency management tool to make upgrades easier in the future.

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

Servlet libraries are not defined in Eclipse

I am trying to make a simple servlet in Eclipse. But including the following libraries generates errors as if they were not defined in Eclipse.
import javax.servlet.*;
import javax.servlet.http.*;
How to have them recognised and defined?
Please add servlet-api.jar in classpath of your project.if you are using tomcat server, then it should be present in ${CATALINA_HOME}/lib
Be sure you are doing the right way:
If you are using the Classic version of Eclipse, then you must donwload the Web Tools Platform.
If you have an Eclipse Java EE Edition, then there is already installed the necessary plugins.
Create a new Dynamic Web Project: Menu New > Project > Dynamic Web Project.
Fill all values you want for the new project.
Do right click on the project and select New Servlet.
Last step creates a new Class file that is a servlet class, already importing the necessary packages, such as javax.servlet.http.*.
If you are using a Eclipse with a Maven plugin installed then, after configured it, you can only add the following dependencies:
http://mvnrepository.com/artifact/javax.servlet/servlet-api/2.5
http://mvnrepository.com/artifact/javax.servlet/jstl/1.2
http://mvnrepository.com/artifact/javax.servlet/jsp-api/2.0
In fact, you can see this tutorial explaining very well all the steps to create a Dynamic Web Prroject using WTP.
Or by ugin Maven, this one and this full explained.
Hope this help...

GWT: Using External Jar

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'/>

ClassNotFoundException when using User Libraries in Eclipse build path

I'm using Eclipse 3.7 (STS) with Tomcat 7 running inside the IDE. I've created a new Dynamic Web project and added a single JSP file to the web content root folder. I can run Tomcat and access the JSP from within Eclipse with no problems.
I've added a few 3rd party JAR's to the project from User Libraries (I'm not using maven or auto dependecies managment). In the JSP I reference a class from the project's JAR file, I can compile this with no problem, but when I deploy on Tomcat the JSP throws ClassNotFoundException. Clearly, Tomcat can't find the JAR's from my library settings. I tried creating a Run As configuration for Tomcat Server and I set the classpath to match the classpath settings of the project, but I still get the same classnotfound problem.
I could get around the issue by manually copying all project JARs to the WEB-INF/lib directory so the webapp can find all dependencies, but that's absurd and I don't expect that to be the solution since it's a maintenance nightmare.
Am I missing something?
In project's properties, go to Deployment Assembly. Add there the buildpath entries as well which you've manually added as user libraries. It'll end up in /WEB-INF/lib of the deployed WAR.
You'll need to copy the jar files to the WEB-INF/lib folder: that is where they are supposed to be.
Eclipse should offer you the option of generating a WAR file that includes all the dependencies: I haven't used Web Tools for a good while but one way or another all dependencies have to be in WEB-INF/lib or the class loader won't be able to find them.