My first GWT Module - gwt

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.

Related

eclipse - cannot get project export/dependencies working

Ok. I am using eclipse kepler.
Ihave an eclipse project called 'afd-core'. It has some classes, and a directory etc/hibernate containing hibernate config - lookup.hbm.xml.
I have another project afd-public. It is a webapp, and needs the stuff in afd-core on it's classpath.
And I think I have tried everything.
afd-public->project referencers: added add-core as a referenced project
afd-public->java build path->projects: added afd-core
afd-public->java build path->order and export: marked afd-core as exported
afd-core->java build path->added etc/hibernate as a classpath entry
afd-core->order and export->marked etc/hibernate as exported
Didn't work. When I run add-public as a web app, complains that it cant find the hibernate config.
So I made etc/hibernate a source rather than a class direcrory. Still didn't work.
Explicitly added add-core/etc/hibernate as a class directory in the add-public project. Still didnt work. Marked those class drectories as 'exported'. Still didn't work.
Manually copied the hibernate config into afd-public/webapp/WEB-INF/classes . Ok, it finds the hibernate config, but it does not find the core class files.
In other words, the afd-public webapp is not including dependencies from afd-core AT ALL, not in any way, shape, or form into the webapp that it deploys locally to tomcat. Whether or not I mark them as exported from afd-core. Whether or not I include the project or the directories explicitly. Whether or not I do or dont export them from the afd-public webapp.
Nothing. nada. Won't go.
Help?
Found it. Goddamnit - I needed to fiddle with Deployment Assembly in afd-public. It seems that there are a couple of ways to do it.
I can include afd-public/build/classes and afd-public/etc/hibernate and have them deployed to WEBINF/classes, or I can deploy the add-core jarfile to lib.
To get the afd-core jarfile correct, I create afd-core as a j2ee "utility project" and check that the Deployment Assembly there is correct. Which it is.

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

Fail to create custom UI component in ZK framework

Trying to create custom UI component going through ZK 6.0.1 Component Development Essentials.
Always got error in logs "http://localhost:8080/zk6/zkau/web/_zv2011051111/js/examples.com.foo.wpd : HTTP Status 404 - /js/examples.com.foo.wpd" when trying to use custom component.
Found the war file with this example in scala, it works OK. I have copied all files from it to my project, and got same error.
The project structure is according to tutorial. What might be wrong?
You have to put the web folder, which contains the js files, in the java classpath, that means it should be put under the src folder. More easy way is to use the ZK Maven Archetype to create the template for you.
At least the way IntelliJ IDEA does things (which I see your are using, as am I), simply placing the web folder under the src folder doesn't seem to automatically get it copied to the artifact (although I'm not sure why). So I tried manually putting it in the WEB-INF/classes folder, and that worked. So the correct path for your example is <project-root>/web/WEB-INF/classes/web/js/examples/com/foo/zk.wpd.

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.

GWT - including source files outside module's package hierarchy

I have a GWT project in eclipse with the following structure for the GWT module
com.foo.gwt -> Dashboard.gwt.xml
com.foo.gwt.client
com.foo.gwt.server
I have different packages com.bar.baz1, com.bar.baz2, etc. whose contents I want to include in client side code. All the files are GWT JAVA->JS conversion compatible.
The problem is that the <source> tag in Dashboard.gwt.xml, treats the path as relative to the directory of Dashboard.gwt.xml. So I cannot reference anything outside com.foo.gwt hierarchy.
So I created a new module MyNewModule.gwt.xml in com.bar and included baz1 and baz2 sub packages using relative paths in tag. Finally I made Dashboard.gwt.xml to inherit the new module.
This works fine when I compile the Dashboard module but fails when I compile MyNewModule.
That's because some classes in MyNewModule reference classes of Dashboard module.
I tried inheriting Dashboard module in MyNewModule. This creates a circular reference, but GWT doesn't complain about it. Everything works but I am not comfortable with the circular reference. I don't need MyNewModule, all I need is a way to include code from packages outside Dashboard module's hierarchy.
I am wondering why GWT does not allow absolute source paths.
Am I missing something here?
You dont need to compile each module separately. When you compile your com.foo.gwt project, GWT compiler will look for all dependencies in your com.foo.gwt.xml file and will compile ALL .java files both your com.foo and com.bar.baz. (and other libraries) to javascript.
As you said, its correct to put MyNewModule.gwt.xml in the com.bar.baz project and "inherit" it in your DashBoard.gwt.xml file. The part you are missing is to make a .jar file with MyNewModule project and put in war/WEB-INF/lib folder (just gwt.xml file and compiled java classes).