Error inheriting a module in a mavenized GWT project - java

After adding this dependency in my pom.xml:
<dependency>
<groupId>com.eaio.uuid</groupId>
<artifactId>uuid</artifactId>
<version>3.2</version>
</dependency>
I get an error by jetty on the module load event:
no source code available for com.eaio.uuid; did you forget to inherit the module? unable to find com.client.myproject..`
What am I missing?

If you're using any of the classes in that artifact in your GWT compiled code, then the source code needs to be available, either packaged in the jar or as a source jar (remember that's another dependency).
You'll have to look for a .gwt.xml file in the jar, as this will be the name you need to inherit in your own GWT descriptor, eg. if the file is called com/eaio/UUID.gwt.xml you should
...
<inherits name="com.eaio.UUID" />
...
If one isn't available, just create your own with a simple <source path="..." /> and stick in the right package in your own project (still provided the source is actually available!)
Cheers,

Related

Add specific package from provided dependency into jar

How to add one package with all classes and subpackage from provided dependency into the Jar.
I have got dependency like :
<dependency>
<groupId>com.a</groupId>
<artifactId>dependencyA</artifactId>
<scope>provided</scope>
</dependency>
What I want to achieve is to add all classes and subpackage into jar file. For example Is there any plugin that allow me to specify which package should be added something like:
<include>com.a.package.*</include>
As a result, I expect that all classes under package com.a.package.* from dependencyA would be added into jar.
You can't as you're defining a dependency, so your application needs that JAR fully, but you only import some packages, those what you need, so the JVM will only load those ones.

Class not found in project sources or resources GWT

I'm building GWT application with Maven. My application uses some custom UI forms instead of standard ones. I have files with custom UI forms, packed in .jar file.
My .ui.xml file has this:
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:nc='custompackage.gwt.fields.client.widgets.reference'
>
...
<nc:UIReferenceField width="100%" text = "123" nc:field="rf"/>
...
My module .gwt.xml file inherits custom class:
...
<inherits name="custompackage.gwt.fields.Fields"/>
...
When I build Maven module I get:
Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.6.0:compile (default)
on project geographical-view-for-osp-gwt-2: GWT Module
com.netcracker.platform.ui.toolkit.gwt.i18n.i18n not found in project sources or resources.
I've looked into similar problem questions, but their resolution didn't help me at all. Can you help me?
P.S.: My module builds fine without custom fields.
I didnt add some dependencies to my .pom file. My inherited module depended on them and it didnt compile.

Unable to compile the com.google.gwt.thirdparty.guava.common.base.Optional package of gwt-dev jar

I would like to use the Optional class of guava jar. I am able to use it in my project.But, in the gwt-dev jar the Optional class has already been there in the package com.google.gwt.thirdparty.guava.common.base.Optional. So, I don't want to use the guava jar for just using the Optional class. So, I am trying to use the Optional class of gwt-dev jar.
Steps which I have done:
I have created com.google.gwt.thirdparty.guava.common.base package in my project
In that package I have created the Base.gwt.xml file.
<?xml version="1.0" encoding="utf-8"?>
<!-- semi-autogenerated module descriptor -->
<module>
<source path="">
</source>
</module>
I have included the Base.gwt.xml file in my gwt.xml file.
Though I have done the above steps I was not able to compile the code. I am getting the below exception:
No source code is available for type com.google.gwt.thirdparty.guava.common.base.Optional; did you forget to inherit a required module?
Any suggestions would be appretiated.
You shouldn't be using com.google.gwt.thirdparty.* - those are internally repackaged jars. There's no guarantee they'll be there in the next version of GWT - in fact, I'd expect them (at least the Guava part) to be removed in favor of "vanilla" Guava, as suggested in this thread. To further reinforce this there's no source attached for them in the gwt-dev.jar (as you've experienced), so you can't use them in your client-side code.
Please use the normal dependency on Google Guava - the GWT compiler will only compile in the parts of Guava that you are using (especially if you just inherit com.google.common.base.Base) and prune out the rest.

Unable to compile the GWT module while trying to use javax.annotation.Nullable?

I would like to use the javax.annotation.Nullable annotation in my GWT project. I would like to know which module has to be inherited into my gwt.xml file inorder to use that annotation. The google guava jar internally uses the Nullable annotation and If I use that Jar in my project it is able to compile. Please help me what package has to be inherited inorder to use the javax.annotation.Nullable annotation?
I have been searching on net for long time, but still unable to figure out which package has to be inherited.
Any suggestions would be appretiated.
You have to add a dependency on JSR 305. For example, Guava uses this:
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>1.3.9</version>
Now, you have to use a workaround mentioned in a issue:
Create a simple javax/annotation/Annotation.gwt.xml file in your project:
<module>
<source path="" />
</module>
Add <inherits name='javax.annotation.Annotation' /> to your applications module (.gwt.xml) file.

How can share bean from external library to GWT client?

I have a question about share the java bean in library to gwt client
I know bean share between GWT client and server usually put into package domain.shared.
However, how can I make use of existing bean from external jar library on GWT client?
Because I always got this message.
No source code is available for type xxxx.xxxx.bean did you forget to inherit a required module?
Given that your beans are in the package xxx.xxx.bean, and they are in an imported my_beans.jar library.
Create a folder in your Application src tree (or src/main/java if you are using maven) with the name xxx/xxx
Create a new Module file in this folder called MyBeans.gwt.xml with this content:
<module>
<inherits name='com.google.gwt.user.User'/>
<source path="bean"/>
</module>
Edit your Application.gwt.xml and add this line
<inherits name="xxx.xxx.MyBeans"/>
Be aware that all Classes in the xxx.xxx.bean package must use classes supported by GWT.
You should check as well that the my_beans.jar library includes the java source files of the beans you are going to use.
1) You can only include beans from the external jar library provided it is GWT compatible and declares a <ThirdPartyModuleName>.gwt.xml file which includes the package for the beans you need to use.
2) You should have the <ThirdPartyModuleName> included in your own <Module>.gwt.xml using <inherits> tag.

Categories