微信创建菜单,MenuApi.createMenu(jsonstr);报错

牛网 发布于 2015/07/04 22:14
阅读 1K+
收藏 0

@JFinal 你好,想跟你请教个问题:

在用MenuApi.createMenu(jsonstr);创建微信菜单的时候,

/**
* 创建菜单
*/
public static ApiResult createMenu(String jsonStr) {
String jsonResult = HttpKit.post(createMenu + AccessTokenApi.getAccessToken().getAccessToken(), jsonStr);
return new ApiResult(jsonResult);
}

/**
	 * 从缓存中获取 access token,如果未取到或者 access token 不可用则先更新再获取
	 */
	public static AccessToken getAccessToken() {
		String appId = ApiConfigKit.getApiConfig().getAppId();
		AccessToken result = map.get(appId);
		if (result != null && result.isAvailable())
			return result;
		
		refreshAccessToken();
		return map.get(appId);
	}



map为null

报错信息:

2015-07-04 22:13:16
[ERROR]-[Thread: qtp231428782-21]-[com.jfinal.core.ActionHandler.handle()]: /weixin/createMenu
java.lang.RuntimeException: javax.net.ssl.SSLException: java.lang.SecurityException: JCE cannot authenticate the provider SunJCE
	at com.jfinal.kit.HttpKit.get(HttpKit.java:128)
	at com.jfinal.kit.HttpKit.get(HttpKit.java:138)
	at com.jfinal.weixin.sdk.api.AccessTokenApi.refreshAccessToken(AccessTokenApi.java:52)
	at com.jfinal.weixin.sdk.api.AccessTokenApi.getAccessToken(AccessTokenApi.java:38)
	at com.jfinal.weixin.sdk.api.MenuApi.createMenu(MenuApi.java:31)
	at com.kuiyun.weixin.action.index.WeiXinIndexAction.createMenu(WeiXinIndexAction.java:203)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:71)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:74)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:365)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
	at java.lang.Thread.run(Unknown Source)
Caused by: javax.net.ssl.SSLException: java.lang.SecurityException: JCE cannot authenticate the provider SunJCE
	at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
	at com.jfinal.kit.HttpKit.get(HttpKit.java:124)
	... 35 more
Caused by: java.lang.SecurityException: JCE cannot authenticate the provider SunJCE
	at javax.crypto.Cipher.getInstance(DashoA13*..)
	at java.security.Signature$Delegate.newInstance(Unknown Source)
	at java.security.Signature$Delegate.chooseProvider(Unknown Source)
	at java.security.Signature$Delegate.engineInitVerify(Unknown Source)
	at java.security.Signature.initVerify(Unknown Source)
	at com.sun.net.ssl.internal.ssl.RSASignature.engineInitVerify(Unknown Source)
	at java.security.Signature$Delegate.init(Unknown Source)
	at java.security.Signature$Delegate.chooseProvider(Unknown Source)
	at java.security.Signature$Delegate.engineInitVerify(Unknown Source)
	at java.security.Signature.initVerify(Unknown Source)
	at com.sun.net.ssl.internal.ssl.HandshakeMessage$DH_ServerKeyExchange.<init>(Unknown Source)
	at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
	at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
	at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
	... 41 more
Caused by: java.util.jar.JarException: Class is on the bootclasspath
	at javax.crypto.SunJCE_c.a(DashoA13*..)
	at javax.crypto.SunJCE_b.b(DashoA13*..)
	at javax.crypto.SunJCE_b.a(DashoA13*..)
	at javax.crypto.SunJCE_b.b(DashoA13*..)
	at javax.crypto.Cipher.getInstance(DashoA13*..)
	at com.sun.net.ssl.internal.ssl.JsseJce.getCipher(Unknown Source)
	at com.sun.net.ssl.internal.ssl.CipherBox.<init>(Unknown Source)
	at com.sun.net.ssl.internal.ssl.CipherBox.newCipherBox(Unknown Source)
	at com.sun.net.ssl.internal.ssl.CipherSuite$BulkCipher.newCipher(Unknown Source)
	at com.sun.net.ssl.internal.ssl.CipherSuite$BulkCipher.isAvailable(Unknown Source)
	at com.sun.net.ssl.internal.ssl.CipherSuite$BulkCipher.isAvailable(Unknown Source)
	at com.sun.net.ssl.internal.ssl.CipherSuite.isAvailable(Unknown Source)
	at com.sun.net.ssl.internal.ssl.CipherSuiteList.buildAvailableCache(Unknown Source)
	at com.sun.net.ssl.internal.ssl.CipherSuiteList.getDefault(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.init(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.createSocket(Unknown Source)
	at sun.net.NetworkClient.doConnect(Unknown Source)
	at sun.net.www.http.HttpClient.openServer(Unknown Source)
	at sun.net.www.http.HttpClient.openServer(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
	... 38 more


 refreshAccessToken();打断点发现,

conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), GET, headers);
conn.connect();   //到这里就报错



加载中
0
JFinal
JFinal
是开发环境的问题,直接下载整个 jfinal weixin 项目,导入到 eclipse 中试一下,在这里下载: http://git.oschina.net/jfinal/jfinal-weixin
0
牛网
jdk问题。。。
0
Adacrya
Adacrya
楼主说明白点,怎么搞定的啊,环境哪里的问题
返回顶部
顶部