My project contains 2 source folder, one is generic J2EE application another is smartCleintGWT,
I want to use some already existing DTO classes from first source folder (src)
Note that class used on client side and on server side of GWT project!
When I do that I getting error
[ERROR] Errors in 'file:/C:/..Projects/Admin/DMX/src_console/com/ho/nod/client/AdminRPC.java'
[ERROR] Line 7: No source code is available for type com.dmx.synch.server.descriptors.DMXLicense; did you forget to inherit a required module?
Source is available obviously; is there any way to import all that into GWT?
PS In the future 2 source folder will be separated into 2 projects...I hope it wont be that complicated as well.
You can find in the good docs:
Modules can specify which subpackages
contain translatable source, causing
the named package and its subpackages
to be added to the source path. Only
files found on the source path are
candidates to be translated into
JavaScript, making it possible to mix
client-side and server-side code
together in the same classpath without
conflict. When module inherit other
modules, their source paths are
combined so that each module will have
access to the translatable source it
requires.
To add another subpackage add <source path="package"/> in your host file (*.gwt.xml). From the log you posted, it seems you have to add source from the com.dmx.synch.server package.
Most RPC problems are related to Serializablity of the DTO in question, can you need to ensure that the classes have default constructor and also check if the Module definition file i.e. .gwt.xml file has source element pointing to these packages.
GWT only looks for source code in the client package by default, so if you have added new packages you must specify this in your *.gwt.xml file.
Add something like: source path='your_top_dir' in XML format.
Related
So I am having issues deploying code to my local websphere server (imagine the dred I have for installing it to my test server).
I get a java.lang.ClassNotFoundException when I attempt to run the application.
So after googling around it seems as though I need to add entries into one of the above files. Problem is, there doesn't seem to be good examples of how to do that.
In the Manifest.mf file, do I need to add the fullpath to where I expect the jar to be? Does anybody have a good example of a deployment.xml/libraries.xml? How do I translate what is in my project classpath to entries into those various files?
Start with 'Websphere Class Loaders'.
Usually the order to load/find a class/resource is :
Current Module(war/jar/sar) --> (if not found then look inside) -->
Another Module in EAR (via manifest.mf) --> (if not found then try to load it from) -->
Common shared library (libraries.xml) (or) Extensions library -->
(if not found, then throw the error Class not found/No class Def found error).
Manifest.mf
Using this file you could point to the module/location directly to load the required classes/resources.
libraries.xml
Here you can define and maintain the shared libraries which can be used across many JVM's (like single jar file can be referenced from multiple jvm instances). Refer this for more information.
In my experience, I try to avoid using manifest.mf files, and refer the library jar files from shared library 'libraries.xml' file. (or) if you are trying to learn the Web sphare, then just include the jar files in lib/ folder of your package.
The GWT documentation states that all the source code for compilation to JavaScript on the client-side must be in a subpackage of the gwt.xml file. How does this work for when one references third party libraries?
Specifically, if I have a library foo.jar and I want to use some POJOs (which are Serializable) and do not suck in any non-Serializable code, how can I use these POJOs? How do I tell GWT where the source code is for them?
Remember too that the GWT compiler needs actual Java source to compile to javascript, so it isn't enough that the classes are available and that all are serializable. For RPC to send the classes over the wire, they must be able to be used as JS when they get to the client.
That said, take a look in gwt-user, at the module javax/validation/Validation.gwt.xml. This file is put there so that other packages in javax.validation - even in other jars - can be compiled into JS for client-side validation. if you have a jar (and sources) on your classpath with code in com.thirdparty.pojos, you can create a module file in your own project in that same dir in your own source (something like com/thirdparty/pojos/ThirdParthRpc.gwt.xml, and put a <source path="" /> element in it to indicate that the entire package is legal for translation to JS. There will likely be some files that cannot be translated - use the exclude tag to deal with those.
If you have control over packaging foo into foo.jar, and you have all the sources, then it's easy.
If you have a packaged foo.jar, and happen to have the source code, then you need to expand the foo.jar, copy the source into the exploded .jar directory, generate a simple GWT module.xml file and add an tag to your project’s module.
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).
How do we add an external .jar package in Google Web Toolkit (GWT)? I have followed the steps
1) added the .jar in classpath
2) added <inherits name='org.scribe.model' /> in my test.gwt.xml
I get this error:
Loading inherited module 'org.scribe.model'
[ERROR] Unable to find 'org/scribe/model.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] Line 8: Unexpected exception while processing element 'inherits'
However, I have found from many sources that you need the source files to compile the client side gwt. My question is what if one cannot get a source file of the .jar package? What is the workaround?
Thanks in advance.
If it is a GWT module it is packaged with sources. Check the jar Java files should be in it.
There are two ways to use a 3rd party dependency in your GWT application.
It is either a GWT module already which contains a module xml file along with the source files. In this case you just refer to it using inherits.
Or it is some regular 3rd party dependency in this case you need the source code and you also have to play with the package names since GWT requires source code to be under client package. Even you do so since the artifact is not developed GWT in mind, it might most likely contain code that is not allowed by GWT, e.g. you cannot use Threads in GWT.
There is no workaround. You need source files.. At least you can decompile class files..
My suggestion would be to handle intense logic on server side (within server package)
On the server side , you can use classes that are not supported by GWT front-end (classes in client package).
E.g
When I tried to use BufferedReader in client, I got exceptions, I then moved it to server package and retuned the result. The same was for RE which didn't work in client code too.
Keep your client code as simple as possible.
Hope this helps.
Cheers
PB
Compiling module com.sem.Sem10
Finding entry point classes
[ERROR] Unable to find type 'com.sem.client.Sem10'
[ERROR] Hint: Previous compiler errors may have made this type unavailable
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
My package structure is
com.sem
com.sem.client
com.sem.schema
com.sem.server
inherits name='com.google.gwt.user.User'
inherits name='com.google.gwt.user.theme.standard.Standard'
inherits name='com.google.gwt.maps.GoogleMaps'
script src="http://maps.google.com/maps?gwt=1&file=api&....
entry-point class='com.sem.client.Sem10'
source path='com.sem.schema'
I have googled this thing for quite a while and could not find a solution...? any help appreciated
It looks like your source path is incorrect.
If you set it to com.sem.schema then the com.sem.client won't be on the source path, and therefore your entry point com.sem.client.Sem10 won't be either.
Try removing your source path definition, use the default (which is the client subpackage underneath where the Module XML File is stored - so com.sem.client).
See here for more information: http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModules
Here's another suggestion to correct your source path in the *.gwt.xml file if you don't want to use the default.
In your .gwt.xml file, find the source tags near the bottom of the file.
revert to an earlier working commit, or open a known working project
take note of the pattern that the working source tags follow relative to the package structure of your working project.
roll forward to the broken commit
modify your source tag(s) to correspond to the current package structure, following the same pattern.