Using beanutils in my maven project

203 views
Skip to first unread message

András Csányi

unread,
Nov 16, 2011, 11:30:36 AM11/16/11
to google-web-toolkit
Dear All,

I would like to ask some help because I'm a little bit confused.
There is my project where apache beanutils is used and dependencies
are managed by Maven. The whole project looks like this:
-WebClient project - gwt project
- GWTLib - external project and a few abstract classes are placed here
and they are used in the WebClient gwt project

In the GWTLib project beanutils are used. I'm able to compile this
project without any error. But when I start to compile the WebClient
project I got an error and it says that there is no source for
BeanUtils class. Here are a few facts:
- GWTLib has the common-beanutils as dependency and the source is downloaded.
- WebClient has the common-beanutils as dependency and the source is downloaded.

If I see correctly in my local maven repository every item has 2 jars,
one contains the compiled files and the other for the sources. Despite
the fact the sources are downloaded gwt compiler is not able to
compile the source. My question is that whether this is the proper
behavior of the compiler or not? If so, than what should I do to use
beanutils in my project? Should I download the source code of
beanutils and compile it that way one jar will contains the compiled
files and the sources as well? Is there any lighter way to do it or I
missed something?

Thanks for any help in advance!

András

--
- -
--  Csanyi Andras (Sayusi Ando)  -- http://sayusi.hu --
http://facebook.com/andras.csanyi
--  ""Trust in God and keep your gunpowder dry!" - Cromwell

Juan Pablo Gardella

unread,
Nov 16, 2011, 12:08:11 PM11/16/11
to google-we...@googlegroups.com
You need to add dependency jar in your pom.xml (with classifier) and define a xml module. For example I add jsr330 to my project in this way:

Add sources to classpath:

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<classifier>sources</classifier>
<scope>provided</scope>
<type>jar</type>
</dependency>

Indicate to GWT that use them:

In your module:
       <!-- javax.inject -->
<inherits name='javax.JSR330' />

And I generate this file
javax/JSR330.xml

<module>
<source path='inject' />
<source path='persistence/metamodel' />
</module>

Juan
2011/11/16 András Csányi <sayus...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


András Csányi

unread,
Nov 16, 2011, 1:09:03 PM11/16/11
to google-we...@googlegroups.com
Dear Juan,

Thank you very much, but I'm still confused. I think I need more clarification.

> You need to add dependency jar in your pom.xml (with classifier) and define
> a xml module. For example I add jsr330 to my project in this way:
> Add sources to classpath:
> <dependency>
> <groupId>javax.inject</groupId>
> <artifactId>javax.inject</artifactId>
> <version>1</version>
> <classifier>sources</classifier>
> <scope>provided</scope>
> <type>jar</type>
> </dependency>

Done!

> Indicate to GWT that use them:
> In your module:
>        <!-- javax.inject -->
> <inherits name='javax.JSR330' />

Is there any naming convention? Beanutils looks like this in pom.xml
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
<classifier>sources</classifier>
</dependency>
Following your example I should create something like this in the
WebClient.gwt.xml file

<inherits name="commons.beanutils" />

> And I generate this file
> javax/JSR330.xml
> <module>
> <source path='inject' />
> <source path='persistence/metamodel' />
> </module>

At this point I feel lost. :)
Summarize what I understand from this.
My project gwt.xml file placed here:
com/sayusiando/java/dilib/DiLibWebClient.gwt.xml
Following your example I should create a directory named "commons"
something like this:
com/sayusiando/java/dilib/commons

And create a beanutils.gwt.xml file in this directory something like this
com/sayusiando/java/dilib/commons/beanutils.gwt.xml

And this file has to be contain something like this:
<module>
<source path='beanutils' />
</module>

According to this the whole beanutils source must be placed under the
"com/sayusiando/java/dilib/commons/beanutils/"
directory.

I don't understand why should I do the last two steps. My project has
a dependency to apache beanutils managed by maven, but my problem is
that according to gwt compiler there is no available source code of
apache beanutils. But this is not true because maven already
downloaded the source code but it's stored in a different file. I
assume the compiler doesn't know that

The whole case looks like for me a little bit hellish... because I
think the whole problem is rooted in that the maven repository doesn't
have that kind of jar which contains the compiled files and the source
code files as well which is deprecated for gwt compiler.

I think I have to watch an episod of Futurama to clear my mind!

Juan Pablo Gardella

unread,
Nov 16, 2011, 1:18:57 PM11/16/11
to google-we...@googlegroups.com
Here you can see a sample (browse the source):


In this site you can check how configure the module.

And some answers:

>I don't understand why should I do the last two steps. My project has
>a dependency to apache beanutils managed by maven, but my problem is

   Yes, maven know, but GWT compiler needs the information that where it can find sources. This kind of information is defined in your modules.

Juan

2011/11/16 András Csányi <sayus...@gmail.com>
Dear Juan,

András Csányi

unread,
Nov 17, 2011, 3:36:52 AM11/17/11
to google-we...@googlegroups.com
On 16 November 2011 19:18, Juan Pablo Gardella

<gardella...@gmail.com> wrote:
> Here you can see a sample (browse the source):
> gwt-sample (Spring, JPA2)
> In this site you can check how configure the module.
> And some answers:
>>I don't understand why should I do the last two steps. My project has
>>a dependency to apache beanutils managed by maven, but my problem is
>    Yes, maven know, but GWT compiler needs the information that where it can
> find sources. This kind of information is defined in your modules.

I think I give it up. I followed your example and the problem is the
same. I put into pom.xml file of my gwt project this:

<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>

</dependency>


<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
<classifier>sources</classifier>

<scope>provided</scope>
<type>jar</type>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>


<classifier>sources</classifier>
<scope>provided</scope>
<type>jar</type>
</dependency>

<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>


<classifier>sources</classifier>
<scope>provided</scope>
<type>jar</type>
</dependency>

Because I've found in your example this:

<!-- Nos permite usar jsr-330 -->


<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>

</dependency>
<!-- Necesario para compilar con GWT -->
<!-- Ref: http://code.google.com/p/gwt-maven/issues/detail?id=47#c15 -->


<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<classifier>sources</classifier>
<scope>provided</scope>
<type>jar</type>
</dependency>

I've inherited the commons-beanutils package in this way:
<inherits name="commons-beanutils" />

I created a directory named "commons" and I put the beanutils.gwt.xml
file into it and the structure looks like this:
com/sayusiando/java/dilib/
com/sayusiando/java/dilib/DiLibWebClient.gwt.xml
com/sayusiando/java/dilib/commons
com/sayusiando/java/dilib/commons/beanutils.gwt.xml

The beanutils.gwt.xml file contains this:
<module rename-to="beanutils">
<source path="beanutils"></source>
</module>
But there is no further "beanutils" directory under
"com/sayusiando/java/dilib/commons" because it doesn't needed, or is
it needed? How on earth the source placed here? Maven will do it or I
have to do it? I compiled your project and it's compiled without any
error, but to be honest, I don't have any idea why yours is working
and why mine is not.
So, I got the error there is no package "beanutils" when I would like
to compile the project.

Long story short, I don't have any idea how can I use the
commons-beanutils package, a third party open source package, from
Apache Foundation in my gwt project.

Juan Pablo Gardella

unread,
Nov 17, 2011, 8:08:41 AM11/17/11
to google-we...@googlegroups.com
You are adding other libs, and for example commons-logging is not possible use in GWT, becouse it use reflection. Check http://code.google.com/intl/es/webtoolkit/doc/latest/RefJreEmulation.html

At writing this mail, I remember commons-beanutils use reflection (I think) so you can't compile to GWT.

Juan

2011/11/17 András Csányi <sayus...@gmail.com>

András Csányi

unread,
Nov 17, 2011, 8:57:08 AM11/17/11
to google-we...@googlegroups.com
On 17 November 2011 14:08, Juan Pablo Gardella

<gardella...@gmail.com> wrote:
> You are adding other libs, and for example commons-logging is not possible
> use in GWT, becouse it use reflection. Check
> http://code.google.com/intl/es/webtoolkit/doc/latest/RefJreEmulation.html
>
> At writing this mail, I remember commons-beanutils use reflection (I think)
> so you can't compile to GWT.

That's correct, unfortunately. Using reflection was my original plan.
I have to figure out something else, but it looks like I found
something usable:

http://code.google.com/p/gwt-ent/

Reply all
Reply to author
Forward
0 new messages