GWT source question

4 views
Skip to first unread message

Jason Purcell

unread,
Mar 12, 2010, 2:23:23 AM3/12/10
to CTJUG...@googlegroups.com
Hi there...

If I want to make certain classes available on the client side in GWT, then it has to be in the "client" folder by default.

However, I want to be able to use classes from another project.  I have access to the source of the project.

Apparently I have to specify the source in the module (*.gwt.xml) but I can't get it to work and I don't see any working examples on the internet.

Something like this:


<?xml version="1.0" encoding="UTF-8"?>
<module>

    <inherits name="com.google.gwt.user.User"/>
    <inherits name="com.google.gwt.http.HTTP" />

    <entry-point class="com.mystuff.web.gwt.client.MainEntryPoint"/>

    <source path=???????????????????????????>  //What format???  Hard-coded?  Relative path?  Namespace?
       
    <!-- Do not define servlets here, use web.xml -->
</module>



Does anyone know how I can do this, or even specify multiple source locations?

By the way, I am using Netbeans 6.8 on Windows, if it helps.

Regards,
Jason.

Enrico Goosen

unread,
Mar 12, 2010, 3:27:32 AM3/12/10
to ctjug...@googlegroups.com
Hi Jason,
 
If you want to use classes from another project in an existing GWT project, you need to jar up the classes, including the source.
The source from the other project will need to be made available as a GWT module.
So the other project will have a mymodule.gwt.xml file.
Example:
You module file may be in the following package:
za.co.mypackage
 
In the project that will be using the module, you use the inherits tag to indicate the module you want to use.
<inherits name="za.co.mypackage.mymodule"/>
 
Regards,
Enrico
 


From: ctjug...@googlegroups.com [mailto:ctjug...@googlegroups.com] On Behalf Of Jason Purcell
Sent: 12 March 2010 09:23 AM
To: CTJUG...@googlegroups.com
Subject: [CTJUG Tech] GWT source question

--
You received this message because you are subscribed to the Google Groups "CTJUG Tech" group.
To post to this group, send email to CTJUG...@googlegroups.com
To unsubscribe from this group, send email to CTJUG-Tech+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CTJUG-Tech?hl=en
For Cape Town Java User Group home page see http://www.ctjug.org.za/
For jobs see http://jobs.gamatam.com/This message is subject to Metropolitans disclaimer pertaining to electronic communications. To view the disclaimer please visit http://www.metropolitan.co.za/disclaimer.asp

Jason Purcell

unread,
Mar 12, 2010, 3:59:45 AM3/12/10
to ctjug...@googlegroups.com
Thanks, Enrico.

When you say "The source from the other project will need to be made available as a GWT module", do you mean the following? :

<?xml version="1.0" encoding="UTF-8"?>
<module>
    <source path="za.co.mypackage" />
</module>

...or must it be a hard-coded path?

Jason.

Alessio Harri

unread,
Mar 12, 2010, 4:07:27 AM3/12/10
to ctjug...@googlegroups.com

The actual source code needs to be in the classpath ie. in the jar file

 

Any libraries you access on the client side needs the source code on the classpath

because the GWT compiler needs to generate javascript from the source code NOT the class files.

Jason Purcell

unread,
Mar 12, 2010, 4:15:25 AM3/12/10
to ctjug...@googlegroups.com
Hi, Alessio...

I configured the other project to include the .java source when creating a JAR.

I then reference that project's JAR file from my GWT project.

I assume then that those sources are in my classpath as I can reference the classes in my project (e.g. when using code-completion).  When I check the JAR then those files are definitely there.

But I am kinda stuck on what needs to go into the *.gwt.xml file of the referenced project.


<?xml version="1.0" encoding="UTF-8"?>
<module>
    <source path="*** this part***" />
</module>

I've tried the namespace and using a hard-coded direct path, but I get the following error:
"No source code is available for type myproject.MyClass; did you forget to inherit a required module?"

Is there anything else I need to configure?  Or am I missing something?

Regards,
Jason.

Jason Purcell

unread,
Mar 12, 2010, 4:18:03 AM3/12/10
to ctjug...@googlegroups.com
Maybe I should ask: Where does the other project's module (e.g. mymodule.gwt.xml) go?  In the same folder as the classes I am referencing, or in root?

On 12 March 2010 10:27, Enrico Goosen <EGoo...@metropolitan.co.za> wrote:

Enrico Goosen

unread,
Mar 12, 2010, 4:30:41 AM3/12/10
to ctjug...@googlegroups.com
Hi Jason,
 
Here's an example of what the module file (*.gwt.xml) looks like:
<module>
 <inherits name="com.google.gwt.user.User"/>
    <inherits name="com.googlecode.gwt.math.Math"/>
    <inherits name="com.allen_sauer.gwt.log.gwt-log" />
 <inherits name="com.gwtext.GwtExt"/>  
 <stylesheet src="css/extension.css" />
 <source path="client" />                
</module>
 
You can place the module file in your source package eg. za.co.myproject
 
When you jar up the above project, you will have classes and source files in the jar as well as the GWT module file.
eg.
   za
        co
            myproject
                mymodule.gwt.xml
                mypackage
                    MyClass.class
                    MyClass.java
 
Make the jar available on your classpath, and as per my previous email:
In the project that will be using the module, you use the inherits tag to indicate the module you want to use.
<inherits name="za.co.myproject.mymodule"/>
 
Hope this helps.
 
Regards,
Enrico


From: ctjug...@googlegroups.com [mailto:ctjug...@googlegroups.com] On Behalf Of Jason Purcell
Sent: 12 March 2010 11:18 AM
To: ctjug...@googlegroups.com
Subject: Re: [CTJUG Tech] GWT source question

Jason Purcell

unread,
Mar 12, 2010, 4:49:16 AM3/12/10
to ctjug...@googlegroups.com
Okay, thanks.

I am probably making a spelling mistake somewhere.

I changed the GWT compiler logging level, and I can see that my module is loaded.  It also shows that the compiler found translatable resources.

I will investigate further and provide feedback when I find out what the problem is.

Jason.

Jason Purcell

unread,
Mar 12, 2010, 5:49:02 AM3/12/10
to ctjug...@googlegroups.com
Got it to work now.

I moved the module up by one folder as in your example...  Sorry, I didn't see that at first.

Thanks!!!
Reply all
Reply to author
Forward
0 new messages