gpt4 book ai didi

java - com.azure.messaging.servicebus.ServiceBusClientBuilder 安全异常 : signer information does not match

转载 作者:行者123 更新时间:2023-12-03 05:12:05 27 4
gpt4 key购买 nike

我尝试使用 eclipse IDE 使用 azure 服务总线客户端的示例执行示例异步 mq 调用。但是我收到以下错误。

Exception in thread "main" java.lang.SecurityException: class "com.azure.messaging.servicebus.ServiceBusClientBuilder"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:898)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:668)
at java.lang.ClassLoader.defineClass(ClassLoader.java:761)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.azure.messaging.servicebus.SendMessageAsyncSample.run(SendMessageAsyncSample.java:51)
at com.azure.messaging.servicebus.SendMessageAsyncSample.main(SendMessageAsyncSample.java:27)

这是我从 Microsoft 网站上获取的 java 类。 https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/SendMessageAsyncSample.java

package com.azure.messaging.servicebus;

import com.azure.core.util.BinaryData;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.IntStream;

/**
* Sample demonstrates how to send a {@link ServiceBusMessage} to an Azure Service Bus
queue.
*/
public class SendMessageAsyncSample {

static String connectionString = "test";
static String queueName = "uat.recq";

/**
* Main method to invoke this demo on how to send a {@link ServiceBusMessageBatch} to an Azure Service Bus.
*
* @param args Unused arguments to the program.
* @throws InterruptedException If the program is unable to sleep while waiting for the operations to complete.
*/
public static void main(String[] args) throws InterruptedException {
SendMessageAsyncSample sample = new SendMessageAsyncSample();
sample.run();
}


public void run() throws InterruptedException {
AtomicBoolean sampleSuccessful = new AtomicBoolean(false);
CountDownLatch countdownLatch = new CountDownLatch(1);

// The connection string value can be obtained by:
// 1. Going to your Service Bus namespace in Azure Portal.
// 2. Go to "Shared access policies"
// 3. Copy the connection string for the "RootManageSharedAccessKey" policy.
// The 'connectionString' format is shown below.
// 1. "Endpoint={fully-qualified-namespace};SharedAccessKeyName={policy-name};SharedAccessKey={key}"
// 2. "<<fully-qualified-namespace>>" will look similar to "{your-namespace}.servicebus.windows.net"
// 3. "queueName" will be the name of the Service Bus queue instance you created
// inside the Service Bus namespace.

// Instantiate a client that will be used to call the service.
ServiceBusSenderClient sender = new ServiceBusClientBuilder()
.connectionString(connectionString)
.sender()
.queueName(queueName)
.buildClient();

// Create a message to send.
final ServiceBusMessageBatch messageBatch = sender.createMessageBatch();
IntStream.range(0, 10)
.mapToObj(index -> new ServiceBusMessage(BinaryData.fromString("Hello world! " + index)))
.forEach(message -> messageBatch.tryAddMessage(message));

// Send that message. It completes successfully when the event has been delivered to the Service queue or topic.
// It completes with an error if an exception occurred while sending the message.
sender.sendMessages(messageBatch);

// Close the sender.
sender.close();
}
}

这是我的 pom.xml

<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>com.example</groupId>
<artifactId>Azure</artifactId>
<version>1.0.0</version>

<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-servicebus</artifactId>
<version>7.13.4</version>
</dependency>
</dependencies>
</project>

我尝试删除 MANIFEST.MF 文件中的所有名称和签名

Name: com/azure/messaging/servicebus/implementation/Messages.java
SHA-256-Digest: r2j4hEvfoypLiEsKreoUQD94jZyJaz0yByg1u1w7CTo=

但是我在运行该类时遇到以下错误。

Exception in thread "main" java.lang.SecurityException: Invalid signature file digest 
for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:330)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318)
at java.util.jar.JarVerifier.update(JarVerifier.java:230)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.getInputStream(JarFile.java:450)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:977)
at sun.misc.Resource.cachedInputStream(Resource.java:77)
at sun.misc.Resource.getByteBuffer(Resource.java:160)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:454)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.azure.messaging.servicebus.SendMessageAsyncSample.run(SendMessageAsyncSample.java:48)
at com.azure.messaging.servicebus.SendMessageAsyncSample.main(SendMessageAsyncSample.java:27)

我尝试运行 mvn dependency:tree 但没有明显的冲突。

[WARNING] Parameter 'localRepository' is deprecated core expression; Avoid use of 
ArtifactRepository type. If you need access to local repository, switch to '
${repositorySystemSession}' expression and get LRM from it instead.
[INFO] com.example:Azure:jar:1.0.0
[INFO] \- com.azure:azure-messaging-servicebus:jar:7.13.4:compile
[INFO] +- com.azure:azure-core:jar:1.38.0:compile
[INFO] | +- com.azure:azure-json:jar:1.0.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.5:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.13.5:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.5:compile
[INFO] | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.5:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.36:compile
[INFO] | \- io.projectreactor:reactor-core:jar:3.4.27:compile
[INFO] | \- org.reactivestreams:reactive-streams:jar:1.0.4:compile
[INFO] +- com.azure:azure-core-amqp:jar:2.8.4:compile
[INFO] | +- com.microsoft.azure:qpid-proton-j-extensions:jar:1.2.4:compile
[INFO] | \- org.apache.qpid:proton-j:jar:0.33.8:compile
[INFO] +- com.azure:azure-core-http-netty:jar:1.13.2:compile
[INFO] | +- io.netty:netty-handler:jar:4.1.89.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.89.Final:compile
[INFO] | | +- io.netty:netty-resolver:jar:4.1.89.Final:compile
[INFO] | | \- io.netty:netty-transport:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-handler-proxy:jar:4.1.89.Final:compile
[INFO] | | \- io.netty:netty-codec-socks:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-buffer:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-codec:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-codec-http:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-codec-http2:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-transport-native-unix-common:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.89.Final:compile
[INFO] | | \- io.netty:netty-transport-classes-epoll:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.89.Final:compile
[INFO] | | \- io.netty:netty-transport-classes-kqueue:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-tcnative-boringssl-static:jar:2.0.56.Final:compile
[INFO] | | +- io.netty:netty-tcnative-classes:jar:2.0.56.Final:compile
[INFO] | | +- io.netty:netty-tcnative-boringssl-static:jar:linux-x86_64:2.0.56.Final:compile
[INFO] | | +- io.netty:netty-tcnative-boringssl-static:jar:linux-aarch_64:2.0.56.Final:compile
[INFO] | | +- io.netty:netty-tcnative-boringssl-static:jar:osx-x86_64:2.0.56.Final:compile
[INFO] | | +- io.netty:netty-tcnative-boringssl-static:jar:osx-aarch_64:2.0.56.Final:compile
[INFO] | | \- io.netty:netty-tcnative-boringssl-static:jar:windows-x86_64:2.0.56.Final:compile
[INFO] | \- io.projectreactor.netty:reactor-netty-http:jar:1.0.28:compile
[INFO] | +- io.netty:netty-resolver-dns:jar:4.1.89.Final:compile
[INFO] | | \- io.netty:netty-codec-dns:jar:4.1.89.Final:compile
[INFO] | +- io.netty:netty-resolver-dns-native-macos:jar:osx-x86_64:4.1.89.Final:compile
[INFO] | | \- io.netty:netty-resolver-dns-classes-macos:jar:4.1.89.Final:compile
[INFO] | \- io.projectreactor.netty:reactor-netty-core:jar:1.0.28:compile
[INFO] \- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.13.5:compile
[INFO] +- org.codehaus.woodstox:stax2-api:jar:4.2.1:compile
[INFO] \- com.fasterxml.woodstox:woodstox-core:jar:6.4.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

以下是我在 JRE 库和 Maven 依赖项中的 jar 文件

C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\access-bridge-64.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\charsets.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\cldrdata.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\dnsns.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jaccess.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\jce.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\jfr.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jfxrt.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\jsse.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\localedata.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\nashorn.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\resources.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\rt.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunec.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunjce_provider.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunmscapi.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunpkcs11.jar
C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\zipfs.jar

C:\Users\test.co\.m2\repository\com\azure\azure-core\1.38.0\azure-core-1.38.0.jar
C:\Users\test.co\.m2\repository\com\azure\azure-core-amqp\2.8.4\azure-core-amqp-2.8.4.jar
C:\Users\test.co\.m2\repository\com\azure\azure-core-http-netty\1.13.2\azure-core-http-netty-1.13.2.jar
C:\Users\test.co\.m2\repository\com\azure\azure-json\1.0.0\azure-json-1.0.0.jar
C:\Users\test.co\.m2\repository\com\azure\azure-messaging-servicebus\7.13.4\azure-messaging-servicebus-7.13.4.jar
C:\Users\test.co\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.5\jackson-annotations-2.13.5.jar
C:\Users\test.co\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.13.5\jackson-core-2.13.5.jar
C:\Users\test.co\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.13.5\jackson-databind-2.13.5.jar
C:\Users\test.co\.m2\repository\com\fasterxml\jackson\dataformat\jackson-dataformat-xml\2.13.5\jackson-dataformat-xml-2.13.5.jar
C:\Users\test.co\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.5\jackson-datatype-jsr310-2.13.5.jar
C:\Users\test.co\.m2\repository\io\netty\netty-buffer\4.1.89.Final\netty-buffer-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-codec\4.1.89.Final\netty-codec-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-codec-dns\4.1.89.Final\netty-codec-dns-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-codec-http2\4.1.89.Final\netty-codec-http2-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-codec-http\4.1.89.Final\netty-codec-http-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-codec-socks\4.1.89.Final\netty-codec-socks-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-common\4.1.89.Final\netty-common-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-handler\4.1.89.Final\netty-handler-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-handler-proxy\4.1.89.Final\netty-handler-proxy-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-resolver\4.1.89.Final\netty-resolver-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-resolver-dns\4.1.89.Final\netty-resolver-dns-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-resolver-dns-classes-macos\4.1.89.Final\netty-resolver-dns-classes-macos-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-resolver-dns-native-macos\4.1.89.Final\netty-resolver-dns-native-macos-4.1.89.Final-osx-x86_64.jar
C:\Users\test.co\.m2\repository\io\netty\netty-tcnative-boringssl-static\2.0.56.Final\netty-tcnative-boringssl-static-2.0.56.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-tcnative-boringssl-static\2.0.56.Final\netty-tcnative-boringssl-static-2.0.56.Final-linux-aarch_64.jar
C:\Users\test.co\.m2\repository\io\netty\netty-tcnative-boringssl-static\2.0.56.Final\netty-tcnative-boringssl-static-2.0.56.Final-linux-x86_64.jar
C:\Users\test.co\.m2\repository\io\netty\netty-tcnative-boringssl-static\2.0.56.Final\netty-tcnative-boringssl-static-2.0.56.Final-osx-aarch_64.jar
C:\Users\test.co\.m2\repository\io\netty\netty-tcnative-boringssl-static\2.0.56.Final\netty-tcnative-boringssl-static-2.0.56.Final-osx-x86_64.jar
C:\Users\test.co\.m2\repository\io\netty\netty-tcnative-boringssl-static\2.0.56.Final\netty-tcnative-boringssl-static-2.0.56.Final-windows-x86_64.jar
C:\Users\test.co\.m2\repository\io\netty\netty-tcnative-classes\2.0.56.Final\netty-tcnative-classes-2.0.56.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-transport\4.1.89.Final\netty-transport-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-transport-classes-epoll\4.1.89.Final\netty-transport-classes-epoll-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-transport-classes-kqueue\4.1.89.Final\netty-transport-classes-kqueue-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\io\netty\netty-transport-native-epoll\4.1.89.Final\netty-transport-native-epoll-4.1.89.Final-linux-x86_64.jar
C:\Users\test.co\.m2\repository\io\netty\netty-transport-native-kqueue\4.1.89.Final\netty-transport-native-kqueue-4.1.89.Final-osx-x86_64.jar
C:\Users\test.co\.m2\repository\io\netty\netty-transport-native-unix-common\4.1.89.Final\netty-transport-native-unix-common-4.1.89.Final.jar
C:\Users\test.co\.m2\repository\org\apache\qpid\proton-j\0.33.8\proton-j-0.33.8.jar
C:\Users\test.co\.m2\repository\com\microsoft\azure\qpid-proton-j-extensions\1.2.4\qpid-proton-j-extensions-1.2.4.jar
C:\Users\test.co\.m2\repository\org\reactivestreams\reactive-streams\1.0.4\reactive-streams-1.0.4.jar
C:\Users\test.co\.m2\repository\io\projectreactor\reactor-core\3.4.27\reactor-core-3.4.27.jar
C:\Users\test.co\.m2\repository\io\projectreactor\netty\reactor-netty-core\1.0.28\reactor-netty-core-1.0.28.jar
C:\Users\test.co\.m2\repository\io\projectreactor\netty\reactor-netty-http\1.0.28\reactor-netty-http-1.0.28.jar
C:\Users\test.co\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar
C:\Users\test.co\.m2\repository\org\codehaus\woodstox\stax2-api\4.2.1\stax2-api-4.2.1.jar
C:\Users\test.co\.m2\repository\com\fasterxml\woodstox\woodstox-core\6.4.0\woodstox-core-6.4.0.jar

当我尝试从 IBM MQ 切换到 Azure 服务总线客户端时,如何绕过此问题。

最佳答案

我认为签名冲突是由于示例使用命名空间名称“com.azure.messaging.servicebus”造成的,该名称与 Azure Service Bus Sdk 命名空间相同。您可以尝试更改示例(例如“com.example”)吗?

关于java - com.azure.messaging.servicebus.ServiceBusClientBuilder 安全异常 : signer information does not match,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76232850/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com