从war文件部署时,Wildfly返回http请求的缓存值

时间:2015-11-24 12:17:42

标签: java eclipse wildfly jnlp wildfly-9

我的Java Web Start应用程序出现问题。我有一个在Wildfly 9容器中运行的JavaEE应用程序。我将属性文件传递给Web Start应用程序,该应用程序包含csv文件的URL和模板文件的URL。

当我第一次运行应用程序时,应用程序下载属性文件,从属性文件条目加载URL并下载csv文件和模板文件,并与文件进行邮件合并。

当我运行Web Start应用程序时,第二次,第三次......时间总是从第一次运行中下载属性文件。每次用户启动Web Start应用程序时,甚至都会覆盖属性文件。

我发现当我通过eclipse的“完全发布”将我的应用程序部署到Wildfly时,Web Start应用程序工作正常,但是当我通过“Project - > Export - > WAR文件部署我的应用程序时“并将.war文件放在我的Wildfly安装中的部署文件夹中,我确实得到了上面解释的行为。

一些额外的信息: 通过“导出WAR文件”控制台输出进行部署,第一次运行:

Java Web Start 11.65.2.17
JRE-Version verwenden 1.8.0_65-b17 Java HotSpot(TM) Client VM
Benutzer-Home-Verzeichnis = C:\Users\arthurw
c:   Konsolenfenster löschen
f:   Objekte in Finalisierungs-Queue finalisieren
g:   Garbage Collect
h:   Diese Hilfemeldung anzeigen
m:   Speicherauslastung drucken
o:   Logging auslösen
p:   Proxykonfiguration neu laden
q:   Konsole ausblenden
r:   Policy-Konfiguration neu laden
s:   System- und Deployment-Eigenschaften ausgeben
t:   Threadliste ausgeben
v:   Threadstack ausgeben
0-5: Traceebene auf <n> setzen

CacheEntry[http://localhost:8080/browser/resources/webstart/715.jnlp]: updateAvailable=true,lastModified=Tue Nov 24 12:23:01 CET 2015,length=831
CacheEntry[http://localhost:8080/browser/resources/webstart/Textverwaltungsschnittstelle.jar]: updateAvailable=true,lastModified=Tue Nov 24 12:21:14 CET 2015,length=2728463
Missing Permissions manifest attribute in main jar: http://localhost:8080/browser/resources/webstart/Textverwaltungsschnittstelle.jar
CacheEntry[http://localhost:8080/browser/resources/webstart/715.properties]: updateAvailable=true,lastModified=Tue Nov 24 12:23:34 CET 2015,length=298
Content-Type = application/octet-stream
Content-Disposition = null
Content-Length = 298
fileName = 715.properties
File downloaded
Content-Type = application/octet-stream
Content-Disposition = null
Content-Length = 2823
fileName = 715_2015_11_24_12_26_16.csv
File downloaded
Content-Type = application/octet-stream
Content-Disposition = null
Content-Length = 37405
fileName = 715_2015_11_24_12_26_16.DOCX
File downloaded
The Library been loaded, and an activeX component been created

第二轮:

Java Web Start 11.65.2.17
JRE-Version verwenden 1.8.0_65-b17 Java HotSpot(TM) Client VM
Benutzer-Home-Verzeichnis = C:\Users\arthurw
----------------------------------------------------
c:   Konsolenfenster löschen
f:   Objekte in Finalisierungs-Queue finalisieren
g:   Garbage Collect
h:   Diese Hilfemeldung anzeigen
m:   Speicherauslastung drucken
o:   Logging auslösen
p:   Proxykonfiguration neu laden
q:   Konsole ausblenden
r:   Policy-Konfiguration neu laden
s:   System- und Deployment-Eigenschaften ausgeben
t:   Threadliste ausgeben
v:   Threadstack ausgeben
0-5: Traceebene auf <n> setzen
----------------------------------------------------
Missing Permissions manifest attribute in main jar: http://localhost:8080/browser/resources/webstart/Textverwaltungsschnittstelle.jar
Content-Type = application/octet-stream
Content-Disposition = null
Content-Length = 298
fileName = 715.properties
File downloaded
Content-Type = application/octet-stream
Content-Disposition = null
Content-Length = 2823
fileName = 715_2015_11_24_12_26_16.csv
File downloaded
Content-Type = application/octet-stream
Content-Disposition = null
Content-Length = 37405
fileName = 715_2015_11_24_12_26_16.DOCX
File downloaded
The Library been loaded, and an activeX component been created

这是JNLP文件

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/browser/resources/webstart" href="715.jnlp">
     <information>
          <title>Textverwaltung Schnittstelle</title>
          <description>automatisierte Serienbriefbefüllung mithilfe Ihrer Textverwaltung</description>
     </information>
     <security>
          <all-permissions/>
     </security>
     <resources>
          <j2se version="1.6+" />
          <jar href="Textverwaltungsschnittstelle.jar" main="true"/>
     </resources>
     <update check="always" policy="always"/>
     <application-desc main-class="mm.Textverwaltungsschnittstelle">
        <argument>http://localhost:8080/browser/resources/webstart/715.properties</argument>
     </application-desc>
</jnlp>

我需要通过“导出WAR文件”让它与部署一起工作。有人知道这是什么问题吗?

------------------------------ EDIT ---------------- ---------------------

这是属性文件的加载过程,这里一切正常,我可以手动打开属性文件,内容是正确的。

Properties clientprops=new Properties();
clientprops.put("modus", modus);
clientprops.put("templatepath", templateUrl);
clientprops.put("csvpath", csvUrl);
String propertypath=jnlpdir + user + ".properties";
File fp = new File(propertypath);
OutputStream out;
try {
  out = new FileOutputStream(fp);
  clientprops.store(out, "Benötigte Attribute für die Aktivierung der Textverwaltungsschnittstelle");
} catch (IOException e2) {
    e2.printStackTrace();
}

这就是我如何下载属性文件

File proppath = new File(tmpdir + "prop.properties");
URL url;
try {
  url = new URL(args[0]);
  FileUtils.copyURLToFile(url, proppath);
} catch (IOException e) {
  showFehler("Properties konnten nicht kopiert werden");
}

copyURLToFile(url,proppath)是来自appache FileUtils的方法。 下载的属性文件包含无效内容。每次都是第一次运行的内容。

诚恳 亚瑟

1 个答案:

答案 0 :(得分:0)

如上所述:

WebStart ed应用程序中下载的属性文件需要更新并包含在已发布的.war中才能工作。所以这不是WebStart或wildfly或JNLP相关的,而是在构建过程中要考虑的事情。