How to use classes in a module that are not part of any module?

5 views
Skip to first unread message

TimOnGmail

unread,
Apr 7, 2009, 8:25:17 PM4/7/09
to Google Web Toolkit
Hi all...

I've looked around here, and didn't find this specific question asked
(although I'm sure it has been).

I have created a module, and have a bunch of bean classes residing
elsewhere. These bean classes are all Serializable (since I transfer
them between several servers already), and I want to use them in my
module. However, I don't want to have to turn these other libraries
INTO modules just to use these bean classes.

Is this even possible in GWT?

- Tim

TimOnGmail

unread,
Apr 7, 2009, 9:51:41 PM4/7/09
to Google Web Toolkit
I found some discussions of this here, but the answer always seems to
be "you can't" (unless you make them part of a module, with a common
parent, etc. etc., which I do not want to do).

Basically, I have this Eclipse project structure:

1. src/com/mycompany/domain/... (serializable domain objects)

2. gwt/[recommended structure]

I want the serializable domain objects in #1 available to the module
in #2, WITHOUT HAVING TO MAKE #1 A MODULE.
Seems like it should be doable, doesn't it? But from what I've read
here, it can't be done.

I also tried putting everything in #2 into the top level src/
hierarchy, and put all the module support files in the top level of
the project, but I couldn't get it work that way, either.

So... as of today, is it at all possible to have 2 separate source
hierarchies, 1 of which contains a GWT module, the other of which
contains simple serializable beans, and have the module be aware of
the other classes? I mean, they are there, they are serializable, the
source is available - why wouldn't it be possible to point the GWT
module to any arbitrary place where there are classes that can be
used? Seems weird.

Failing that, is it possible to have a standard Eclipse project
format, like the above, with the GWT module classes embedded in the
src/ hierarchy? If so, how would you set up the module file, etc.?

- Tim

Vitali Lovich

unread,
Apr 8, 2009, 12:29:48 AM4/8/09
to Google-We...@googlegroups.com
For development, yes.  Simply add the other project as a dependancy.

However, you can try fooling around with the classpath you provide the compiler - maybe that will work.

<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
  <classpath>
    <pathelement location="path to my beans"/>
    <pathelement location="src"/>
  </classpath>
  <arg value="com.foo.bar.MyModule"/>
</java>

If it doesn't, you could always just maintain an ant task that takes those beans & packages them into a module.  No it's not ideal because of the multiple locations you have to keep track of dependancies, but it should work.

TimOnGmail

unread,
Apr 8, 2009, 1:04:38 AM4/8/09
to Google Web Toolkit
Hi Vitali...

Well, I wasn't thinking of how to compile everything together in an
Ant script.

Rather, I was thinking of using the launch config that's created when
you follow the "how to create a module" instructions, and use it to
launch the test, without doing any special build processing. You
know, follow "how to" for Eclipse instructions, but rearrange the
locations of things or just modifying the single module I'm writing,
so that it drags in the other classes from the Eclipse src/ and bin/
folders.

Are you talking about creating a custom builder for the project? I
already depend upon the default builder for my project.

- Tim

On Apr 7, 9:29 pm, Vitali Lovich <vlov...@gmail.com> wrote:
> For development, yes.  Simply add the other project as a dependancy.
>
> However, you can try fooling around with the classpath you provide the
> compiler - maybe that will work.
>
> <java failonerror="true" fork="true"
> classname="com.google.gwt.dev.Compiler">
>   <classpath>
>     <pathelement location="path to my beans"/>
>     <pathelement location="src"/>
>   </classpath>
>   <arg value="com.foo.bar.MyModule"/>
> </java>
>
> If it doesn't, you could always just maintain an ant task that takes those
> beans & packages them into a module.  No it's not ideal because of the
> multiple locations you have to keep track of dependancies, but it should
> work.
>

Vitali Lovich

unread,
Apr 8, 2009, 1:15:45 AM4/8/09
to Google-We...@googlegroups.com
If you're just trying to launch hosted mode, adding the other project onto the build-path should be sufficient.  Have you actually tried this & it didn't work?  You might also want to add the other project as being a dependancy of the GWT project (not necessary for it to work, but just nicer from a behaviour of Eclipse perspective).

However, I've never heard of anyone actually compiling the Java into javascript from eclipse - it's certainly possible, but it's not what the default launch config does.

TimOnGmail

unread,
Apr 8, 2009, 1:49:44 AM4/8/09
to Google Web Toolkit
Yes, just for testing purposes, before I actually need to compile
everything into JavaScript.
Both hierarchies are part of the same project, by the way, and I have
already added the non-module
hierarchies (both source and compiled) to the class path of the launch
configuration for the module.
But when I launch it I get lots of these kinds of things:

[ERROR] Line 16: No source code is available for type
com.on24.loadtest.management.AgentEntry; did you forget to inherit a
required module?

- Tim

On Apr 7, 10:15 pm, Vitali Lovich <vlov...@gmail.com> wrote:
> If you're just trying to launch hosted mode, adding the other project onto
> the build-path should be sufficient.  Have you actually tried this & it
> didn't work?  You might also want to add the other project as being a
> dependancy of the GWT project (not necessary for it to work, but just nicer
> from a behaviour of Eclipse perspective).
>
> However, I've never heard of anyone actually compiling the Java into
> javascript from eclipse - it's certainly possible, but it's not what the
> default launch config does.
>

Isaac Truett

unread,
Apr 8, 2009, 8:34:25 AM4/8/09
to Google-We...@googlegroups.com
Tim,

"Making a module" means creating one XML file.

src/com/mycompany/Domain.gwt.xml:

<module>
<source path="domain" />
</module>

... and done. Inherit that in your GWT app and, assuming that
everything in com.mycompany.domain is GWT-compatible, you're set.

- Isaac

TimOnGmail

unread,
Apr 8, 2009, 2:51:25 PM4/8/09
to Google Web Toolkit
Hi Isaac...

I should make this even clearer. My bean-like classes are scattered
throughout my codebase, and not concentrated in one place. They many
are JAXB beans and import javax.xml classes, which appears to break
compilation in GWT. I'll check into that here, perhaps others have
tried this.

Basically, I'm trying - as others have tried - to avoiding having to
do a lot of work merely to use classes that are simple beans, though
they may use certain unsupported packages (like the JAXB packages) and
annotations, etc.

It's *looking* like I may have to create a common interface, and
create my own beans and use BeanUtils to copy them on the server side,
unfortunately.

- Tim

On Apr 8, 5:34 am, Isaac Truett <itru...@gmail.com> wrote:
> Tim,
>
> "Making a module" means creating one XML file.
>
> src/com/mycompany/Domain.gwt.xml:
>
> <module>
>     <source path="domain" />
> </module>
>
> ... and done. Inherit that in your GWT app and, assuming that
> everything in com.mycompany.domain is GWT-compatible, you're set.
>
> - Isaac
>

Vitali Lovich

unread,
Apr 8, 2009, 2:55:07 PM4/8/09
to Google-We...@googlegroups.com
If you use classes that aren't part of the GWT emulated JRE or there isn't a module out there that emulates the functionality, obviously you can't do it (unless you decide to write the emulated classes yourself if they are even possible).

TimOnGmail

unread,
Apr 8, 2009, 7:48:34 PM4/8/09
to Google Web Toolkit
Thanks Vitali...

I ended up having to move everything all over the place, separated out
my bean classes into interfaces, and applied them to both my existing
beans and the new, simplified ones to use for GWT.

Pain in the neck, but it almost works now... now I'm having another
problem, with regards to JAXB (will post again).

- Tim

On Apr 8, 11:55 am, Vitali Lovich <vlov...@gmail.com> wrote:
> If you use classes that aren't part of the GWT emulated JRE or there isn't a
> module out there that emulates the functionality, obviously you can't do it
> (unless you decide to write the emulated classes yourself if they are even
> possible).
>
Reply all
Reply to author
Forward
0 new messages