PDA

View Full Version : including external jars



giovanni.puliti
15 Jan 2010, 2:47 AM
hy folks

i'm currently involved in building a GXT application based on a business logic layer made in EJB.
The GXT application communicate with the EJB layer via RMI/IIOP, all the calls are made in the server side of the GXT application using a Business Delegate (BD) for the comunication and some data transfer objects (DTO) for the data transport between layers.
All the EJB interaction logics (BDs and DTOs objects) are included in a jar library made by the EJB developers team. I need to include and use this classes in my GXT application.
This is what i did:

- first of all include the ejb-client.jar in the Eclipse project. following the GWT documentation in that jar are included all .class (compiled) and .java (sources) files.
I put in that file a ejb-client.gwt.xml file describing the library (but maybe the mistake is in the place of that file and the content).

- in the gxt application i've imported that library using the inherited tag in my-gxt-app.gwt.xml

<inherits name="it.myejbapp.utils.ejb-client"/>


when i use some DTO object on signature of RPC methods i receive an error (in Eclipse console and also from the gwt-compiler log):


Problem description: it.myejbapp.utils.MyDTO can not be found in source packages. 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.

the Eclispe automatic fixing put in the gwt.xml file another <inherits> but this doesn't solve the problem.....
any idea? Wich is the correct way to include an external set of classes in my application?

note: i wish to use external DTOs since i'm using the proxy-loader-store mechanism to populate data UI widgets (for example a grid) in automatic way, with out translating in other objects from gxt layer

Arno.Nyhm
18 Jan 2010, 3:39 AM
if you like to use the objects on client side then you need
a) also the java sources (you describe that the .java files in the .jar file - please double check this because the gwt compiler use only the .java source files)
b) the classes need also be in a client subdirectory under your gwt.xml

examples:


- mylib.ui
UI.gwt.xml
- mylib.ui.client
MyClass.java
in UI.gwt.xml:

<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name="com.google.gwt.user.User"/>
</module>in my application i use this:


<inherits name="mylib.ui.UI"/>
i dont know if this is the problem but maybe it helps you.

giovanni.puliti
19 Jan 2010, 9:12 AM
Thanx Arno

actually your hints was what i missed..... The problem is the DTO classes arrives from a com.foobar.another.project.utils.MyDTO and i cannot place these classes under a client directory.
this is a very common situation (using classes from another project placed in a anywhere.package.com), and i think to solve wrapping the DTOs in a Value Object Class (VO) existing in the GWT project. This avoid any including module issue.

any other idea?

Giovanni



if you like to use the objects on client side then you need
a) also the java sources (you describe that the .java files in the .jar file - please double check this because the gwt compiler use only the .java source files)
b) the classes need also be in a client subdirectory under your gwt.xml

examples:


- mylib.ui
UI.gwt.xml
- mylib.ui.client
MyClass.javain UI.gwt.xml:

<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name="com.google.gwt.user.User"/>
</module>in my application i use this:


<inherits name="mylib.ui.UI"/>i dont know if this is the problem but maybe it helps you.

Colin Alworth
21 Jan 2010, 9:35 AM
What you are asking for isnt possible for GWT - it needs access to the java source of any code that is to be used in the client, not just the class file. It _might_ be enough to make a new gwt module around your model objects on the server, and reference the namespace they are in using the <source /> tag. Be sure that this code does not contain anything that the gwt compiler cannot handle. Consider then using the BeanModelMarker annotation to turn your models into something the gxt Store can handle.

Most projects I have seen that incorporate GWT have the client project reference whatever service layer already exists. Then, to be as clear as possible as to what should be passed to the client, a copy of the model objects is created in the client project, and when the servlet is written, it has the code to do the translating from server to client objects.

Some people have tried to skip this step, such as in a GAE-GWT project - this results in models that get duplicated (as they can't cleanly detach, reattach), or some fields dont get serialized cleanly (as the reflection code that makes the models storable in the db adds extra fields that gwt cant handle).