SiO2: EntityContainer and ParameterizedType exception


I’m using parameterized types in the entity container, and something is breaking. As far as I can see in the git-repo, it’s already checking on the type of the parameter - but the cast error is occuring in the initialize of the container:

19:36:15,696 ERROR [LegacyApplication] Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
	at<init>( ~[sio2-1.1.0.jar:?]
	at<init>( ~[sio2-1.1.0.jar:?]
	at$MobSeekers.<init>( ~[main/:?]

Here’s my container:

//Map entities to seeking behaviours
    private class MobSeekers extends EntityContainer<SteeringBehavior<com.badlogic.gdx.math.Vector2>> {

        public MobSeekers(EntityData ed) {
            super(ed, SteeringSeek.class);

        protected SteeringBehavior<com.badlogic.gdx.math.Vector2>[] getArray() {
            return super.getArray();

        protected SteeringBehavior<com.badlogic.gdx.math.Vector2> addObject(Entity e) {
            SteeringSeek ss = e.get(SteeringSeek.class);

            //The driver to create a behaviour for
            MobDriver steerable = mobSteerables.getObject(e.getId());

            //The target location
            Entity targetEntity = ed.getEntity(ss.getTarget(), Position.class);
            Location seekable = mobSeekables.getObject(targetEntity.getId());

            SteeringBehavior<com.badlogic.gdx.math.Vector2> behaviour = new Seek(steerable, seekable);

            mobSeekerMap.put(e.getId(), behaviour);

            return behaviour;

        protected void updateObject(SteeringBehavior<Vector2> object, Entity e) {

        protected void removeObject(SteeringBehavior<Vector2> object, Entity e) {

        public void calculateSteeringAndCreateForces() {
            mobSeekerMap.entrySet().forEach((entry) -> {
                EntityId eId = entry.getKey();
                SteeringBehavior<Vector2> behaviour = entry.getValue();
                SteeringAcceleration<Vector2> steeringOutput = new SteeringAcceleration<>(new Vector2());


                Force f = new Force(steeringOutput.linear.x, steeringOutput.linear.y);

                GameEntities.createForce(eId, f, convert(behaviour.getOwner().getPosition()), ed);

And the EntityComponent is simple:

public class SteeringSeek implements EntityComponent {
    EntityId target; 

    public EntityId getTarget() {
        return target;

    public SteeringSeek(EntityId target) { = target;

This is where the error occurs in EntityContainer:

If anyone has any idea of a workaround or fix, let me know.

Just gonna tag @pspeed for this issue :slight_smile:

Okay, så if I change



EntityContainer<SteeringBehavior> it works.

Can’t really figure out why it throws the error though.

See the issues there. I had the same Problem. Paul Wanted to fix this sometime, however you can use a dummy Class as replacement i think

I’m just digging out of my huge to-do pile from being without a computer for over a week… I can’t promise that I will remember this thread so if someone wants to file a problem report on github for this (with a simple test case preferably) then that would be super helpful.


It’s already there :slight_smile:

1 Like