Dagger and libgdx - gwt

Is it possible to use dagger 2 and libgdx web? The libgdx project builds fine with android and desktop. When I add a web module and run with
./gradlew html:superDev
[ERROR] Line 1: The type javax.inject.Named cannot be resolved. It is indirectly referenced from required .class files
[ERROR] Line 30: The import dagger.Lazy cannot be resolved
[ERROR] Line 32: The import javax.inject.Inject cannot be resolved
[ERROR] Line 37: Inject cannot be resolved to a type
After following this http://www.g-widgets.com/2017/06/28/dependency-injection-in-gwt-using-dagger-2 . I have in my Game.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd">
<module>
<inherits name="dagger.Dagger" />
<source path="com/trashmelody" />
</module>
It will throw a different error
[ERROR] Line 34: No source code is available for type com.trashmelody.di.ComponentProvider<T>; did you forget to inherit a required module?
[ERROR] Line 34: No source code is available for type com.trashmelody.di.AppComponent; did you forget to inherit a required module?
[ERROR] Line 47: No source code is available for type com.trashmelody.managers.ScreenProvider; did you forget to inherit a required module?
[ERROR] Line 177: No source code is available for type com.trashmelody.di.DaggerAppComponent; did you forget to inherit a required module?
[ERROR] Line 178: No source code is available for type com.trashmelody.di.AppModule; did you forget to inherit a required module?
Does it mean we have to inherit all the errors in the xml?

Related

GWT compile fails in IDEA: UserAgentAsserter cannot be resolved

Moving my development environment to a new laptop and faced the following error (it's never no-hassle process).
So, what I have is: Windows 8, Intellij Idea 12, GWT 2.5.1, configured a simple artifact that only produces a "GWT compile output":
Information: Compilation completed with 6 errors and 0 warnings in 25 sec
Information: 6 errors
Information: 0 warnings
Error: GWT Compiler: The import com.google.gwt.user.client.UserAgentAsserter cannot be resolved
Error: GWT Compiler: UserAgentProperty cannot be resolved to a type
Error: GWT Compiler: The method create(Class<?>) from the type GWT refers to the missing type UserAgentProperty
Error: GWT Compiler: UserAgentProperty cannot be resolved to a type
Error: GWT Compiler: UserAgentProperty cannot be resolved to a type
<-> D:\Projects\MyProject\src\main\java\com\myproject\RichClient.gwt.xml
Error: GWT Compiler: Aborting compile due to errors in some input files
Build on old laptop is working fine (same environment on Win7), although I don't see any differences in my gwt.xml file. Maybe something is missing that was added to old config manually rather than through repository checkout, but now I can only guess. I have tried to remove/comment all the lines from client.gwt.xml that relate to user.agent property setting, like
<set-property name="user.agent" value="gecko1_8,safari"/>
but no changes and I still see the same "6 errors" message.
I would appreciate any clue on why this error may appear. Thanks.
UPD.
Reduced the code of my RichClient.gwt.xml file to
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='richclient'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
</module>
(no entry point set) and still got the same error.
Found this later. Obsolete jar that was not included in the lib path for the original project but managed to sneak into the newly configured.
Validating units:
[ERROR] Errors in 'jar:file:/D:/Projects/myProject/src/main/webapp/WEB-INF/lib/css3pie-0.1.jar!/com/google/gwt/user/client/UserAgentInfo.java'
[ERROR] Line 19: The import com.google.gwt.user.client.UserAgentAsserter cannot be resolved
[ERROR] Line 23: UserAgentProperty cannot be resolved to a type
[ERROR] Line 23: The method create(Class<?>) from the type GWT refers to the missing type UserAgentProperty
[ERROR] Line 23: UserAgentProperty cannot be resolved to a type
[ERROR] Line 26: UserAgentProperty cannot be resolved to a type
[ERROR] Line 26: UserAgentProperty cannot be resolved to a type
[ERROR] Line 40: UserAgentProperty cannot be resolved to a type
Removing the jar did the trick.

GWT compositC component test cases?

i had a GWT composite component, with two textBox, want to write test cases for it. Each of them had change handler, i want to know how can i fire a change event to exact component in the composite component class.
EDITED:
my test code looks like this,
#Test
public void testValueChangesToOutOfRange(){
DvCountUI count = new DvCountUI(15, "place holder", true);
count.specifyNormalRange(10, 30);
TextBox magnitude = GwtReflectionUtils.getPrivateFieldValue(count, "magnitude");
assertTrue(true);
}
and when i run it with GWT Junit Test am getting ERROR:
in console
Validating units:
Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[ERROR] Errors in 'file:/D:/TRANSFER/asclepian/workspace/UIBuilder/src/com/rubirules/uibuilder/client/DvCountUITest.java'
[ERROR] Line 65: No source code is available for type com.googlecode.gwt.test.utils.GwtReflectionUtils; did you forget to inherit a required module?
[ERROR] Unable to find type 'com.rubirules.uibuilder.client.DvCountUITest'
[ERROR] Hint: Previous compiler errors may have made this type unavailable
[ERROR] Hint: 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
and in junit
JUnitFatalLaunchException
my gwt.xml file looks like:
<module rename-to='uibuilder'>
<inherits name='com.google.gwt.user.User' />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<entry-point class='com.rubirules.uibuilder.client.UIBuilder' />
<source path='client' />
<source path='shared' />
</module>
whats wrong here?
also i added gwt-test-utils jar in project library.
I am not sure whether your approach towards unit testing widget is correct.
In this scenario you should ideally be setting value (triggering the internal change event) and testing whether the code written in the change handler get executed.
Example - TextBoxBaseTestBase.java
public void testValueChangeEvent() {} in
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/user/client/ui/TextBoxBaseTestBase.java
If you insist on firing change event you can refer to GWT sample CreateEventTest.java
public void testTriggerChangeEvent() {} in
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/user/client/ui/CreateEventTest.java
I got solved things by :
extending GwtTest instead of GWTTestCases
and adding a gwt-test-util.property file with a value "com.rubirules.uibuilder.UIBuilder = gwt-module", in the META-INF folder which is inside test package.

error when building a GWT app after updating GWT

after updating GWT2.0 to the GWT2.4, eclipse shows error message when building GWT app with ant.
here is the message:
[java] Compiling module com.certus.noc.noc
[java] Validating newly compiled units
[java] [ERROR] Errors in 'jar:file:/D:/EX-GWT/gwt-2.4.0/gwt-user.jar!/com/google/gwt/user/client/ui/HasDirectionalSafeHtml.java'
[java] [ERROR] Line 26: No source code is available for type com.google.gwt.safehtml.client.HasSafeHtml; did you forget to inherit a required module?
[java] [ERROR] Line 33: No source code is available for type com.google.gwt.safehtml.shared.SafeHtml; did you forget to inherit a required module?
[java] [ERROR] Errors in 'jar:file:/D:/EX-GWT/gwt-2.4.0/gwt-user.jar!/com/google/gwt/event/shared/SimpleEventBus.java'
[java] [ERROR] Line 27: No source code is available for type com.google.web.bindery.event.shared.SimpleEventBus; did you forget to inherit a required module?
[java] [ERROR] Line 32: Cannot cast from GwtEvent.Type<H> to Event.Type<H>
[java] [ERROR] Line 32: No source code is available for type com.google.web.bindery.event.shared.Event<H>.Type<H>; did you forget to inherit a required module?
[java] [ERROR] Line 36: No source code is available for type com.google.web.bindery.event.shared.HandlerRegistration; did you forget to inherit a required module?
[java] [ERROR] Line 42: Cannot cast from GwtEvent.Type<H> to Event.Type<H>
[java] [ERROR] Line 51: No source code is available for type com.google.web.bindery.event.shared.Event<H>; did you forget to inherit a required module?
[java] [ERROR] Errors in 'jar:file:/D:/EX-GWT/gwt-2.4.0/gwt-user.jar!/com/google/gwt/user/client/ui/DirectionalTextHelper.java'
[java] [ERROR] Line 32: No source code is available for type com.google.gwt.i18n.shared.HasDirectionEstimator; did you forget to inherit a required module?
and the inherites module in gwt.xml file
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.extjs.gxt.ui.GXT'/>
<inherits name='com.extjs.gxt.desktop.WebDesktop' />
<inherits name='com.certus.noc.resources.Resources' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.certus.noc.resources.Resources' />
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<inherits name='com.extjs.gxt.themes.Themes' />
<inherits name='com.google.gwt.i18n.I18N' />
<inherits name='com.extjs.gxt.charts.Chart' />
Thanks in advance for any answer
Try to add
<inherits name="com.google.web.bindery.event.Event"/>
to your main <project>.gwt.xml it should solve Events problems
Also try to place your gwt jars before gxt jars in your classpath
And check that HasDirectionalSafeHtml take HasSafeHtml and SafeHtml from gwt-servlet-2.4.0.jar, or event check if gwt-servlet-2.4.0.jar exists in your classpath.
This should solve HasDirectionalSafeHtml problems
I have solved the problem.
delete all the jars in the WEB-INF/lib, and then copy the new jar from APP Engine and other
userful . then it works

How do you use JPA objects with GWT in a different project?

I'm new to GWT, and I'm setting up a project to hold the UI portion of a complicated application. The JPA data objects are defined in a separate project using MyBatis generated POJOs. Once I manually modify the JPA objects to include 'implements Serializable' (this is a separate problem I need to solve), the gwtc step in the build process can't continue because it needs the source code for the JPA object, but can't find them.
I've created the 'core' project's jar files so that it includes the source .java files, but this didn't work. I've tried adding a classpath element to the gwtc ant java call.
How can I make my UI project compile while keeping the JPA objects defined in a separate project?
Errors:
Buildfile: /Users/user/source/user_interface/build.xml
libs:
javac:
gwtc:
[java] Compiling module org.mysite.ui
[java] Validating newly compiled units
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyService.java'
[java] [ERROR] Line 21: No source code is available for type org.mysite.core.model.Person; did you forget to inherit a required module?
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyServiceAsync.java'
[java] [ERROR] Line 19: No source code is available for type org.mysite.core.model.Person; did you forget to inherit a required module?
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/presenter/MainTabPresenter.java'
[java] [ERROR] Line 75: No source code is available for type org.mysite.core.model.Person; did you forget to inherit a required module?
[java] Scanning for additional dependencies: file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyApp.java
[java] Computing all possible rebind results for 'org.mysite.ui.client.MyService'
[java] Rebinding org.mysite.ui.client.MyService
[java] Checking rule <generate-with class='com.google.gwt.user.rebind.ui.ImageBundleGenerator'/>
[java] [ERROR] Unable to find type 'org.mysite.ui.client.MyService'
[java] [ERROR] Hint: Previous compiler errors may have made this type unavailable
[java] [ERROR] Hint: 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
[java] [ERROR] Errors in 'file:/Users/user/source/user_interface/src/org/mysite/ui/client/MyApp.java'
[java] [ERROR] Line 23: Failed to resolve 'org.mysite.ui.client.MyService' via deferred binding
[java] [ERROR] Cannot proceed due to previous errors
BUILD FAILED
/Users/user/source/user_interface/build.xml:39: Java returned: 1
Total time: 26 seconds
Ant gwtc target:
<target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<pathelement location="../core/src"/>
<path refid="project.class.path"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<arg line="-war"/>
<arg value="web"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="org.mysite.ui.MyApp"/>
</java>
</target>
GWT has always had this problem.
The approach I have taken in the past is to make a .gwt.xml module in the other JAR including the JPA POJOs and putting the JPA annotation classes in an "emul" javax.persistence folder. This won't work w/ many providers that use lazy fetching of course, so Gilead (as mentioned in another answer here) will be needed.
Another way is to make copies of the JPA objects and just Dozer them before sending across RPC
Luckily, GWT 2.1 has solved this problem. Use Entity proxies and request factories. It works well.
Either use the new GWT 2.1 RequestFactory / EntityProxy approach, or
Better, ditch the JPA and use Objectify or Twig.
We use Objectify, because JPA is not a good fit for Datastore. JPA was created with SQL-based relational databases in mind, while GAE Datastore is an entirely different thing.
Google ported JPA layer to Datastore to lure in developers, pretending that Datastore is just a plain old SQL relational database. This later blows up in their faces once projects grow big.
You really need to understand the Datastore tradeoffs if you want to use AppEngine. JPA is not making you a favor here.
Your best bet if you want to serialize POJOs to GWT is to use Gilead http://noon.gilead.free.fr/gilead/
All you have to do on your POJO is extend LightEntity and implement Serializable
The tutorial is pretty straight forward in how to set up the RPC.

GWT 3rd Party Library Problem : Code Included

I am using Eclipse Version: 3.5.1, GWT 2.0.0, GAE 1.3.0 and I am trying to use XStream 1.3.2 to 'serialize' my Java objects to and from xml between the client and server sides of GWT.
On the server side, XStream works without issue.
On the client side, the compiler complains that it cannot find source code for the XStream classes used. I understand that this is some sort of 'referencing' issue where GWT client classes cannot automatically find server classes and I understand why this is however, I am going slowly insane as I try to use the approaches described in various articles and tutorials that cover how to use 3rd party libraries in GWT.
None of them work!
My gwt.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='bandmates'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='org.redboffin.bandmates.client.BandMates' />
</module>
My Eclipse XStream Library is as follows:
XStream
|__ Access rules : No rules defined
|__ Native library location: (None)
|__ xstream-1.3.2.jar [path to jar]
|__ Source Attachment: xstream-1.3.2-sources.jar [path to source jar]
|__ Javadoc location: [path to javadoc]
|__ Native library location: (None)
|__ Access rules : No restrictions
I am more familiar with Netbeans and so I may be setting this up incorrectly, but I think I have included XStream into my Eclipse GWT project as a third party library and have correctly referenced the binary jar, the source jar and the javadoc jar
The client side method that throws the error:
public void onSuccess(String profilesXml) {
// Deserialize the xml
XStream xstream = new XStream(new DomDriver());
ProfilesImpl profiles = (ProfilesImpl) xstream.fromXML(profilesXml);
// Show the RPC result to the user
this.friendsWidget.setFriendProfiles(profiles);
this.friendsWidget.update();
}
And the GWT Compiler error:
Compiling module org.redboffin.bandmates.BandMates
Validating newly compiled units
[ERROR] Errors in 'file:/C:/Documents%20and%20Settings/Darren/workspace/BandMates/src/org/redboffin/bandmates/client/widgets/FriendsWidget.java'
[ERROR] Line 63: No source code is available for type com.thoughtworks.xstream.XStream; did you forget to inherit a required module?
[ERROR] Line 63: No source code is available for type com.thoughtworks.xstream.io.xml.DomDriver; did you forget to inherit a required module?
Finding entry point classes
[ERROR] Unable to find type 'org.redboffin.bandmates.client.BandMates'
[ERROR] Hint: Previous compiler errors may have made this type unavailable
[ERROR] Hint: 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
I'm not sure what other information you may need to help me but if you need something I haven't provided then please ask.
Thanks for reading this far :-)
Don't you need to import your XStreams package in your gwt.xml file. E.g. something like:
<inherits name='com.thoughtworks.xstream'/>
?
GWT compiles Java source to JavaScript. You canĀ“t just point to a regular jar. If you really must use XStream, you will need to include the sources under the client package or create a separate module and import it.
But for me this is just reinvent the wheel. You will have a lot of work and it will be slower than RPC. Even if there are other clients using the XML output, maybe you should consider having both ways.