junkdog / artemis-odb

A continuation of the popular Artemis ECS framework
BSD 2-Clause "Simplified" License
771 stars 109 forks source link

gwt compile errors #101

Closed ghost closed 10 years ago

ghost commented 10 years ago

Some code in artemis-odb-gwt use non gwt method/classes:

Errors in 'jar:file:/home/devnewton/.m2/repository/net/onedaybeard/artemis/artemis-odb-gwt/0.6.3/artemis-odb-gwt-0.6.3-sources.jar!/com/artemis/backends/gwt/emu/com/artemis/utils/reflect/ClassReflection.java' [ERROR] Line 34: No source code is available for type java.lang.ClassNotFoundException; did you forget to inherit a required module? [ERROR] Line 41: The method getSimpleName() is undefined for the type Class [ERROR] Line 91: No source code is available for type java.lang.SecurityException; did you forget to inherit a required module?

junkdog commented 10 years ago

Ouch, I really ought to test GWT more extensively before releasing new version :(

I'll have a new version up during the weekend. 0.6.3 doesn't really bring anything new over 0.6.0, aside from a few rare bugs. The cli tool, if you're using it, should still be usable with 0.6.0.

junkdog commented 10 years ago

Fixed in the repo, I'll try to push a new release tomorrow.

ghost commented 10 years ago

I get new errors using 0.6.5.

[ERROR] Errors in 'jar:file:/C:/Users/bob/.m2/repository/net/onedaybeard/artemis/artemis-odb-gwt/0.6.5/artemis-odb-gwt-0.6.5-sources.jar!/com/artemis/backends/gwt/emu/com/artemis/utils/reflect/ClassReflection.java' [ERROR] Line 34: No source code is available for type java.lang.ClassNotFoundException; did you forget to inherit a required module? [ERROR] Line 41: The method getSimpleName() is undefined for the type Class [ERROR] Line 91: No source code is available for type java.lang.SecurityException; did you forget to inherit a required module? Computing all possible rebind results for 'com.google.gwt.storage.client.Storage.StorageSupportDetector' Rebinding com.google.gwt.storage.client.Storage.StorageSupportDetector Checking rule [WARN] Unknown type 'com.artemis.gwtref.client.IReflectionCache' specified in deferred binding rule Computing all possible rebind results for 'com.google.gwt.logging.impl.LoggerImplNull' Rebinding com.google.gwt.logging.impl.LoggerImplNull Checking rule [WARN] Unknown type 'com.artemis.gwtref.client.IReflectionCache' specified in deferred binding rule [ERROR] Errors in 'jar:file:/C:/Users/bob/.m2/repository/net/onedaybeard/artemis/artemis-odb-gwt/0.6.5/artemis-odb-gwt-0.6.5-sources.jar!/com/artemis/backends/gwt/emu/com/artemis/utils/reflect/Field.java' [ERROR] Line 117: No source code is available for type java.lang.IllegalAccessException; did you forget to inherit a required module?

junkdog commented 10 years ago

Hmm, strange... Class#getSimpleName was added in GWT 2.6.0. Which version of libgdx and gwt are you on?

How are you building your targets? I updated spaceship warrior redux yesterday to build against the latest release + gwt. Maybe there's something in the POMs?

ghost commented 10 years ago

I have updated my project POM and tried to use GWT 2.6.0 then 2.6.1 but I still get the same errors.

I tried to build spaceship warrior redux using mvn package -Phtml. It failed on assets generation but I cannot figure out why.

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default) on project spaceship-warrior-assets: An exception occured while executing the Java class. com/badlogic/gdx/utils/GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException

junkdog commented 10 years ago

Hmm, I wonder if PlayN does things differently from libgdx. I'll have to investigate during the weekend.

I tried to build spaceship warrior redux using mvn package -Phtml. It failed on assets generation but I cannot figure out why.

Did you make any changes to the POMs, such as upping libgdx tools to 1.2.0? Could you try building with -e, maybe the stacktrace will shed some more light it.

ghost commented 10 years ago

I use the pom as it is after git clone.

Here is the stack trace:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default) on project spaceship-warrior-assets: An exception occured while executing the Java class. com/badlogic/gdx/utils/GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default) on project spaceship-warrior-assets: An exception occured while executing the Java class. com/badlogic/gdx/utils/GdxRuntimeException
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. com/badlogic/gdx/utils/GdxRuntimeException
    at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:352)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: java.lang.NoClassDefFoundError: com/badlogic/gdx/utils/GdxRuntimeException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
    at java.lang.Class.getMethod0(Class.java:2774)
    at java.lang.Class.getMethod(Class.java:1663)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.utils.GdxRuntimeException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 6 more
junkdog commented 10 years ago

Are you sure you're on the branch called updating?

ghost commented 10 years ago

It works using the updating branch!

I still cannot figure what is different between our POM, but this is a progress.

Here is the full maven debug output: http://pastebin.com/raw.php?i=2Y4Bm3UN

ghost commented 10 years ago

I think I got it: missing classes like java.lang.ClassNotFoundException does not comes from gwt jre emulation, but from libgdx.

If this is right, there is two issues:

junkdog commented 10 years ago

Good digging! Hmm, I wonder under what license those classes are - there are a few with headers matching s/SUN/ORACLE too.

I've cloned Ned et les Maki, I'll see if I can get GWT compilation working by re-implementing any classes supplied by libgdx.

junkdog commented 10 years ago

Tried getting artemis' gwt compilation working, unfortunately without success. I'll need to setup a bare-bones PlayN project with GWT and then see how one can go about adding artemis to the mix. I suspect it's a matter of a missing gwt conf somewhere (in addition to the missing classes), or something else is stopping artemis gwt from being compiled.

DaanVanYperen commented 10 years ago

Need some help with this? Edit: Don't let me slow you down if you are close ;)

junkdog commented 10 years ago

Sure, always appreciated ;)

I'm a little lost in GWT land; I think I'm starting to get my bearings, but I gather that GWT debugging isn't one of its strong points - or my map just sucks. I managed to get to the point where it stops complaining about missing classes (I stubbed ClassNotFoundException etc), instead bailing on missing artemius IReflectionCache - although it could be that I screwed up somewhere in the gwt xml files.

DaanVanYperen commented 10 years ago

I'm probably at a similar level with GWT, all the more reason to get some more experience in. ;)

So you are trying to get Ned et les Maki to compile with GWT, and it breaks at Artemis?

junkdog commented 10 years ago

Yes, Ned et les Maki has a pretty complex module architecture + several GWT-related xml files though, so I'm thinking it might be easier to start off with a simple hello world in PlayN and work from there.

DaanVanYperen commented 10 years ago

I'll whip up a PlayN artemis quickstart after work. Got to update https://github.com/DaanVanYperen/libgdx-artemis-quickstart anyway!

junkdog commented 10 years ago

Sweet! Might want to have a look at the PlayN samples - https://code.google.com/p/playn/wiki/GettingStarted - they appear to be prepped for GWT.

DaanVanYperen commented 10 years ago

Got the quickstart updated easy enough. Slightly overestimated my time tonight, playn queued for tomorrow!

junkdog commented 10 years ago

Slightly overestimated my time tonight

I do that every night. The Earth spins too quickly.

I was stuck elsewhere in artemis yesterday.

DaanVanYperen commented 10 years ago

So set up the playn hello-world example with gwt 2.6 and artemis 1.6.5, mirroring all the gwt settings I'm aware of. https://github.com/DaanVanYperen/playn-artemis-quickstart

The reflection cache seems to generate, but it barfs at runtime with a reflection cache error. Right now i'm thinking either obfuscation or missing reflected classes being the culprit. Trying to get superdev to work with playn, right now it's a tad hard to debug.

GWT stacktrace:

(-:-) 2014-07-22 21:57:19,316 [FATAL] Uncaught Exception:
Class$S37: (artemis-odb) Couldn't find Type for class 'Class$8'
    at Unknown.$fillInStackTrace(StackTraceCreator.java:180)
    at Unknown.fillInStackTrace(StackTraceCreator.java:518)
    at Unknown.RuntimeException_1(Throwable.java:56)
    at Unknown.getType_0(Class.java:250)
    at Unknown.isAssignableFrom(ClassReflection.java:52)
    at Unknown.ComponentType_0(ComponentType.java:38)
    at Unknown.$getTypeFor(ComponentTypeFactory.java:40)
    at Unknown.associate(ComponentTypeFactory.java:70)
    at Unknown.$initialize(Aspect.java:70)
    at Unknown.$setWorld(EntitySystem.java:350)
    at Unknown.$setSystem(World.java:405)
    at Unknown.$run(HtmlPlatform.java:261)
    at Unknown.run(PlayN.java:47)
    at Unknown.execute_3(HelloGameHtml.java:29)
    at Unknown.runScheduledTasks(SchedulerImpl.java:180)
    at Unknown.$flushPostEventPumpCommands(SchedulerImpl.java:345)
    at Unknown.execute_0(SchedulerImpl.java:78)
    at Unknown.execute(SchedulerImpl.java:138)
    at Unknown.apply_0(Impl.java:290)
    at Unknown.entry0(Impl.java:347)
    at Unknown.anonymous(Impl.java:93)
    at Unknown.anonymous(UnloadSupport.java:42)

Think we ran into this before but for the life of me can't remember what was the cause.

Other than that, had to copy ClassNotFoundException, IllegalAccessException and SecurityException from LibGDX to get things to compile. Can't imagine the license will be too much of an issue there, can just stub them like you said. not much more than a stub to begin with.

DaanVanYperen commented 10 years ago

Now it works fine. Meuh? ._o

junkdog commented 10 years ago

Weird... but great! It runs out of the box for me too. Could it have been a dirty state from an earlier build?

Found this in the log - I should probably replace them with an emu class.

[INFO]             not emitting code for accessing field added in class 'com.artemis.EntityManager.class as its of type long which can't be used with JSNI
[INFO]             not emitting code for accessing field created in class 'com.artemis.EntityManager.class as its of type long which can't be used with JSNI
[INFO]             not emitting code for accessing field deleted in class 'com.artemis.EntityManager.class as its of type long which can't be used with JSNI

Not sure if it's related to Ignored 1 unit with compilation errors in first pass - couldn't find any reference to which class it meant. Might be the EntityManager. Or I should turn on logging, but it will have to wait until tomorrow.

DaanVanYperen commented 10 years ago

Works fine for me now. Artemis 1.6.5 with GWT 2.6.0 and playn 1.8.5.

Could you give it a try @junkdog? Just to be sure there isn't any local repo or gwt cache funny-business going on. https://github.com/DaanVanYperen/playn-artemis-quickstart mvn -Phtml integration-test localhost:8080

To get rid of the libgdx dependency merge the quickstarts playn.sample.hello.emu package with artemis-odb / artemis-gwt / src / main / java / com / artemis / backends / gwt / emu. We just need to make sure this doesn't break libgdx projects due to things doubling up.

Besides that, it's the typical checklist for projects:

Tweak gwt maven config to fix the reflection issues. Not sure if all these are required.

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.6.0</version>
          <configuration>
              <enableClosureCompiler>true</enableClosureCompiler>
              <disableClassMetadata>false</disableClassMetadata>
              <disableCastChecking>true</disableCastChecking>
          </configuration>
DaanVanYperen commented 10 years ago

Weird... but great! It runs out of the box for me too. Could it have been a dirty state from an earlier build?

Probably. GWT is both magical and a pain in the butt, especially with IntellIJ silently leaving old vm's running.

@devnewton able to progress? Gwt config for your project looks a bit daunting. XD

junkdog commented 10 years ago

I tried running mvn dependency:tree on it yesterday because it looked as if earlier versions of GWT libs were downloaded too - unfortunately, it died upon hitting a faulty custom maven repo. I'll do some more digging, but it doesn't appear malignant.

GWT is both magical and a pain in the butt

Especially the latter...

PS. Interesting that PlayN can compile to flash. I'll see if I can get it working under linux.

ghost commented 10 years ago

I'll try to fix my project using playn-artemis-quickstart.

About PlayN, I think that flash support is dropped.

DaanVanYperen commented 10 years ago

About PlayN, I think that flash support is dropped.

Noticed there was some GWT in there as well,

@devnewton Do you have both LibGDX and PlayN experience? I'm curious to know what made you go with PlayN. (don't know squat about PlayN).

How's the sound playback with PlayN on browsers? I know LibGDX has some latency issues.

DaanVanYperen commented 10 years ago

@junkdog do you have any contacts with the LibGDX team? would be good if they could split gwt reflection into a separate project, so you don't need to deal with it in artemis'.

junkdog commented 10 years ago

About PlayN, I think that flash support is dropped.

Ah, for the better maybe.

@DaanVanYperen It was mentioned in passing, but I don't think there's been any effort towards making it happen - unless Ashley prompted something. I might take a stab at it during the weekend.

ghost commented 10 years ago

Do you have both LibGDX and PlayN experience? I'm curious to know what made you go with PlayN.

I wanted to port my first game on android and html5. LibGDX and PlayN were possible choices. PlayN was on maven central, libgdx wasn't. Laziness always win!

How's the sound playback with PlayN on browsers? I know LibGDX has some latency issues.

PlayN sound works well for me on Chrome, rarely on Firefox.

DaanVanYperen commented 10 years ago

I wanted to port my first game on android and html5. LibGDX and PlayN were possible choices. PlayN was on maven central, libgdx wasn't. Laziness always win!

LibGDX uses a one-click jar for quick project creation, Gradle instead of Maven though, can Imagine not everyone is a fan.

@DaanVanYperen It was mentioned in passing, but I don't think there's been any effort towards making it happen - unless Ashley prompted something. I might take a stab at it during the weekend.

As far as I can tell the impact should be minimal for LibGDX, slap in separate project and include in relevant gwt xmls. But then again, the guys at LibGDX might not be able to pivot very fast, it being so popular and all. ;)

ghost commented 10 years ago

I manage to make a Ned et les maki gwt build: http://play.bci.im/nedetlesmaki/

A lot of optimisation is required, but this is out of this issue scope :-)

junkdog commented 10 years ago

Time to celebrate! I'll add the link to the README later.

DaanVanYperen commented 10 years ago

Yay! Any findings you'd like to add for the next guy stuck on artemis+gwt?

ghost commented 10 years ago

Always remember that the gwt compiler is not your friend.

junkdog commented 10 years ago

True words.

DaanVanYperen commented 10 years ago

shhhhhhhh it might hear you.

junkdog commented 10 years ago

I have a cron job continuously requiring me to disable the GWT kill switch. If I'm going down - so is GWT. A case of mutually assured destruction(/deletion).