我正在使用这个网络推送java库:https://github.com/MartijnDwars/web-push
Gradle构建任务,编译为要在Coldfusion中使用的jar文件。
jar {
baseName = 'web-push'
version = '3.0.0'
doFirst {
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
所以我有一个包含所有依赖项的正常运行的jar文件。但是,当我发送通知时,我收到此错误。
java.lang.NoSuchMethodError: org.bouncycastle.math.ec.ECPoint.getEncoded(Z)[B
指向savePublicKey
Utils.java
方法
public static byte[] savePublicKey(ECPublicKey publicKey) {
return publicKey.getQ().getEncoded(false);
}
我的理解是getEncoded
是一个构建int java Key方法。因此,我不确定是否收到此错误,因为publicKey.getQ
不是有效密钥,或者因为我需要导入/包含java密钥类。
提前感谢您提供任何提示/帮助。
CFML代码
<cfscript>
variables.server.pubKey = 'XXXXXXXXXXX';
variables.server.priKey = 'XXXXXX';
variables.subscription = {
"endpoint": "https://fcm.googleapis.com/fcm/send/eEmctHWg8-k:APA91bF-kzQfUv1Y1T9C3sJ3eN5zDDtyRhcDU0MyVS1XWgPIko2X7VpjeymhqDAzb-4nbg4x2SmObHk1JSITG4lmsx-40E_uNi4a_TnFavs4ICMzbeHQJzKgnuTAcQxSXDxJSBNFrzY_"
, "keys": {
"p256dh": "BMIWtizmL6BgkofOn6DmPq/AaDwBvh894GBHvPpH2xgg9/uNoNsvKWAfEXVxLgpaUeytb8tGryguvIAmYTDO0W8="
, "auth": "zDH8z4GPHvW2zFXG0bf2pQ=="
}
}
variables.json = serializeJSON(variables.subscription);
variables.java.gson = createObject('java', 'com.google.gson.Gson', expandPath('/fw/jar/gson-2.8.0.jar'));
variables.lib = expandPath('/fw/jar/web-push-3.0.0.jar');
variables.java.subscription = createObject('java', 'nl.martijndwars.webpush.Subscription', variables.lib);
variables.java.notification = createObject('java', 'nl.martijndwars.webpush.Notification', variables.lib);
variables.java.pushservice = createObject('java', 'nl.martijndwars.webpush.PushService', variables.lib);
variables.java.subscription = variables.java.gson.fromJson(variables.json, variables.java.subscription.class);
variables.java.notification.init(variables.java.subscription, 'Hello, World!');
variables.java.pushservice.init(variables.server.pubKey, variables.server.priKey, "mailto:craig@thinkerventures.com");
variables.resonse = variables.java.pushservice.send(variables.java.notification);
</cfscript>
CFML堆栈跟踪
Full Trace: org.bouncycastle.math.ec.ECPoint.getEncoded(Z)[B
at nl.martijndwars.webpush.Utils.savePublicKey(Utils.java:36):36
at nl.martijndwars.webpush.HttpEce.lengthPrefix(HttpEce.java:124):124
at nl.martijndwars.webpush.HttpEce.deriveDH(HttpEce.java:115):115
at nl.martijndwars.webpush.HttpEce.deriveKey(HttpEce.java:55):55
at nl.martijndwars.webpush.HttpEce.encrypt(HttpEce.java:172):172
at nl.martijndwars.webpush.PushService.encrypt(PushService.java:92):92
at nl.martijndwars.webpush.PushService.sendAsync(PushService.java:128):128
at nl.martijndwars.webpush.PushService.send(PushService.java:113):113
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method):-2
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62):62
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43):43
at java.lang.reflect.Method.invoke(Method.java:497):497
at lucee.runtime.reflection.pairs.MethodInstance.invoke(MethodInstance.java:55):55
at lucee.runtime.reflection.Reflector.callMethod(Reflector.java:857):857
at lucee.runtime.reflection.Reflector.callMethod(Reflector.java:842):842
at lucee.runtime.java.JavaObject.call(JavaObject.java:228):228
at lucee.runtime.java.JavaObject.call(JavaObject.java:259):259
at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1593):1593
at script.dev.push_cfm$cf.call(D:\nonprofitthrive_com\script\dev\push.cfm:38):38
at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:954):954
at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:858):858
at fw.application_fw_cfc$cf.udfCall1(D:\nonprofitthrive_com\fw\application_fw.cfc:279):279
at fw.application_fw_cfc$cf.udfCall(D:\nonprofitthrive_com\fw\application_fw.cfc):-1
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1761):1761
at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:414):414
at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:223):223
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:37):37
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2265):2265
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2228):2228
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:456):456
at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:47):47
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729):729
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291):291
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206):206
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52):52
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239):239
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206):206
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217):217
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106):106
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502):502
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142):142
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79):79
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88):88
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518):518
at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:844):844
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673):673
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500):1500
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456):1456
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142):1142
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617):617
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61):61
at java.lang.Thread.run(Thread.java:745):745