junkdog / artemis-odb

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

Gwt Application: artemis-odb cant find type for class #153

Closed xaguzman closed 10 years ago

xaguzman commented 10 years ago

Using artemis in my libgdx game, however I am having the problem stated in the title while running the game with libgdx's gwt backend.

I have a subclass of World, called TweenableWorld, which I use for my game rather than the default one in artemis.

Initially, my game's file hierarchy looked like this:

game -TweenableWorld.java -systems -------lots of systems -components ------- lots of components

where systems and components are packages(just in case above example wasn't clear :P)

I added the following entries into my GdxDefinition.gwt.xml file

<module rename-to="html">
    <inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' />
    <inherits name='com.artemis.backends.artemis_backends_gwt' />
    <inherits name='aurelienribon.tweenengine'/>
    <inherits name='org.xguzm.pathfinding' />
    <inherits name='MathGame' />
    <entry-point class='org.xguzm.mathgame.client.HtmlLauncher' />

    <extend-configuration-property name="gdx.reflect.include" value="org.xguzm.mathgame.map.EnemyWave" />
    <extend-configuration-property name="gdx.reflect.include" value="org.xguzm.mathgame.map.MapInfo" />
    <extend-configuration-property name="artemis.reflect.include" value="org.xguzm.mathgame.components" />
    <extend-configuration-property name="artemis.reflect.include" value="org.xguzm.mathgame.systems" />

    <set-configuration-property name="gdx.assetpath" value="../android/assets" />
</module>

but the game just keeps breaking as soon as the game creates it's first World. I already tried moving the TweenableWorld class withing the systems package, but it didn't work either. Maybe I am still missing something?

xaguzman commented 10 years ago

...since it seems i suck at explaining my project structure, here's a screenshot on how my project looks:

image

DaanVanYperen commented 10 years ago

Just for clarity, typically only systems and components need to be specified for reflection. Unless you happen to do some reflection on TweenableWorld ofcourse.

Our typical GWT reflection checklist is:

You can get a better idea what's going on by running your project in superDev mode:

You should be able to use the right panel in the sources tab (specifically Scope Variables, Call stack) to give you some more insight into what's going on.

If you are certain it's an Artemis reflection issue, you can check if your class is included by checking the generated reflection cache. <project>\html\build\gwt\gen\com\artemis\gwtref\client\IReflectionCacheGenerated.java

xaguzman commented 10 years ago

I have been wanting to try the superdev mode...however, I am really unaware of how the superdev mode works.

I ran html:superDev, and my server started, now if I visit localhost:9876 I see the super dev page which gives you bookmarks to turn on / off the super dev mode.

However, I am unable to browse to the actual game...I can't find information on what port it uses?

I even attemped to copy the contents of the html/webapp folder into html/build/gwt/draftOut, but still no luck...any tips regarding this? ( i know this has nothing to do with artemis...but still, any help would be greatly appreciated)


Xavier Guzman

http:////plus.google.com/u/0/113140404022814604923? http://mx.linkedin.com/in/xavierguz/ https://www.facebook.com/xavguz

On Fri, Sep 19, 2014 at 4:33 AM, Daan van Yperen notifications@github.com wrote:

Just for clarity, typically only systems and components need to be specified for reflection. Unless you happen to do some reflection on TweenableWorld ofcourse.

Our typical GWT reflection checklist is:

  • Are you really getting reflection cache errors, or could it be something else?
  • which reflection engine is giving errors? (artemis' reflection errors are prefixed by artemis-odb)
  • is there something lingering from a previous build?

You can get a better idea what's going on by running your project in superDev mode:

  • Start it with gradlew html:superDev
  • browse to your project.
  • Click the 'Superdev Refresh' button in the top left of the page and click compile.
  • Have your Chrome developer console (F12) open on 'sources' tab.
  • Click the 'don't pause on exceptions' icon (pause symbol in circle).
  • trigger the issue.

You should be able to use the right panel in the sources tab (specifically expanding Scope Variables, Call stack) to give you some more insight into what's going on.

If you are certain it's an Artemis reflection issue, you can check if your class is included by checking the generated reflection cache.

\html\build\gwt\gen\com\artemis\gwtref\client\IReflectionCacheGenerated.java — Reply to this email directly or view it on GitHub https://github.com/junkdog/artemis-odb/issues/153#issuecomment-56156271.
DaanVanYperen commented 10 years ago

yeah that threw me off at first. The port you connect to is not where the game runs.

Current LibGDX: http://localhost:8080/html or just visit http://localhost:8080/ and the only link you can click will be the path to our app.

xaguzman commented 10 years ago

sweet! thanks for that ... I remember trying 8080 once...but for some reason it did not work (probably got confused and closed server before hand).

I will try this as soon as i am home and let you know what the exact problem seems to be...

Thanks! :)


Xavier Guzman

http:////plus.google.com/u/0/113140404022814604923? http://mx.linkedin.com/in/xavierguz/ https://www.facebook.com/xavguz

On Fri, Sep 19, 2014 at 11:45 AM, Daan van Yperen notifications@github.com wrote:

yeah that threw me off at first. The port you connect to is not where the game runs.

Current LibGDX: http://localhost:8080/html or just visit http://localhost:8080/ and the only link you can click will be the path to our app.

— Reply to this email directly or view it on GitHub https://github.com/junkdog/artemis-odb/issues/153#issuecomment-56202849.

DaanVanYperen commented 10 years ago

If it doesn't work, assuming you run windows 7 you can open up a command window as administrator and type: netstat -abn to get a list of all listening ports (and a crapton of established connections). Just got to scan for 'LISTENING' and whatever process gwt runs as.

DaanVanYperen commented 10 years ago

Any luck @xaguzman ?

xaguzman commented 10 years ago

Haven't been able to take a look at it... later today I think I will, will let you know immediatly El sep 20, 2014 8:05 AM, "Daan van Yperen" notifications@github.com escribió:

Any luck @xaguzman https://github.com/xaguzman ?

— Reply to this email directly or view it on GitHub https://github.com/junkdog/artemis-odb/issues/153#issuecomment-56267280.

xaguzman commented 10 years ago

So, i was unable to run the super dev mode. The exception is being thrown during the World.configure() method, when the target is TweenableWorld itself...

image

As you can see, the TweenableWorld is inside the systems package (left panel), however it is still not being able to find it during the @Wire lookup...i'm unsure on why it is attemping to do do that, but that seems to be the case here?

I could always take the data I use inside TweenableWorld outside, into the gdx's Screen which uses artemis, however, I would really like being able to encapsulate those inside the world.

Just in case you are wondering how the TweenableWorld looks like, here's the code:

public class TweenableWorld extends World {

    public TweenManager tweenManager;
    public boolean isPaused;

    public TweenableWorld(){
        this(null);
    }

    public TweenableWorld(TweenManager tweenM){
        super();
        if ( tweenM == null){
            this.tweenManager = new TweenManager();
        }else{
            this.tweenManager = tweenM;
        }

        setSystem(new VoidEntitySystem() {
            @Override
            protected void processSystem() {
                tweenManager.update(delta);
            }
        });
    }
}
xaguzman commented 10 years ago

Also, just checked the IReflectionCacheGenerator, TweenableWorld seems to be in there:

  private void c58() {
      Type t = new Type();
      t.name = "org.xguzm.mathgame.systems.TweenableWorld";
      t.id = 652;
      t.clazz = org.xguzm.mathgame.systems.TweenableWorld.class;
      t.superClass = com.artemis.World.class;
      Set<Class> tAssignables = new HashSet<Class>();
      tAssignables.add(org.xguzm.mathgame.systems.TweenableWorld.class);
      tAssignables.add(com.artemis.World.class);
      tAssignables.add(java.lang.Object.class);
      t.assignables = tAssignables;
      t.isStatic = false;
      t.isAbstract = false;
      t.annotationClasses = new String[]{};
      t.fields = new Field[] {
        new Field("tweenManager", org.xguzm.mathgame.systems.TweenableWorld.class, aurelienribon.tweenengine.TweenManager.class, false, false, false, false, true, false, false, false, 654, 653, null, new String[]{}), 
        new Field("isPaused", org.xguzm.mathgame.systems.TweenableWorld.class, boolean.class, false, false, false, false, true, false, false, false, 656, 655, null, new String[]{}), 
      };
      t.methods = new Method[] {
      };
      t.constructors = new Constructor[] {
        new Constructor("TweenableWorld", 
            org.xguzm.mathgame.systems.TweenableWorld.class, 
            org.xguzm.mathgame.systems.TweenableWorld.class, 
            new Parameter[] {}, 
            false, false, false, false, false, false, true, false, false, false, true, 657),
        new Constructor("TweenableWorld", 
            org.xguzm.mathgame.systems.TweenableWorld.class, 
            org.xguzm.mathgame.systems.TweenableWorld.class, 
            new Parameter[] {
                new Parameter("tweenM", aurelienribon.tweenengine.TweenManager.class, "Laurelienribon/tweenengine/TweenManager;"), 
            }, 
            false, false, false, false, false, false, true, false, false, false, true, 658),
      };
      types.put("org.xguzm.mathgame.systems.TweenableWorld", t);
  }
DaanVanYperen commented 10 years ago

Expand e in watch expressions and see what field it is failing to inject. Is TweenManager an Artemis manager?

xaguzman commented 10 years ago

TweenManager is a class inside the universal tween engine. As for the exception thrown, I am unable to inspect...for some odd reason....however, the message thrown in the console is this:

(artemis-odb) Couldn't find Type for class 'org.xguzm.mathgame.systems.TweenableWorld$1

DaanVanYperen commented 10 years ago

$1 holds anonymous inner classes. Guessing here, but try making it a full class. (or a concrete public inner class if you prefer, not sure if that'll work.)

xaguzman commented 10 years ago

Wait, how is TweenableWorld not considered as a full class? Getting lost here :P

DaanVanYperen commented 10 years ago

Referring to the anonymous class you create here:

  setSystem(new VoidEntitySystem() {
            @Override
            protected void processSystem() {
                tweenManager.update(delta);
            }
        });
xaguzman commented 10 years ago

holy shit! that was it !! thanks a lot for the help ! :)

image

junkdog commented 10 years ago

Yay! :)

On Sat, Sep 20, 2014 at 11:05 PM, Xavier Guzman notifications@github.com wrote:

holy shit! that was it !! thanks a lot for the help ! :)

[image: image] https://cloud.githubusercontent.com/assets/104923/4346623/d68c8f6e-4109-11e4-8c89-2d38e37e16fb.png

— Reply to this email directly or view it on GitHub https://github.com/junkdog/artemis-odb/issues/153#issuecomment-56280363.