0

我正在使用自定义 Jetty 容器在开发模式下运行 GWT 应用程序。该应用程序第一次加载正常,但是,如果我刷新它,我会在开发模式窗口中收到以下错误(路径已更改):

00:16:44.854 [ERROR] Unable to create file 'C:\somePath\src\war\msjavaSnack\C4EA130FD0ED44BE513FEEDDE13614DA.cache.png'
java.io.FileNotFoundException: C:\somePath\src\war\msjavaSnack\C4EA130FD0ED44BE513FEEDDE13614DA.cache.png (The requested operation cannot be performed on a file with a user-mapped section open) 
at java.io.FileOutputStream.open(Native Method) 
at java.io.FileOutputStream.<init>(FileOutputStream.java:194) 
at java.io.FileOutputStream.<init>(FileOutputStream.java:145) 
at com.google.gwt.core.ext.linker.impl.StandardLinkerContext.writeArtifactToFile(StandardLinkerContext.java:658) 
at com.google.gwt.core.ext.linker.impl.StandardLinkerContext.produceOutputDirectory(StandardLinkerContext.java:595) 
at com.google.gwt.dev.DevMode.produceOutput(DevMode.java:476) 
at com.google.gwt.dev.DevModeBase.relink(DevModeBase.java:1131) 
at com.google.gwt.dev.DevModeBase.access$000(DevModeBase.java:67) 
at com.google.gwt.dev.DevModeBase$2.accept(DevModeBase.java:1076) 
at com.google.gwt.dev.shell.ShellModuleSpaceHost$1.accept(ShellModuleSpaceHost.java:122) 
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:59) 
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:154) 
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:119) 
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:531) 
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:414) 
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:39) 
at com.google.gwt.core.client.GWT.create(GWT.java:98) 
at com.extjs.gxt.ui.client.GXT.<clinit>(GXT.java:38) 
at com.extjs.gxt.ui.client.widget.Component.<clinit>(Component.java:202) 
at msjava.snack.gui.client.MSHeaderPanelViewport.<init>(MSHeaderPanelViewport.java:62) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:422) 
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:361) 
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185) 
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380) 
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) 
at java.lang.Thread.run(Thread.java:662)

更新

在 ProcessExplorer 中,我可以看到托管 Jetty 的 JVM 进程有一个打开的文件句柄,所以这可能是其他 JVM(托管开发模式)无法写入它的原因。有什么办法可以解决吗?

4

2 回答 2

0

似乎同一文件上的两个(打开/关闭)(打开/关闭)例程一个接一个地发生得太快导致了这种情况......一些开发人员建议调用 gc。检查每个 i/o 操作是否正确关闭。不要过早执行完成(打开,循环(写入),关闭)。似乎当一个操作将在第二个请求到达时完成,这会引发问题。

于 2013-05-13T15:03:53.990 回答
0

我在此页面上找到了解决方案:

http://docs.codehaus.org/display/JETTY/Files+locked+on+Windows

编辑:

上面的网址现在已经死了。

现在很容易在 Jetty 的 wiki 中找到解决方案:

Jetty 在 webdefault.xml 文件中为 DefaultServlet 提供了一个配置开关,用于启用或禁用内存映射文件的使用。如果您在 Windows 上运行并且遇到文件锁定问题,则应设置此开关以禁用内存映射文件缓冲区。

默认的 webdefault.xml 文件位于 org/eclipse/jetty/webapp/webdefault.xml 的 lib/jetty.jar 中。将其提取到一个方便的磁盘位置并对其进行编辑以将 useFileMappedBuffer 更改为 false。

https://wiki.eclipse.org/Jetty/Howto/Deal_with_Locked_Windows_Files

于 2013-05-16T14:39:33.260 回答