servlets - java.lang.ClassNotFoundException: org.jivesoftware.smack.SmackException$NotConnectedException Smack -


smack not working servlet. however, works fine when copy-paste code , run desktop application. error occurs @ chatserver.java:42 here's code:

servlet (chatserver.java):

import java.io.ioexception; import java.io.printwriter; import java.util.arraylist; import java.util.collection; import java.util.hashmap;  import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse;  import org.jivesoftware.smack.rosterentry;  /**  * servlet implementation class chatserver  */ @webservlet("/chatserver") public class chatserver extends httpservlet {     private static final long serialversionuid = 1l;      /**      * default constructor.       */     public chatserver() {         // todo auto-generated constructor stub     }      /**      * @see httpservlet#doget(httpservletrequest request, httpservletresponse response)      */     protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {      }      /**      * @see httpservlet#dopost(httpservletrequest request, httpservletresponse response)      */     protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {             string jid =  request.getparameter("jid");             string pword = request.getparameter("pword");             connection.register(jid, pword, "192.168.1.75", "5222");         }       } 

connection class (connection.java):

import java.util.collection; import org.jivesoftware.smack.connectionconfiguration; import org.jivesoftware.smack.roster; import org.jivesoftware.smack.rosterentry; import org.jivesoftware.smack.saslauthentication; import org.jivesoftware.smack.smackexception.notconnectedexception; import org.jivesoftware.smack.xmppconnection; import org.jivesoftware.smack.packet.presence; import org.jivesoftware.smack.tcp.xmpptcpconnection;    public class connection{      /**      * @param args      */     static xmppconnection connection;      public static void register(string username, string password, string host, string port){         //  username += "@" + host;         string service = host;         connectionconfiguration connconfig =                 new connectionconfiguration(host, integer.parseint(port), service);         connection = new xmpptcpconnection(connconfig);         saslauthentication.supportsaslmechanism("plain", 0);         connconfig.setsecuritymode(connectionconfiguration.securitymode.disabled);         try {             connection.connect();         }catch (exception e) {             // todo auto-generated catch block             e.printstacktrace();         }         try {             connection.login(username, password);         } catch (exception e) {             // todo auto-generated catch block             e.printstacktrace();         }          // set status available         presence presence = new presence(presence.type.available);         try {             connection.sendpacket(presence);         } catch (notconnectedexception e) {             // todo auto-generated catch block             e.printstacktrace();         }     }     public static collection<rosterentry> getroster(){         roster roster = connection.getroster();         collection<rosterentry> entries = roster.getentries();         return entries;      }      public static void sendmsg(string jid, string msg_text){      } } 

full stack trace:

java.lang.classnotfoundexception: org.jivesoftware.smack.smackexception$notconnectedexception     @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1720)     @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1571)     @ chatserver.create_connection(chatserver.java:73)     @ chatserver.dopost(chatserver.java:52)     @ javax.servlet.http.httpservlet.service(httpservlet.java:646)     @ javax.servlet.http.httpservlet.service(httpservlet.java:727)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208)     @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:220)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:122)     @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:504)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:170)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:103)     @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:950)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:116)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:421)     @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1074)     @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:611)     @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:314)     @ java.util.concurrent.threadpoolexecutor.runworker(unknown source)     @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source)     @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)     @ java.lang.thread.run(unknown source) 

you're missing jar contains org.jivesoftware.smack.smackexception class. need place jar on classpath. since appears servlet running in tomcat should package jar application before deploying it.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -