Skip to content

公众号demo程序发送一次性订阅消息时空指针 #483

Closed

Description

@ImLeonLi

模块:weixin-java-mp
版本:develop分支48d3163b33a1d6dde5fa1ac730798b857ae63fae
功能:一次性订阅消息
问题:用户授权后推送订阅模板消息给该用户时demo程序空指针
错误信息:

java.lang.NullPointerException
	at me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl.getAccessToken(WxMpServiceHttpClientImpl.java:94)
	at me.chanjar.weixin.mp.api.impl.WxMpServiceBaseImpl.executeInternal(WxMpServiceBaseImpl.java:272)
	at me.chanjar.weixin.mp.api.impl.WxMpServiceBaseImpl.execute(WxMpServiceBaseImpl.java:239)
	at me.chanjar.weixin.mp.api.impl.WxMpServiceBaseImpl.post(WxMpServiceBaseImpl.java:228)
	at me.chanjar.weixin.mp.api.impl.WxMpSubscribeMsgServiceImpl.sendSubscribeMessage(WxMpSubscribeMsgServiceImpl.java:39)
	at me.chanjar.weixin.mp.demo.WxMpSubscribeMsgServlet.service(WxMpSubscribeMsgServlet.java:50)

分析原因:下面代码只是将配置文件中的配置值装入了wxMpDemoInMemoryConfigStorage中,但父类中的3个Lock并未赋值。

@XStreamAlias("xml")
class WxMpDemoInMemoryConfigStorage extends WxMpInMemoryConfigStorage {
  public static WxMpDemoInMemoryConfigStorage fromXml(InputStream is) {
    XStream xstream = XStreamInitializer.getInstance();
    xstream.processAnnotations(WxMpDemoInMemoryConfigStorage.class);
    WxMpDemoInMemoryConfigStorage wxMpDemoInMemoryConfigStorage = (WxMpDemoInMemoryConfigStorage) xstream.fromXML(is);
    return wxMpDemoInMemoryConfigStorage;
  }
  ...
}

Activity

  1. added a commit that references this issue on Mar 8, 2018
  2. binarywang commented on Mar 11, 2018

    @binarywang
    Owner

    2.9.8.BETA版本已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions