User Service problem

Whenever I try to use User Service plugin, I get the following exception:

HTTP ERROR: 500

gnu/inet/encoding/Stringprep

RequestURI=/plugins/userService/userservice

Caused by:

java.lang.NoClassDefFoundError: gnu/inet/encoding/Stringprep
     at org.jivesoftware.openfire.plugin.userService.UserServiceServlet.doGet(UserServiceServlet.java:130)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
     at org.jivesoftware.openfire.container.PluginServlet.handleServlet(PluginServlet.java:251)
     at org.jivesoftware.openfire.container.PluginServlet.service(PluginServlet.java:91)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
     at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
     at org.jivesoftware.admin.PluginFilter.doFilter(PluginFilter.java:70)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.jivesoftware.admin.AuthCheckFilter.doFilter(AuthCheckFilter.java:146)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
     at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
     at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
     at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
     at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
     at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
     at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
     at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
     at org.mortbay.jetty.Server.handle(Server.java:324)
     at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
     at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
     at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
     at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

I have checked that the plugin is enabled, and I pass the secret pass correctly. I’m using Linux Mint, and libidn seems to be installed. Any idea about what may be causing this problem?

Regards

I am having same problem. Any help on this?

I’m also having this problem and I opened another thread about it.

Did any of you solved it?

I’ve got this problem as well… I love the speedy support ignite are giving :frowning:

I solved the problem by downloading the source for user service, downloading the gnu stringprep source code, and then compile both together to create a new binary.

1 Like

Thnx. I’ll try that.

It works! thank you :slight_smile:

is this the only solution ?

Dear yadit,

I am new for openfire, which version better for me and how to install this package in my local machine using wamp server linux server. what is mean by embaded database and statndard database.

Can you have example below two points please help me on this regards

  1. JDBC Driver Class

  2. database url

Sorry for bad english.

Thanks,

Mayasakthi

Hi on Debian (lenny) cant find librarys that compile,

Can you tell me the sources you were able to compile , THANKS

I have just installed User Service plugin on Openfire 3.7.1 (from the Available plugins page). Then i have enabled commands processing for this plugin in its settings, copied the secret key and formed a special url to create a user. I was able to create a user this way without an exception.

I’m sorry, I’m not that familiar with openfire - just installed this plugin and nothing more, so I can’t really help.

Only solution I found…

I just used google - I’m sorry, but I can’t find the link from where I got it…

I have the same problem but i’m not familiar on building the plugin as suggested, can you provide me the binaries to replace the existing plugin? Please help me!!

hi. am using openfire 3.7.1, i will create a new user from outside the openfire… i need how to create a new user via java applications or how to use userservice plugin in java…

coding…

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletConfig;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.util.log.Log;

import org.jivesoftware.admin.AuthCheckFilter;

import org.jivesoftware.openfire.XMPPServer;

import org.jivesoftware.openfire.user.UserAlreadyExistsException;

import org.jivesoftware.openfire.user.UserNotFoundException;

public class UserServiceServlet extends HttpServlet{

UserServicePlugin plugin;

public void init(ServletConfig servletConfig) throws ServletException {

super.init(servletConfig);

24 plugin = (UserServicePlugin) XMPPServer.getInstance().getPluginManager().getPlugin(“userservice”);

25 // Exclude this servlet from requiring the user to login

//AuthCheckFilter.addExclude(“userservice/userservice”);

}

protected void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException

{

// Printwriter for writing out responses to browser

PrintWriter out = response.getWriter();

out.println(“Resgistration Successfully”);

/*if(!plugin.getAllowedIPs().isEmpty()){

// Get client’s IP address

String ipAddress = request.getHeader(“x-forwarded-for”);

if(ipAddress == null){

ipAddress = request.getHeader(“X_FORWARDED_FOR”);

if(ipAddress == null){

ipAddress = request.getHeader(“X-Forward-For”);

if(ipAddress == null){

ipAddress = request.getRemoteAddr();

}

}

}

System.out.println(“ipAddress in UserServiceServlet.java=”+ipAddress);

if(!plugin.getAllowedIPs().contains(ipAddress)){

System.out.println("User service rejected service to IP address: "+ipAddress);

Log.warn("User service rejected service to IP address: "+ipAddress);

replyError(“RequestNotAuthorised”, response, out);

return;

}

}

String username = request.getParameter(“username”);

String password = request.getParameter(“password”);

String name = request.getParameter(“name”);

String email = request.getParameter(“email”);

String type=“add”;

String secret=“JDzvHGSW”;

//String type = request.getParameter(“type”);

//String secret = request.getParameter(“secret”);

String groupNames = request.getParameter(“groups”);

//No defaults, add, delete, update only

//type = type == null ? “image” : type;

// Check that our plugin is enabled.

if (!plugin.isEnabled()) {

Log.warn("User service plugin is disabled: " + request.getQueryString());

replyError(“UserServiceDisabled”,response, out);

return;

}

// Check this request is authorised

if (secret == null || !secret.equals(plugin.getSecret())){

Log.warn("An unauthorised user service request was received: " + request.getQueryString());

replyError(“RequestNotAuthorised”,response, out);

return;

}

// Check the request type and process accordingly

try

{

if (“add”.equals(type)) {

plugin.createUser(username, password, name, email, groupNames);

replyMessage(“ok”,response, out);

//imageProvider.sendInfo(request, response, presence);

}else if (“delete”.equals(type)) {

plugin.deleteUser(username);

replyMessage(“ok”,response,out);

//xmlProvider.sendInfo(request, response, presence);

}else if (“update”.equals(type)) {

plugin.updateUser(username, password,name,email, groupNames);

replyMessage(“ok”,response,out);

//xmlProvider.sendInfo(request, response, presence);

}else {

Log.warn("The userService servlet received an invalid request of type: " + type);

// TODO Do something

}

}catch(UserAlreadyExistsException e) {

replyError(“UserAlreadyExistsException”,response, out);

}catch(UserNotFoundException e) {

replyError(“UserNotFoundException”,response, out);

}catch(IllegalArgumentException e) {

replyError(“IllegalArgumentException”,response, out);

}catch (Exception e) {

replyError(e.toString(),response, out);

}*/

}

private void replyMessage(String message,HttpServletResponse response, PrintWriter out){

response.setContentType(“text/xml”);

out.println("" + message + “”);

out.flush();

}

private void replyError(String error,HttpServletResponse response, PrintWriter out){

response.setContentType(“text/xml”);

out.println("" + error + “”);

out.flush();

}

protected void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

System.out.println(“Resquest=”+request);

System.out.println(“Response=”+response);

System.out.println(“request.getheader1=”+request.getHeader(“x-forwarded-for”));

System.out.println(“request.getheader2=”+request.getHeader(“X_FORWARDED_FOR”));

System.out.println(“request.getheader3=”+request.getHeader(“X-Forward-Forr”));

System.out.println(“getLocalAddr=”+request.getLocalAddr());

System.out.println(“getLocalName=”+request.getLocalName());

System.out.println(“getLocalPort=”+request.getLocalPort());

System.out.println(“getRemoteAddr=”+request.getRemoteAddr());

System.out.println(“getRemoteHost=”+request.getRemoteHost());

System.out.println(“getRemotePort=”+request.getRemotePort());

System.out.println(“getRemoteUser=”+request.getRemoteUser());

System.out.println(“getMethod=”+request.getMethod());

System.out.println(“getPathInfo=”+request.getPathInfo());

System.out.println(“getRequestURI=”+request.getRequestURI());

System.out.println(“getRequestURL=”+request.getRequestURL());

System.out.println(“getServerName=”+request.getServerName());

System.out.println(“getServerPort=”+request.getServerPort());

System.out.println(“getServletPath=”+request.getServletPath());

System.out.println(“getUserPrincipal=”+request.getUserPrincipal());

doGet(request, response);

}

public void destroy() {

super.destroy();

// Release the excluded URL

AuthCheckFilter.removeExclude(“userService/userservice”);

}

}

UserServiceplugin.java

import java.io.File;

import java.util.ArrayList;

import java.util.Collection;

import java.util.Collections;

import java.util.Map;

import java.util.StringTokenizer;

import org.apache.taglibs.standard.tag.common.core.SetSupport;

import org.jivesoftware.openfire.XMPPServer;

import org.jivesoftware.openfire.container.Plugin;

import org.jivesoftware.openfire.container.PluginManager;

import org.jivesoftware.openfire.group.Group;

import org.jivesoftware.openfire.group.GroupManager;

import org.jivesoftware.openfire.user.User;

import org.jivesoftware.openfire.user.UserAlreadyExistsException;

import org.jivesoftware.openfire.user.UserManager;

import org.jivesoftware.openfire.user.UserNotFoundException;

import org.jivesoftware.util.JiveGlobals;

import org.jivesoftware.util.PropertyEventDispatcher;

import org.jivesoftware.util.PropertyEventListener;

import org.jivesoftware.util.StringUtils;

import org.xmpp.packet.JID;

public class UserServicePlugin implements Plugin, PropertyEventListener{

UserManager userManager;

XMPPServer server;

String secret;

boolean enabled;

Collection allowedIPs;

public UserServicePlugin()

{

}

public void createUser(String username, String password, String name, String email, String groupNames)

throws UserAlreadyExistsException

{

userManager.createUser(username, password, name, email);

if(groupNames!=null)

{

Collection groups = new ArrayList();

StringTokenizer tkn=new StringTokenizer(groupNames, “,”);

while(tkn.hasMoreTokens())

{

try{

groups.add(GroupManager.getInstance().getGroup(tkn.nextToken()));

}catch (Exception e) {

// TODO: handle exception

}

for(Group group : groups){

group.getMembers().add(server.createJID(username, null));

}

}

}

}

public void deleteUser(String username) throws UserNotFoundException{

User user = getUser(username);

userManager.deleteUser(user);

}

public void updateUser(String username, String password, String name, String email, String groupNames)

throws UserNotFoundException

{

User user = getUser(username);

user.setPassword(password);

user.setName(name);

user.setEmail(email);

if(groupNames!=null){

Collection newGroups = new ArrayList();

StringTokenizer tkn = new StringTokenizer(groupNames, “,”);

while(tkn.hasMoreTokens()){

try{

newGroups.add(GroupManager.getInstance().getGroup(tkn.nextToken()));

}catch (Exception e) {

// TODO: handle exception

}

}

Collection existingGroups = GroupManager.getInstance().getGroups(user);

// Get the list of groups to add to the user

Collection groupsToAdd = new ArrayList(newGroups);

groupsToAdd.removeAll(existingGroups);

// Get the list of groups to remove from the user

Collection groupsToDelete = new ArrayList(existingGroups);

groupsToDelete.removeAll(newGroups);

// Add the user to the new groups

for(Group group : groupsToAdd){

group.getMembers().add(server.createJID(username, null));

}

// Remove the user from the old groups

for(Group group : groupsToDelete){

group.getMembers().remove(server.createJID(username, null));

}

}

}

/**

  • Returns the the requested user or null if there are any

  • problems that don’t throw an error.

  • @param username the username of the local user to retrieve.

  • @return the requested user.

  • @throws UserNotFoundException if the requested user

  •     does not exist in the local server.
    

*/

private User getUser(String username) throws UserNotFoundException {

JID targetJID = server.createJID(username, null);

// Check that the sender is not requesting information of a remote server entity

if(targetJID.getNode()!=null){

// Sender is requesting presence information of an anonymous user

throw new UserNotFoundException(“Username is null”);

}

return userManager.getUser(targetJID.getNode());

}

//@Override

public void destroyPlugin() {

// TODO Auto-generated method stub

userManager=null;

// Stop listening to system property events

PropertyEventDispatcher.removeListener(this);

}

//@Override

public void initializePlugin(PluginManager arg0, File arg1) {

// TODO Auto-generated method stub

server=XMPPServer.getInstance();

System.out.println(“server in UserServicePlugin.java=”+server);

userManager=server.getUserManager();

System.out.println(“userManager in UserServicePlugin.java=”+userManager);

secret=JiveGlobals.getProperty(“plugin.userservice.secret”,"");

// If no secret key has been assigned to the user service yet, assign a random one.

if(secret.equals(""))

{

secret=StringUtils.randomString(8);

setSecret(secret);

}

// See if the service is enabled or not.

enabled=JiveGlobals.getBooleanProperty(“plugin.userservice.enabled”,false);

// Get the list of IP addresses that can use this service. An empty list means that this filter is disabled.

allowedIPs=StringUtils.stringToCollection(JiveGlobals.getProperty(“plugin.users ervice.allowedIPs”,""));

// Listen to system property events

PropertyEventDispatcher.addListener(this);

}

//@Override

public void propertyDeleted(String property, Map<String, Object> params) {

// TODO Auto-generated method stub

if (property.equals(“plugin.userservice.secret”)) {

this.secret = “”;

}

else if (property.equals(“plugin.userservice.enabled”)) {

this.enabled = false;

}

else if (property.equals(“plugin.userservice.allowedIPs”)) {

this.allowedIPs = Collections.emptyList();

}

}

//@Override

public void propertySet(String property, Map<String, Object> params) {

// TODO Auto-generated method stub

if(property.equals(“plugin.userservice.secret”)){

this.secret = (String) params.get(“value”);

}else if(property.equals(“plugin.userservice.enabled”)){

this.enabled =Boolean.parseBoolean((String) params.get(“value”));

}else if(property.equals(“plugin.userservice.allowedIP”)){

this.allowedIPs =StringUtils.stringToCollection((String) params.get(“value”));

}

}

//@Override

public void xmlPropertyDeleted(String arg0, Map<String, Object> arg1) {

// TODO Auto-generated method stub

// Do nothing

}

//@Override

public void xmlPropertySet(String arg0, Map<String, Object> arg1) {

// TODO Auto-generated method stub

// Do nothing

}

/**

  • Returns the secret key that only valid requests should know.

  • @return the secret key.

*/

public String getSecret() {

return secret;

}

/**

  • Sets the secret key that grants permission to use the userservice.

  • @param secret the secret key.

*/

public void setSecret(String secret) {

JiveGlobals.setProperty(“plugin.userservice.secret”, secret);

this.secret = secret;

}

/**

  • Returns true if the user service is enabled. If not enabled, it will not accept

  • requests to create new accounts.

  • @return true if the user service is enabled.

*/

public boolean isEnabled() {

return enabled;

}

/**

  • Enables or disables the user service. If not enabled, it will not accept

  • requests to create new accounts.

  • @param enabled true if the user service should be enabled.

*/

public void setEnabled(boolean enabled) {

this.enabled = enabled;

JiveGlobals.setProperty(“plugin.userservice.enabled”, enabled ? “true” : “false”);

}

public Collection getAllowedIPs() {

return allowedIPs;

}

public void setAllowedIPs(Collection allowedIPs) {

JiveGlobals.setProperty(“plugin.userservice.allowedIPs”, StringUtils.collectionToString(allowedIPs));

this.allowedIPs = allowedIPs;

}

}

i have some following errors are occured after submitting … the error line is 24 in UserServiceServlet.java.

java.lang.NullPointerException

at jabbersmackapi.UserServiceServlet.init(UserServiceServlet.java:24)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)

at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 129)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: 191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10 9)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11P rotocol.java:588)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

at java.lang.Thread.run(Unknown Source)

Jun 14, 2012 4:07:57 PM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Allocate exception for servlet UserServiceServlet

java.lang.NullPointerException

at jabbersmackapi.UserServiceServlet.init(UserServiceServlet.java:24)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)

at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 129)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: 191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10 9)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11P rotocol.java:588)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

at java.lang.Thread.run(Unknown Source)

the openfire userservice plugin is not connected using java… so pls guys any suggestions … rply me…

Just copy libidn.jar to /path/to/openfier/lib/ and restart openfire.