我是Gatling(2.1.2)的新手,想要做一个小型原型项目给同事们展示.
根据快速入门页面,有几种方法可以用Gatling运行模拟:
gatling-maven-pluginmaven插件执行模拟.gatling-highcharts-maven-archetype,创建一个项目,并运行Engine类.我发现了那些问题
对于1,很难为模拟类添加依赖项.我必须弄清楚需要什么罐子并将它们放到lib文件夹中.
对于2,它需要安装maven.
对于3,它只从IDE运行
我只想要一个简单的可执行JAR文件,其中所有依赖项捆绑在一起(我的模拟,加特林和第三方),并从任何机器(如EC2实例)运行它.
有没有办法实现这个目标?
更新1:
我尝试了方法3,但将所有项目文件从test文件夹移动到main,并用于maven-assembly-plugin构建具有依赖项的jar.当我尝试运行该文件时,出现以下错误:
Exception in thread "main" java.lang.ExceptionInInitializerError
at Engine$.delayedEndpoint$Engine$1(Engine.scala:7)
at Engine$delayedInit$body.apply(Engine.scala:4)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at Engine$.main(Engine.scala:4)
at Engine.main(Engine.scala)
Caused by: java.nio.file.FileSystemNotFoundException
at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171)
at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157)
at java.nio.file.Paths.get(Paths.java:143)
at io.gatling.core.util.PathHelper$.uri2path(PathHelper.scala:32)
at IDEPathHelper$.<init>(IDEPathHelper.scala:7)
at IDEPathHelper$.<clinit>(IDEPathHelper.scala)
... 11 more
Run Code Online (Sandbox Code Playgroud)
我想这与Gatling配置有关,但不知道出了什么问题.
要运行maven-shade-plugin,由于签名依赖,我必须使用此处描述的方法,如下所示:
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<filters>
<filter>
<!-- filter out signature files from signed dependencies, else repackaging fails with security ex -->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
问题:如何判断哪个 JAR导致插件失败?它似乎不是最近提到的那个.
调试输出的尾部:
[DEBUG] We have a duplicate org/jdom2/xpath/util/AbstractXPathCompiled.class in C:\Users\me\aaaa-1.11.0-SNAPSHOT.jar
[DEBUG] We have a duplicate org/jdom2/xpath/util/XPathDiagnosticImpl.class in C:\Users\me\aaaa-1.11.0-SNAPSHOT.jar
[DEBUG] Processing JAR C:\Users\me\bbbb-1.11.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Retrievers JAR ................................ FAILURE [ 9.581 s]
[INFO] Retrievers .................................... …Run Code Online (Sandbox Code Playgroud) Exception in thread "main" java.lang.SecurityException: Invalid signature file d igest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVeri fier.java:240)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier .java:193)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:262)
at java.util.jar.JarVerifier.update(JarVerifier.java:216)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:341)
at java.util.jar.JarFile.getInputStream(JarFile.java:406)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:75 2)
at sun.misc.Resource.cachedInputStream(Resource.java:77)
at sun.misc.Resource.getByteBuffer(Resource.java:160)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:436)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480)
Run Code Online (Sandbox Code Playgroud)
嗨,我得到这个错误,我想知道是否有人可以告诉我是什么导致这.这是我的项目的痘文件的快照.任何帮助,将不胜感激.
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.50</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.29</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1101-jdbc41</version>
</dependency>
<dependency> …Run Code Online (Sandbox Code Playgroud) 我一直在使用各种配方来使用Maven POM 为JavaFX项目生成可运行的JAR文件.这些Stackoverflow问题中的每一个都描述了同样的问题.令人沮丧的是,针对同一目标似乎有几种不同的解决方案.
问题:
java.lang.SecurityException:Manifest主要属性的签名文件摘要无效
在命令行上执行JAR文件时出错.虽然Netbeans可以愉快地运行程序并调试程序.
诊断
有关于此的几个Stackoverflow和论坛问题(下面最有用的).尽管已知问题,但我还没有找到一个与JavaFX一起使用的明确解决方案.这些答案中描述的过程不是用于捆绑JavaFX JAR 的JavaFxPackager工具:
通常的方法:这个问题的帖子流行答案(撰写本文时为255票):在我们的项目中使用非 -JavaFX模块:
但是,当我们将相同的插件放在构建JavaFX JAR文件的POM中时,我们仍然得到:" 无效的签名文件摘要 ..."错误.具体来说,我<artifactId>maven-shade-plugin</artifactId>在JavaFxPackager exec规则之前和之后放置了第一个.结果是
**题*:
如何管理JavaFX应用程序.这是<build> sectionJavaFX 的POM Netbeans设置:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeScope>system</excludeScope>
<excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals> …Run Code Online (Sandbox Code Playgroud) 我有一个宁静的服务(post)消耗(application/json)并生成(application/json).此服务的单个参数是带注释的java对象.
我正在使用org.jboss.resteasy.client.ClientRequest将请求发送到服务.但是,我在客户端获得此异常并且异常:
找不到内容类型application/json类型的writer.
这是否意味着我缺少一些图书馆罐子,或者我必须为application/json编写自己的编写器?
我正在使用resteasy 2.3.3.Final
以下是我添加到我的pom中的各种依赖项,我认为可能与之相关:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.3.3.Final</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>2.3.4.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>2.3.4.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.3.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
马特
我有一个使用很少外部jar的应用程序mail-1.4等等.现在我想用IDE(IntelliJ)执行我的应用程序.我也遵循指令文件>项目结构>工件等,但我的命令提示符说:
Exception in thread "main" java.lang.SecurityException: Invalid signature file
igest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)
at sun.security.util.SignatureFileVerifier.process(Unknown Source)
at java.util.jar.JarVerifier.processEntry(Unknown Source)
at java.util.jar.JarVerifier.update(Unknown Source)
at java.util.jar.JarFile.initializeVerifier(Unknown Source)
at java.util.jar.JarFile.getInputStream(Unknown Source)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(Unknown Source)
at sun.misc.Resource.cachedInputStream(Unknown Source)
at sun.misc.Resource.getByteBuffer(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
我 …
我制作了一个使用 Maven、JavaFX 和其他一些依赖项的 Java 应用程序。以前,构建一个可执行的 jar 很容易,但由于 Java11 是模块化的并且不包含 JavaFX,我无法构建一个可用的 jar。
我已经尝试了很多东西,但我不知道我现在应该做什么。
我的 pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<verbose>true</verbose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<outputDirectory>out/</outputDirectory>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>fr.crosf32.fxtest.Entry</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我尝试构建包含所有依赖项的工件,但在运行时出现错误 (java -jar ):
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: javafx/application/Application
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at fr.crosf32.fxtest.SlimForest.lambda$new$0(SlimForest.java:26)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) …Run Code Online (Sandbox Code Playgroud) 我的问题非常类似于:当依赖性组合成一个罐子时,仅抛出泽西异常
我运行我的应用程序(jetty embedded + jersey),一切正常.当我尝试创建可执行JAR时,我收到错误:
org.glassfish.jersey.message.internal.WriterInterceptorExecutor $ TerminalWriterInterceptor aroundWriteTo GRAVE:找不到媒体类型= application/json的MessageBodyWriter,type = class
我的POM.XML:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>server.application.DeepDig</mainClass>
</transformer>
</transformers>
<filters>
<!-- filter to address "Invalid signature file" issue - see https://stackoverflow.com/a/6743609/589215 -->
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud) 我正试图在Eclipse下开始使用JMH.我可以从命令行构建一个jar来执行,但是我也希望能够在Eclipse中直接运行它以便于开发.
目前我正在:
java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList
Run Code Online (Sandbox Code Playgroud)
我正在使用来自http://nitschinger.at/Using-JMH-for-Java-Microbenchmarking/的简单入门案例:
public class MyBenchmark {
@Benchmark
public void testMethod() {
// This is a demo/sample template for building your JMH benchmarks. Edit as needed.
// Put your benchmark code here.
}
public static void main(String... args) throws Exception {
Options opts = new OptionsBuilder()
.include(".*")
.warmupIterations(10)
.measurementIterations(10)
// .jvmArgs("-server")
.forks(1)
// .outputFormat(OutputFormatType.TextReport)
.build();
new Runner(opts).run();
}
}
Run Code Online (Sandbox Code Playgroud)
我按照JMH文档中的规定生成了POM,并添加了JMH中指定的exec-maven-plugin 无法找到资源:/ META-INF/BenchmarkList:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sample</groupId> …Run Code Online (Sandbox Code Playgroud) 我刚刚使用这个命令创建了一个Maven项目:
$ mvn archetype:generate \
-DinteractiveMode=false \
-DarchetypeGroupId=org.openjdk.jmh \
-DarchetypeArtifactId=jmh-java-benchmark-archetype \
-DgroupId=org.sample \
-DartifactId=test \
-Dversion=1.0
Run Code Online (Sandbox Code Playgroud)
然后我做了一个mvn clean install跟着java -jar test-1.0.jar
该程序给了我这个消息
no main manifest attribute, in target/test-1.0.jar
Run Code Online (Sandbox Code Playgroud)
我查看了清单,没有Main-Class属性.
这应该产生它:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${uberjar.name}</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<!--
Shading signed JARs will fail without this.
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
-->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)