project-SIMPLE / simple.webplatform

Server for monitoring Gama Server simulations and managing multiplayer connections
4 stars 2 forks source link

Error when loading a experiment from the middleware #12

Open ptaillandier opened 1 month ago

ptaillandier commented 1 month ago

I tried to add a new "model" to the learning package, but I get errors when I let the middleware launch the experiment, whereas I have no error when loaded directly from GAMA.

The folder used in learning-packages: TutoVR.zip

The error In Eclipse (GAMA):

java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at gama.core.common.util.FileUtils.lambda$1(FileUtils.java:164)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:212)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1709)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:702)
    at gama.core.common.util.FileUtils.constructAbsoluteFilePath(FileUtils.java:164)
    at gama.core.util.file.GamaFile.<init>(GamaFile.java:120)
    at gama.core.util.file.GamaFile.<init>(GamaFile.java:80)
    at gama.core.util.file.GamaGeometryFile.<init>(GamaGeometryFile.java:47)
    at gama.core.util.file.GamaGisFile.<init>(GamaGisFile.java:282)
    at gama.core.util.file.GamaShapeFile.<init>(GamaShapeFile.java:292)
    at gaml.additions.core.GamlAdditions.lambda$1171(GamlAdditions.java:1224)
    at gama.gaml.types.ParametricFileType.createFile(ParametricFileType.java:251)
    at gama.gaml.types.ParametricFileType.cast(ParametricFileType.java:184)
    at gama.gaml.types.ParametricFileType.cast(ParametricFileType.java:1)
    at gama.gaml.types.ParametricType.cast(ParametricType.java:423)
    at gama.gaml.types.ParametricType.cast(ParametricType.java:1)
    at gama.gaml.operators.Cast.as(Cast.java:246)
    at gaml.additions.core.GamlAdditions.lambda$371(GamlAdditions.java:421)
    at gama.gaml.expressions.operators.BinaryOperator._value(BinaryOperator.java:150)
    at gama.gaml.expressions.AbstractExpression.value(AbstractExpression.java:87)
    at gama.core.runtime.ExecutionScope.evaluate(ExecutionScope.java:623)
    at gama.gaml.variables.Variable.initializeWith(Variable.java:652)
    at gama.core.metamodel.population.GamaPopulation.createVariablesFor(GamaPopulation.java:607)
    at gama.core.kernel.simulation.SimulationPopulation.initSimulation(SimulationPopulation.java:192)
    at gama.core.kernel.simulation.SimulationPopulation.createAgents(SimulationPopulation.java:151)
    at gama.core.metamodel.population.IPopulation.createAgents(IPopulation.java:230)
    at gama.core.kernel.experiment.ExperimentAgent.createSimulation(ExperimentAgent.java:500)
    at gama.core.kernel.experiment.ExperimentAgent._init_(ExperimentAgent.java:374)
    at gaml.extension.unity.species.VRExperiment._init_(VRExperiment.java:174)
    at gama.core.metamodel.agent.MinimalAgent.init(MinimalAgent.java:241)
    at gama.core.kernel.experiment.ExperimentAgent.init(ExperimentAgent.java:456)
    at gama.core.runtime.ExecutionScope.init(ExecutionScope.java:602)
    at gama.core.kernel.experiment.DefaultExperimentController.schedule(DefaultExperimentController.java:196)
    at gama.core.kernel.experiment.ExperimentAgent.schedule(ExperimentAgent.java:536)
    at gama.core.kernel.experiment.ExperimentPlan.open(ExperimentPlan.java:714)
    at gama.core.kernel.experiment.ExperimentPlan.open(ExperimentPlan.java:772)
    at gama.core.kernel.experiment.DefaultExperimentController.processUserCommand(DefaultExperimentController.java:72)
    at gama.core.kernel.experiment.AbstractExperimentController.lambda$0(AbstractExperimentController.java:63)
    at java.base/java.lang.Thread.run(Thread.java:1570)
Adding exception to error collector1 occurence in Simulation 0 at cycle 0: Java error: index out of bounds
in Simulation 0
in agent Simulation 0
in file<int, geometry> road_shapefile <- file<int, geometry>('../includes/roads.shp') ;
ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
gama.core.common.util.FileUtils.lambda$1(FileUtils.java:164)
java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:212)
java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1709)
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556)
java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546)
java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
when applying the as operator on '../includes/roads.shp' and file<int, geometry>

!ENTRY org.eclipse.ui.workbench 4 0 2024-09-05 11:34:01.331
!MESSAGE An internal error has occurred.
!STACK 0
java.lang.NullPointerException: Cannot invoke "org.eclipse.core.resources.IFile.getName()" because the return value of "org.eclipse.xtext.ui.editor.model.IXtextDocument.getAdapter(java.lang.Class)" is null
    at gaml.compiler.ui.editor.GamlEditor.lambda$2(GamlEditor.java:644)
    at gama.ui.shared.utils.WorkbenchHelper$2.runInUIThread(WorkbenchHelper.java:409)
    at org.eclipse.ui.progress.UIJob.lambda$0(UIJob.java:148)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4382)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4005)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:152)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:639)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:546)
    at gama.ui.application.Application.start(Application.java:148)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:668)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:605)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1481)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1454)
RoiArthurB commented 2 weeks ago

I inspected it, and it's a bug on the GAMA server side. I will open an issue about it.

In the meantime, I did found a workaround which is to set all of your relative path to absolute; then everything works just fine. :)

AlexisDrogoul commented 2 weeks ago

Could it be related to https://github.com/gama-platform/gama/issues/318 ? If yes, one possible option (that would make sense) is that the middleware manages its own GAMA workspace with the different projects (instead of having to import the models in whatever workspace the modeler is using).

RoiArthurB commented 2 weeks ago

@AlexisDrogoul I don't think it is related, the error happened while trying to read an import file : Here's in the error log

Adding exception to error collector1 occurence in Simulation 0 at cycle 0: Java error: index out of bounds
in Simulation 0
in agent Simulation 0
in file<int, geometry> road_shapefile <- file<int, geometry>('../includes/roads.shp') ;
AlexisDrogoul commented 2 weeks ago

Well -- looks like something similar though, i.e. access to files using relative paths outside the workspace...