第一次在堆栈溢出上摆姿势,所以请原谅任何遗漏的约定。让我知道,我会补救的。
我在以编程方式运行模型时遇到问题。我认为这是因为imageio无法读取jar或外部项目中的图像文件,我无法找到修复它的方法。
当我运行模型时,一切正常,但当我从另一个项目以编程方式运行它时,我得到:
首先是警告:
log4j:WARN No appenders could be found for logger (org.java.plugin.boot.DefaultPluginsCollector).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
然后GUI启动,当我按下“开始运行”或“初始化运行”时,我得到:
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Caught NullPointerException: null on thread AWT-EventQueue-0
接着是我在阅读repast sourceforge邮件列表时认为与此无关的许多其他内容,其中他们说,GUI错误日志是需要阅读的内容。GUI中的记录器显示:
2019/03/05 09:12:32,297: Error while initializing edited style
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at repast.simphony.visualizationOGL2D.ImageSpatialSource.registerSource(ImageSpatialSource.java:52)
at repast.simphony.visualization.editedStyle.EditedStyleOGL2D.init(EditedStyleOGL2D.java:95)
at repast.simphony.visualizationOGL2D.DisplayOGL2D.registerStyle(DisplayOGL2D.java:475)
at repast.simphony.visualization.engine.DisplayCreatorOGL2D$2.register(DisplayCreatorOGL2D.java:81)
at repast.simphony.visualization.engine.DisplayCreatorOGL2D$2.register(DisplayCreatorOGL2D.java:1)
at repast.simphony.visualization.engine.StyleRegistrar.registerStyles(StyleRegistrar.java:93)
at repast.simphony.visualization.engine.StyleRegistrar.registerStyles(StyleRegistrar.java:34)
at repast.simphony.visualization.engine.DisplayCreatorOGL2D.createDisplay(DisplayCreatorOGL2D.java:79)
at repast.simphony.visualization.engine.DisplayProducer.createDisplay(DisplayProducer.java:48)
at repast.simphony.visualization.engine.DisplayComponentControllerAction.runInitialize(DisplayComponentControllerAction.java:116)
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(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
此错误的违规代码(在模型中)必须是:
@Override
public Context build(Context<Object> context) {
try {
img = ImageIO.read(new File("maps/trondheimv2.png"));
} catch (IOException e) {
System.out.println(e + ": Image file not found!");
}
...
我尝试过使用绝对路径:
C:/Users/USER/Documents/Git/REPO/Traffic_Main/maps/trondheimv2.png
这种方法:
getClass().getResource("C:/Users/USER/Documents/Git/REPO/Traffic_Main/maps/trondheimv2.png").toURI()));
我正在使用FAQ示例的重命名版本以编程方式运行模型:
package execute;
public class UserMain {
public UserMain () {};
public void start () {
String [] args = new String []{ "C:/Users/USERNAME/Documents/Git/REPO/Traffic_Main/CitySim.rs"};
repast . simphony . runtime . RepastMain . main ( args ) ;
}
public static void main ( String [] args ) {
UserMain um = new UserMain () ;
um . start () ;
}
}
该类位于另一个C:/Users/USERNAME/Documents/Git/REPO/Runner/src/execute项目中
我已经加上了就餐时的罐子。辛菲尼。运行时_2.6.0/lib并添加了就餐。辛菲尼。运行时_2.6.0/bin文件夹到类路径。
我的目标是运行Runner项目中的多个模型
感谢您抽出时间。
编辑:进行了Eric Tatara建议的更改并出现以下错误:
WARN [AWT-EventQueue-0] 11:04:59,452 repast.simphony.ui.RSGUIConstants - Error loading: player_play, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,453 repast.simphony.ui.RSGUIConstants - Error loading: player_pause, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,454 repast.simphony.ui.RSGUIConstants - Error loading: player_stop, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,455 repast.simphony.ui.RSGUIConstants - Error loading: player_step, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,455 repast.simphony.ui.RSGUIConstants - Error loading: project_open, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,455 repast.simphony.ui.RSGUIConstants - Error loading: filesave, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,456 repast.simphony.ui.RSGUIConstants - Error loading: filesave16, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,456 repast.simphony.ui.RSGUIConstants - Error loading: filter16, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,457 repast.simphony.ui.RSGUIConstants - Error loading: reload, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,457 repast.simphony.ui.RSGUIConstants - Error loading: exec, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,457 repast.simphony.ui.RSGUIConstants - Error loading: folder, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,458 repast.simphony.ui.RSGUIConstants - Error loading: folder_open, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,458 repast.simphony.ui.RSGUIConstants - Error loading: camera, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,458 repast.simphony.ui.RSGUIConstants - Error loading: movie, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,459 repast.simphony.ui.RSGUIConstants - Error loading: chart, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,459 repast.simphony.ui.RSGUIConstants - Error loading: database, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,460 repast.simphony.ui.RSGUIConstants - Error loading: display, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,460 repast.simphony.ui.RSGUIConstants - Error loading: info_viz, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,460 repast.simphony.ui.RSGUIConstants - Error loading: kudesigner, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,461 repast.simphony.ui.RSGUIConstants - Error loading: lockstart_session, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,461 repast.simphony.ui.RSGUIConstants - Error loading: leaf, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,462 repast.simphony.ui.RSGUIConstants - Error loading: edit, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,462 repast.simphony.ui.RSGUIConstants - Error loading: home, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,462 repast.simphony.ui.RSGUIConstants - Error loading: info, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,463 repast.simphony.ui.RSGUIConstants - Error loading: view_sidetree, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,463 repast.simphony.ui.RSGUIConstants - Error loading: harddrive, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,463 repast.simphony.ui.RSGUIConstants - Error loading: button_cancel, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,464 repast.simphony.ui.RSGUIConstants - Error loading: edit_add, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,464 repast.simphony.ui.RSGUIConstants - Error loading: apply, it will not be used.
WARN [AWT-EventQueue-0] 11:04:59,464 repast.simphony.ui.RSGUIConstants - Error loading: redo, it will not be used.
FATAL [AWT-EventQueue-0] 11:04:59,545 repast.simphony.ui.RSUIPlugin - Fatal error starting Repast
java.lang.NoSuchMethodError: com.jgoodies.forms.layout.ColumnSpec.createGap(Lcom/jgoodies/forms/layout/ConstantSize;)Lcom/jgoodies/forms/layout/ColumnSpec;
at com.jgoodies.forms.layout.FormSpecs.<clinit>(FormSpecs.java:115)
at repast.simphony.ui.RunOptionsPanel.initComponents(RunOptionsPanel.java:114)
at repast.simphony.ui.RunOptionsPanel.<init>(RunOptionsPanel.java:39)
at repast.simphony.ui.RSGui.addRunOptionsView(RSGui.java:558)
at repast.simphony.ui.RSApplication.initGui(RSApplication.java:655)
at repast.simphony.ui.RSAppConfigurator.fillBars(RSAppConfigurator.java:52)
at saf.core.ui.GUICreatorDelegate.createDisplay(GUICreatorDelegate.java:189)
at saf.core.ui.GUICreator.createDisplay(GUICreator.java:12)
at repast.simphony.ui.RSUIPlugin$1.run(RSUIPlugin.java:99)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
at java.awt.image.BufferedImage.<init>(Unknown Source)
at repast.simphony.ui.widget.IconRotator.rotate(IconRotator.java:51)
at repast.simphony.ui.widget.IconRotator.access$0(IconRotator.java:47)
at repast.simphony.ui.widget.IconRotator$1.actionPerformed(IconRotator.java:32)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
问题1:您需要复制MessageCenter。log4j。属性文件保存到运行模型的文件夹中。
问题2:您发布的异常表明错误是由于其中一个显示的已编辑样式类出现问题所致。如果使用编辑器创建显示样式并将图像文件指定给代理图标,则图像文件URL将存储在项目中的显示描述符XML文件中。rs文件夹。我怀疑XML文件中定义了图像文件的相对文件路径,如果从其他文件夹启动代码,相对路径将不正确。我建议直接编辑样式XML,或者使用绝对路径,或者相应地更改相对路径,或者在文件夹中创建一个符号链接,从中运行指向正确的位置。
问题内容: 我一周前开始使用Java,现在我想在窗口中插入一个图像。无论我尝试什么,我都会在Eclipse中继续使用它: javax.imageio.IIOException:无法读取输入文件! } 我认为代码很容易解释。我试图解决这个问题 我想做的是一个桌面程序,我的源代码存储如下:training / src / graphics / Window training / src / src /
问题内容: 我对Logstash有一个奇怪的问题。我正在提供一个日志文件作为logstash的输入。配置如下: 我已经在运行elasticsearch服务器并验证是否正在使用curl查询接收数据。问题是,当输入为时,没有数据被接收。但是,如果我将输入更改为以下内容,它将顺利发送所有输入数据: 我不明白我要去哪里错了。有人可以看看这个吗? 问题答案: 您应该在文件部分下设置start_positio
问题内容: 这是我的第一篇文章,请问如果我做错了什么。直到我尝试从源包中读取图像,此代码才能正常运行。但是现在它无法读取任何图像。我究竟做错了什么?还是关于日食的事? 例外: 谢谢… 问题答案: 改变了,如果你使用的是Windows。 更跨平台的方法将替代 对于每对。 进一步了解File api文档 编辑 (对不起,我没有读过此行) 这段代码运行正常,直到我尝试从源包中读取图像 为了从jar包中获
问题内容: 如何在不启动GUI的情况下如何编写python脚本来读取Tensorboard日志文件,提取损失和准确性以及其他数字数据? 问题答案: 您可以使用TensorBoard的Python类或脚本来提取数据: 如何从TensorBoard导出数据? 如果您想导出数据以在其他地方可视化(例如iPython Notebook),那也是可能的。您可以直接依赖TensorBoard用来加载数据的基础
问题内容: 我不知道为什么这不起作用,但是程序说它无法读取输入文件。顺便说一下,这也在Ubuntu中运行: 这是示例代码: 该目录也位于程序的bin文件夹和src文件夹中。 问题答案: 如果您改为从资源流中获取图像怎么办?例如,