AnsweredAssumed Answered

how to connect to openfire server using smack api 4.1.0

Question asked by amir on Apr 18, 2015

i am trying to connect to my openfire server by this code

String DOMAIN = "my server ip";
AbstractXMPPConnection connection;
try{
 XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
    config.setSecurityMode(SecurityMode.disabled);
    config.setUsernameAndPassword("admin@"+DOMAIN, "my password");
    config.setServiceName(DOMAIN);
    config.setHost(DOMAIN);
    config.setPort(5222);
    config.setDebuggerEnabled(true);
   connection = new XMPPTCPConnection(config.build());
   connection.setPacketReplyTimeout(10000);
   connection.addConnectionListener(this);
     connection.connect();
     AccountManager AM = AccountManager.getInstance(connection);
     AM.createAccount("userName", "password");
     connection.disconnect();
     System.out.println(":)");
    } 
  catch(Exception e){
  System.out.println(":(");
   
  }

my code is in try catch statement but still after running this code nothing gets printed and i get this errors:

 

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

Caused by: java.lang.reflect.InvocationTargetException

  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 sun.reflect.misc.Trampoline.invoke(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at sun.reflect.misc.MethodUtil.invoke(Unknown Source)

  ... 48 more

Caused by: java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserFactory

  at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:153)

  at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:148)

  at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:11 6)

  at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96 )

  at org.jivesoftware.smack.ConnectionConfiguration.<clinit>(ConnectionConfiguration .java:38)

  at application.XmppFuncs.Register(XmppFuncs.java:56)

  at application.Form1.btn_register_onclick(Form1.java:43)

  ... 57 more

Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserFactory

  at java.net.URLClassLoader$1.run(Unknown Source)

  at java.net.URLClassLoader$1.run(Unknown Source)

  at java.security.AccessController.doPrivileged(Native Method)

  at java.net.URLClassLoader.findClass(Unknown Source)

  at java.lang.ClassLoader.loadClass(Unknown Source)

  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

  at java.lang.ClassLoader.loadClass(Unknown Source)

  ... 64 more

 

how can i fix this?

thanks in advance

Outcomes