2

I coded a Repast program in ReLogo. Basically, I copy pasted the code by following instructions up to Page 19 of this document.

I am on Ubuntu 18.04 and I installed Repast Symphony as instructed. My java version is basically oracle JDK-8:-

java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

I then try to run the code as instructed on Page 20 but project fails to compile and gives this error:-

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems: 
    The annotation @ReLogoBuilderGeneratedFor is disallowed for this location
    Syntax error, insert ";" to complete FieldDeclaration
    Duplicate field ReLogoObserver.get
    Return type for the method is missing
    The annotation @ReLogoBuilderGeneratedFor is disallowed for this location
    Syntax error, insert ";" to complete FieldDeclaration
    Duplicate field ReLogoObserver.set
    void is an invalid type for the variable set
    Return type for the method is missing
    Syntax error, insert ";" to complete FieldDeclaration
    Duplicate field ReLogoObserver.get
    Return type for the method is missing
    Syntax error, insert ";" to complete FieldDeclaration
    Duplicate field ReLogoObserver.set
    Return type for the method is missing

    at zombies.ReLogoObserver.<init>(ReLogoObserver.java:639)
    at zombies.relogo.UserObserver.<init>(UserObserver.groovy)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at repast.simphony.relogo.factories.ObserverFactory.createObserver(ObserverFactory.java:28)
    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:237)
    at zombies.context.SimBuilder.build(SimBuilder.groovy:46)
    at repast.simphony.dataLoader.engine.ClassNameContextBuilder.build(ClassNameContextBuilder.java:41)
    at repast.simphony.dataLoader.engine.DataLoaderControllerAction.runInitialize(DataLoaderControllerAction.java:48)
    at repast.simphony.engine.controller.DefaultController$2.visit(DefaultController.java:214)
    at repast.simphony.engine.controller.DefaultController$2.visit(DefaultController.java:1)
    at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:292)
    at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:295)
    at repast.simphony.util.collections.NaryTree.preOrderTraverals(NaryTree.java:295)
    at repast.simphony.util.collections.NaryTree.preOrderTraversal(NaryTree.java:288)
    at repast.simphony.engine.controller.DefaultController.runInitialize(DefaultController.java:212)
    at repast.simphony.engine.controller.DefaultController.runInitialize(DefaultController.java:383)
    at repast.simphony.ui.RSApplication.initSim(RSApplication.java:157)
    at repast.simphony.ui.action.InitRun.actionPerformed(InitRun.java:17)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
    at java.awt.Component.processMouseEvent(Component.java:6539)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6304)
    at java.awt.Container.processEvent(Container.java:2239)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2297)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
    at java.awt.Container.dispatchEventImpl(Container.java:2283)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    at java.awt.EventQueue$4.run(EventQueue.java:733)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

My groovy compiler settings are thus: enter image description here

user_1_1_1
  • 903
  • 1
  • 12
  • 27

1 Answers1

1

I have two suggestions for you to try.

  1. Copying and pasting from the PDF document can have inadvertent effects, so please try typing the code in directly. You can also try to run the Zombies_Demo example model, found here. You can follow the instructions to import the example model in the "Linux users and Unix-related system users" section here. If you still see an issue...
  2. Try changing the Groovy version to 2.4.

Let us know if either of these suggestions help.

J. Ozik
  • 1,083
  • 5
  • 6
  • none are working still same errors. I found from the repository codes that I had semicolon missing after import statements. I put them there. You don't need semicolon statements in other places, right? – user_1_1_1 Sep 14 '18 at 23:14
  • 1
    You shouldn't need any semicolons in the Groovy import statements. Which file are you editing? You could also try a Project -> Clean in case you're in some unexpected inconsistent state. – J. Ozik Sep 16 '18 at 02:51
  • i am changing the human and zombie groovy files. cleaning also doesn't work. – user_1_1_1 Sep 17 '18 at 23:32
  • 1
    Okay then I'd suggest to import the demo model and see if it's an issue with your installation rather than something model specific. – J. Ozik Sep 19 '18 at 01:23
  • So yes when i import the zombies demo model it worked. Now i have not yet figured out why my code was not working. – user_1_1_1 Sep 19 '18 at 19:26
  • In that case, the only thing I can recommend is to create a new project and try to follow the tutorial steps from the beginning, and to type in the code instead of pasting it in. Let us know if you encounter any issues with that. – J. Ozik Sep 20 '18 at 20:04