我有一个包含清单文件的webapp,我在其中编写了一个ant构建任务期间我的应用程序的当前版本.清单文件是正确创建的,但是当我尝试在运行时读取它时,我会得到一些奇怪的副作用.我在清单中阅读的代码是这样的:
InputStream manifestStream = Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream("META-INFFFF/MANIFEST.MF");
try {
Manifest manifest = new Manifest(manifestStream);
Attributes attributes = manifest.getMainAttributes();
String impVersion = attributes.getValue("Implementation-Version");
mVersionString = impVersion;
}
catch(IOException ex) {
logger.warn("Error while reading version: " + ex.getMessage());
}
Run Code Online (Sandbox Code Playgroud)
当我将eclipse附加到tomcat时,我看到上面的代码有效,但它似乎得到了一个不同于我预期的清单文件,我可以告诉它,因为ant版本和构建时间戳都是不同的.然后,我在那里放了"META-INFFFF",上面的代码仍然有效!这意味着我正在阅读其他一些清单,而不是我的清单.我也试过了
this.getClass().getClassLoader().getResourceAsStream(...)
Run Code Online (Sandbox Code Playgroud)
但结果是一样的.从tomcat中运行的webapp内部读取清单文件的正确方法是什么?
编辑:感谢您的建议到目前为止.另外,我应该注意到我正在运行tomcat独立; 我从命令行启动它,然后附加到Eclipse调试器中正在运行的实例.这不应该有所作为,不是吗?
我希望Maven将项目与其运行时依赖项打包在一起.我希望它使用以下清单创建一个JAR文件:
.....
Main-Class : com.acme.MainClass
Class-Path : lib/dependency1.jar lib/dependency2.jar
.....
Run Code Online (Sandbox Code Playgroud)
并创建以下目录结构:
target
|-- ....
|-- my-project.jar
|-- lib
|-- dependency1.jar
|-- dependency2.jar
Run Code Online (Sandbox Code Playgroud)
意思是,我希望主JAR排除任何依赖项,并且我希望所有传递依赖项都被复制到"lib"子目录中.有任何想法吗?
我在Win 7 RTM x64上创建了一个.NET C#WinForms应用程序,假设我已经调用了DataInstaller.
当我在调试器之外运行这个程序时(这只是一个没有功能的空表单),它可以正常工作,直到我关闭表单.然后,我从程序兼容性助手那里收到一条消息:
此程序可能未正确安装
然后,我可以选择使用推荐的设置重新安装,或者说安装确实按预期工作.
如果我将应用程序命名为"DataThingy",这不是问题,我想这与程序调用*Setup获得UAC屏蔽图标的方式有关.
我假设我可以将一些简单的东西放在应用程序清单中以防止这种情况发生?
我不确定这是否发生在Vista上,因为我目前没有访问权限.
更改名称不是一个选项,关闭UAC不是一个选项,所以请不要建议这个!
编辑:
我的天啊.
似乎如果以下任何一种情况属实,UAC坚持:
exe名称包含单词Installer
AssemblyInfo.cs中
AssemblyTitle contains the word 'Installer'
e.g. [assembly: AssemblyTitle("DataInstaller")]
AssemblyProduct contains the word 'Installer'
e.g. [assembly: AssemblyProduct("Data Installation Utility")]
Run Code Online (Sandbox Code Playgroud)
'Installer'也可以是'Setup'.
它乞丐信仰,它真的.显然,其中一位老VB6程序员已经在Redmond重新安置到UAC团队.
我仍然需要一个解决方法,我不准备接受我的应用程序不可能被称为安装程序,因为它不会触及注册表或将任何文件放在Program Files文件夹中.
我假设如果我尝试执行名为IAmAVirus.exe的应用程序,UAC会将机器置于完全锁定状态.(实际上,我不敢尝试,因为我并不完全相信我只是愚蠢)
我正在开发一个使用Boost.Python嵌入Python解释器的应用程序.这用于运行与主程序交互的用户生成的"脚本".
不幸的是,一个用户在尝试运行脚本时报告运行时错误R6034.主程序启动正常,但我认为加载python27.dll时可能会出现问题.
我使用的是Visual Studio 2005,Python 2.7和Boost.Python 1.46.1.问题仅发生在一个用户的计算机上.我以前处理过明显的问题,并设法解决它们,但在这种情况下,我有点不知所措.
有没有其他人遇到过类似的问题?你能解决吗?怎么样?
visual-studio-2005 manifest boost-python visual-c++ python-2.7
在下面的构建文件中,jar目标引用了manifest class-path的jar.class.path属性.编译目标引用project.class.path
这里有冗余,因为jar.class.path和project.class.path非常相似.添加库时必须更新它们,如果库列表变得很长,这可能会很麻烦.有没有更好的办法?任何解决方案都必须是跨平台的,并始终使用相对路径.
编辑:
它应该从文件集生成JAR类路径,而不是相反,所以我可以使用通配符,例如在目录中包含所有JAR文件.
<?xml version="1.0"?>
<project name="Higgins" default="jar" basedir=".">
<property name="jar.class.path" value="lib/forms-1.2.0.jar lib/BrowserLauncher.jar"/>
<path id="project.class.path">
<pathelement location="build"/>
<fileset dir="lib">
<include name="forms-1.2.0.jar"/>
<include name="BrowserLauncher.jar"/>
</fileset>
</path>
<target name="prepare">
<mkdir dir="build"/>
</target>
<target name="compile" depends="prepare" description="Compile core sources">
<javac srcdir="src"
includes="**"
destdir="build"
debug="true"
source="1.5">
<classpath refid="project.class.path"/>
</javac>
</target>
<target name="jar" depends="compile" description="Generates executable jar file">
<jar jarfile="higgins.jar">
<manifest>
<attribute name="Main-Class" value="nl.helixsoft.higgins.Main"/>
<attribute name="Class-Path" value="${jar.class.path}"/>
</manifest>
<fileset dir="build" includes="**/*.class"/>
<fileset dir="src" includes="**/*.properties"/>
</jar>
</target>
</project>
Run Code Online (Sandbox Code Playgroud) 我一直想知道嵌入有什么区别
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
Run Code Online (Sandbox Code Playgroud)
和
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Run Code Online (Sandbox Code Playgroud)
在你的应用程序的清单中.
有没有一种简单的方法来读取应用程序已嵌入的清单文件?
我在考虑备用数据流的思路?
我正在尝试使用Windows SDK中的mt.exe将清单添加到没有的清单,使用以下命令行:
C:\winsdk61>mt.exe -nologo -manifest "r:\shared\hl.exe.manifest" -updateresource:"r:\shared\hl33m.exe;#1"
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我这样做时,我收到此错误:
mt.exe : general error c101008c: Failed to read the manifest from
the resource of file "r:\shared\hl33m.exe". The specified resource
type cannot be found in the image file.
Run Code Online (Sandbox Code Playgroud)
当然在文件中找不到资源 - 文件没有清单,这就是我想添加一个的原因.
如何将清单附加到可执行文件?这不应该简单吗?
我的Chrome应用有以下清单:
{
"name": ",
"version": "1.0.3",
"manifest_version": 2,
"description": "Chrome Extension for.",
"icons": {
"16": "images/test.png",
"19": "images/test.png",
"256": "images/test.png"
},
"app": {
"background": {
"scripts": [
"background.js"
]
}
},
"sandbox": {
"js": [
"lib/test-api.js"
]
},
"permissions": [
"<all_urls>",
"notifications",
"storage",
"videoCapture"
]
}
Run Code Online (Sandbox Code Playgroud)
我有一个运行的脚本文件eval.我已经阅读了有关CSP和沙盒的内容,但我仍然收到此错误:
拒绝将字符串评估为JavaScript,因为'unsafe-eval'不是以下内容安全策略指令中允许的脚本源:"default-src'self'chrome-extension-resource:".请注意,'script-src'未明确设置,因此'default-src'用作后备.
javascript google-chrome manifest content-security-policy google-chrome-app
我们提到android.intent.action.MAIN并android.intent.category.LAUNCHER作为启动器活动的Intent过滤器Manifest.xml.什么是imp.这两个?它们的功能是什么?
manifest ×10
.net ×2
jar ×2
visual-c++ ×2
windows ×2
android ×1
ant ×1
boost-python ×1
c# ×1
c++ ×1
classpath ×1
dependencies ×1
intentfilter ×1
java ×1
javascript ×1
maven-2 ×1
mt ×1
python-2.7 ×1
tomcat ×1
uac ×1
winapi ×1
windows-7 ×1