From: Nick C. <nic...@gm...> - 2009-10-28 15:51:57
|
Dave, Simphony uses a lot of dynamic class loading and that can make things like this complicated. For models, external code that you want to load is specified in the score file. The implementation element has an optional "binDir" attribute and you should be able to specify your jar in the implementation element for the root context. More than one path, jar file can be specified in the birDir by separating them with a ",". Note that the binDir is relative to the implementation basePath attribute. If you can leverage this so that the location of your framework is included in the "binDir" then that should work. Note that this will change. The current development code uses a different simpler and more flexible mechanism and that will become the standard ways in the future. Converting from the old to the new should be relatively trivial though so I wouldn't let it stop you from exploring this solution. The other alternative is to make your framework a "plugin". All the repast code except for the runtime stuff that needs to be on the root classpath is loaded as plugins. If you configure your framework as a plugin then it should get loaded just as the repast code gets loaded. Plugins are defined via a plugin_jpf.xml file that specifies where the code for the plugin should be found. If you look through the source you'll see lots of examples. The plugin_jpf.xml has essentially two sections -- one that specifies what this plugin requires -- for that you'd fill in the plugins your framework depends on, and then a runtime section that specifies the code that your plugin provides, this includes non-repast 3rd party libraries that your code requires. See the source for examples. The one in repast.simphony.core is probably a good model for you. The last step is to make sure the plugin mechanism can find your plugin, the boot.properties file in repast.simphony.runtime specifies contains a pluginFolders property that specifies where to find plugins. Nick On Oct 28, 2009, at 10:42 AM, Dave Murray-Rust wrote: > Hi List, > > I'm working on a modelling framework based on RepastS, and I'd like to > create projects which use this, but define their own models. The > framework specifies a ModelInitializer in scenario.xml, and I would > like for the related projects to be able to re-use this > ModelInitialiser, but I cannot get the classpaths set up correctly. > > I have added my framework to the standard java classpath, and can > write code which uses it, and it compiles correctly. However, when the > model runs, it cannot find the model initialiser. > > When editing the Run Configuration: > > * leaving the classpath as it is results in not being able to find my > framework's ModelInitializer[1] > * if I add my framework to the Bootstrap Classpath (as a project), > then it can't find the Repast ModelInitializer (which mine implements) > [2] > * the same happens if I add it as a project to the User Entries > section [3] > > I tried copying across the model initialiser, but then I also have to > copy across all the supporting classes etc, and it's going to be a > maintenance nightmare. > > Any thoughts? > > Cheers, > dave > > > [1] > 2009/10/28 14:35:56,015: Scenario Load Error > java.lang.ClassNotFoundException: > ecochangeabm.initialisation.EcochangeABMInitializer > at > org.java.plugin.standard.StandardPluginClassLoader.loadClass(Unknown > Source) > at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:242) > at > repast.simphony.scenario.Scenario.getModelInitializer(Scenario.java: > 66) > at repast.simphony.scenario.ScenarioLoader.load(ScenarioLoader.java: > 197) > at repast.simphony.ui.RSApplication.open(RSApplication.java:247) > at > repast > .simphony.ui.RSAppConfigurator.postWindowOpen(RSAppConfigurator.java: > 40) > at saf.core.ui.GUICreatorDelegate.runDisplay(GUICreatorDelegate.java: > 188) > at saf.core.ui.GUICreator.runDisplay(GUICreator.java:14) > at repast.simphony.ui.RSUIPlugin.run(RSUIPlugin.java:87) > at > saf.core.runtime.CorePlugin.runApplicationRunnable(CorePlugin.java: > 64) > at saf.core.runtime.CorePlugin.run(CorePlugin.java:33) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun > .reflect > .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > 39) > at > sun > .reflect > .DelegatingMethodAccessorImpl > .invoke(DelegatingMethodAccessorImpl.java: > 25) > at java.lang.reflect.Method.invoke(Method.java:592) > at saf.core.runtime.Boot.run(Boot.java:125) > at saf.core.runtime.Boot.main(Boot.java:280) > at repast.simphony.runtime.RepastMain.main(RepastMain.java:43) > > [2] > 2009/10/28 14:38:09,290: Fatal error starting Repast > java.lang.NoClassDefFoundError: repast/simphony/scenario/ > ModelInitializer > at java.lang.ClassLoader.findBootstrapClass(Native Method) > at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:946) > at java.lang.ClassLoader.loadClass(ClassLoader.java:308) > at java.lang.ClassLoader.loadClass(ClassLoader.java:306) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280) > at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > at > org.java.plugin.standard.StandardPluginClassLoader.loadClass(Unknown > Source) > at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:242) > at > repast.simphony.scenario.Scenario.getModelInitializer(Scenario.java: > 66) > at repast.simphony.scenario.ScenarioLoader.load(ScenarioLoader.java: > 197) > at repast.simphony.ui.RSApplication.open(RSApplication.java:247) > at > repast > .simphony.ui.RSAppConfigurator.postWindowOpen(RSAppConfigurator.java: > 40) > at saf.core.ui.GUICreatorDelegate.runDisplay(GUICreatorDelegate.java: > 188) > at saf.core.ui.GUICreator.runDisplay(GUICreator.java:14) > at repast.simphony.ui.RSUIPlugin.run(RSUIPlugin.java:87) > at > saf.core.runtime.CorePlugin.runApplicationRunnable(CorePlugin.java: > 64) > at saf.core.runtime.CorePlugin.run(CorePlugin.java:33) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun > .reflect > .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > 39) > at > sun > .reflect > .DelegatingMethodAccessorImpl > .invoke(DelegatingMethodAccessorImpl.java: > 25) > at java.lang.reflect.Method.invoke(Method.java:592) > at saf.core.runtime.Boot.run(Boot.java:125) > at saf.core.runtime.Boot.main(Boot.java:280) > at repast.simphony.runtime.RepastMain.main(RepastMain.java:43) > > [3] > 2009/10/28 14:40:00,894: Fatal error starting Repast > java.lang.NoClassDefFoundError: repast/simphony/scenario/ > ModelInitializer > at java.lang.ClassLoader.defineClass1(Native Method) > at java.lang.ClassLoader.defineClass(ClassLoader.java:675) > at > java.security.SecureClassLoader.defineClass(SecureClassLoader.java: > 124) > at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) > at java.net.URLClassLoader.access$100(URLClassLoader.java:56) > at java.net.URLClassLoader$1.run(URLClassLoader.java:195) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:188) > at java.lang.ClassLoader.loadClass(ClassLoader.java:316) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280) > at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > at > org.java.plugin.standard.StandardPluginClassLoader.loadClass(Unknown > Source) > at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:242) > at > repast.simphony.scenario.Scenario.getModelInitializer(Scenario.java: > 66) > at repast.simphony.scenario.ScenarioLoader.load(ScenarioLoader.java: > 197) > at repast.simphony.ui.RSApplication.open(RSApplication.java:247) > at > repast > .simphony.ui.RSAppConfigurator.postWindowOpen(RSAppConfigurator.java: > 40) > at saf.core.ui.GUICreatorDelegate.runDisplay(GUICreatorDelegate.java: > 188) > at saf.core.ui.GUICreator.runDisplay(GUICreator.java:14) > at repast.simphony.ui.RSUIPlugin.run(RSUIPlugin.java:87) > at > saf.core.runtime.CorePlugin.runApplicationRunnable(CorePlugin.java: > 64) > at saf.core.runtime.CorePlugin.run(CorePlugin.java:33) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun > .reflect > .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > 39) > at > sun > .reflect > .DelegatingMethodAccessorImpl > .invoke(DelegatingMethodAccessorImpl.java: > 25) > at java.lang.reflect.Method.invoke(Method.java:592) > at saf.core.runtime.Boot.run(Boot.java:125) > at saf.core.runtime.Boot.main(Boot.java:280) > at repast.simphony.runtime.RepastMain.main(RepastMain.java:43) > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market and > stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Repast-interest mailing list > Rep...@li... > https://lists.sourceforge.net/lists/listinfo/repast-interest |