当我从jnlp启动应用程序时,我收到消息
" Missing Codebase manifest attribute for:xxx.jar"
这是什么意思?
Pet*_*ter 25
刚刚在将JRE更新到1.7u25后运行内部应用程序时遇到了这个问题.出现警告是因为1.7u25中引入了一个新的安全功能,以防止未经授权的代码重用.在我的情况下,我还看到了一个对话框,要求我确认我希望应用程序可以访问我的PC.
如果您有权访问jar文件,请为其添加两个属性:Permissions和Codebase.您需要确定应用程序是否需要访问PC上的所有内容,在这种情况下,您将使用all-permissions该Permissions属性的值.否则,使用sandbox和JRE将限制代码在PC上的访问级别. Codebase可能需要与jnlp文件的代码库相同,除非从不同的URL下载该jar文件,在这种情况下,它需要是该URL.
Phi*_*lin 10
按照Peter的回答,这就是你如何以自动方式解决问题,以防你使用Netbeans和JavaFX.
Netbeans 7.3.1仍然没有修复这个"bug"(它没有为你添加代码库和Manifest的权限).如果要使用Netbeans构建项目而不是手动添加缺少的属性(并重新签名.jar),则可以编辑build.xml并添加以下ANT目标和宏:
<target name="-post-jfx-jar">
<update-libs-manifest />
<update-jar-manifest jarfile="${jfx.deployment.dir}${file.separator}${jfx.deployment.jar}" />
</target>
<macrodef name="update-libs-manifest">
<sequential>
<property name="pp_rebase_dir" value="${basedir}${file.separator}${dist.dir}${file.separator}lib"/>
<property name="pp_rebase_fs" value="*.jar"/>
<condition property="manifest.codebase" value="${manifest.custom.codebase}" else="*">
<and>
<isset property="manifest.custom.codebase" />
<not>
<equals arg1="${manifest.custom.codebase}" arg2="" trim="true" />
</not>
</and>
</condition>
<condition property="manifest.permissions" value="all-permissions" else="sandbox">
<isset property="permissions-elevated" />
</condition>
<echo message="Updating libraries manifest => Codebase: ${manifest.codebase} / Permissions: ${manifest.permissions}" />
<script language="javascript">
<![CDATA[
var dir = project.getProperty("pp_rebase_dir");
var fDir = new java.io.File(dir);
if( fDir.exists() ) {
var callTask = project.createTask("antcall");
callTask.setTarget("-update-jar-macro-call");
var param = callTask.createParam();
param.setName("jar.file.to.rebase");
var includes = project.getProperty("pp_rebase_fs");
var fs = project.createDataType("fileset");
fs.setDir( fDir );
fs.setIncludes(includes);
var ds = fs.getDirectoryScanner(project);
var srcFiles = ds.getIncludedFiles();
for (i=0; i<srcFiles.length; i++) {
param.setValue(dir + "${file.separator}" + srcFiles[i]);
callTask.perform();
}
}
]]>
</script>
</sequential>
</macrodef>
<target name="-update-jar-macro-call">
<update-jar-manifest jarfile="${jar.file.to.rebase}"/>
</target>
<macrodef name="update-jar-manifest">
<attribute name="jarfile"/>
<sequential>
<echo message="jarfile = @{jarfile}" />
<jar file="@{jarfile}" update="true">
<manifest>
<attribute name="Codebase" value="${manifest.codebase}"/>
<attribute name="Permissions" value="${manifest.permissions}"/>
</manifest>
</jar>
</sequential>
</macrodef>
Run Code Online (Sandbox Code Playgroud)
之后,您只需要添加manifest.custom.codebase=<your_codebase>到project.properties.例如:manifest.custom.codebase=localhost
注意:此代码适用于使用Netbeans默认ANT构建过程的JavaFX应用程序.如果不是这种情况,您需要相应地更新它 - 这将需要更改第一个目标(<target name="-post-jfx-jar">),属性名称和检查permissions-elevated属性的条件.
| 归档时间: |
|
| 查看次数: |
74431 次 |
| 最近记录: |