Openfire插件:Null Pointer在尝试获取插件实例时出现异常

时间:2014-11-04 14:23:17

标签: plugins openfire

我正在为openfire开发一个插件。

从jsp,我使用getter和setter来传输数据。 我的问题类似于这里提到的问题: https://community.igniterealtime.org/message/155892#155892

我一直试图从一周内弄明白。

我有以下代码:

<%@ page
   import="org.jivesoftware.openfire.XMPPServer,
           de.meisterfuu.openfire.plugin.teamFantasian_UserServicePlugin,
           org.jivesoftware.util.ParamUtils,
           org.jivesoftware.openfire.container.Plugin,
           org.jivesoftware.util.*,
           java.util.*,
           java.util.HashMap,
           java.util.Map"
   errorPage="error.jsp"%>


<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>

<%
    boolean save = request.getParameter("save") != null;    
    String pNameSpace = ParamUtils.getParameter(request, "pNameSpace");
    String pModule = ParamUtils.getParameter(request, "pModule");
    String pCreateUser = ParamUtils.getParameter(request, "pCreateUser");
    String pCreateUser_input = ParamUtils.getParameter(request, "pCreateUser_input");
    String pCreateUser_output = ParamUtils.getParameter(request, "pCreateUser_output");




  teamFantasian_UserServicePlugin plugin = (teamFantasian_UserServicePlugin) XMPPServer.getInstance().getPluginManager().getPlugin("teamFantasian_UserServicePlugin");


    Collection<Plugin> a = XMPPServer.getInstance().getPluginManager().getPlugins();

    out.write(Arrays.toString(a.toArray()));

    if(plugin == null) {

    out.println("Cant find plugin ..!!");
    return;
    }

这是我的目录结构:

/home/manoj/final/Openfire/src/plugins/teamFantasian_UserServicePlugin
|-- lib
|   |-- asm-3.1.jar
|   |-- commons-pool2-2.0.jar
|   |-- fluent-hc-4.3.2.jar
|   |-- httpclient-4.3.3.jar
|   |-- httpcore-4.3.2.jar
|   |-- jackson-core-asl-1.9.2.jar
|   |-- jackson-jaxrs-1.9.2.jar
|   |-- jackson-mapper-asl-1.9.2.jar
|   |-- jackson-xc-1.9.2.jar
|   |-- jedis-2.4.2.jar
|   |-- jersey-bundle-1.18.jar
|   |-- jersey-servlet-1.18.jar
|   |-- jettison-1.1.jar
|   `-- jsr311-api-1.1.1.jar
|-- logo_large.gif
|-- logo_small.gif
|-- plugin.xml
|-- readme.html
`-- src
    |-- i18n
    |   `-- teamFantasian_UserServicePlugin_i18n.properties
    |-- java
    |   `-- de
    |       `-- meisterfuu
    |           `-- openfire
    |               `-- plugin
    |                   |-- teamFantasian_UserServicePlugin.java
    |                   `-- UserServiceHelper.java
    `-- web
        |-- images
        |   |-- error-16x16.gif
        |   `-- success-16x16.gif
        `-- teamFantasian_UserServicePlugin.jsp

10 directories, 24 files

1 个答案:

答案 0 :(得分:0)

请勿使用下划线表示插件名称。 将您的插件重命名为teamFantasianUserServicePlugin。

获取实例:

XMPPServer.getInstance().getPluginManager().getPlugin("teamfantasianuserserviceplugin");

插件名称应为小写。