wbb
1
now I want to wirte a simple exmple with smack. but fail. I very sadly. can you help me?
below is my java program, and it’s will throw nullpoint exception when runing.
public class App
{
public static void main( String[] args ) throws Exception
{
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword(“test”, “test”);
configBuilder.setXmppDomain(“jabber.org”);
configBuilder.setHost(“10.15.233.144”);
configBuilder.setPort(5222);
configBuilder.setConnectTimeout(30000);
AbstractXMPPConnection connection = new XMPPTCPConnection(configBuilder.build());
connection.connect();
connection.login();
connection.disconnect();
}
}
Hi wbb!
Have you tried using a debugger to find out, which line throws the NPE?
If you still struggle with the problem, please provide a stacktrace.
wbb
3
below is my stacktrace,thanks vary much.
Exception in thread “main” java.lang.NullPointerException
at org.jivesoftware.smack.util.stringencoder.Base64.encode(Base64.java:64)
at org.jivesoftware.smack.util.stringencoder.Base64.encode(Base64.java:60)
at org.jivesoftware.smack.util.stringencoder.Base64.encodeToString(Base64.java:42)
at org.jivesoftware.smackx.caps.EntityCapsManager.generateVerificationString(Entit yCapsManager.java:723)
at org.jivesoftware.smackx.caps.EntityCapsManager.generateVerificationString(Entit yCapsManager.java:589)
at org.jivesoftware.smackx.caps.EntityCapsManager.updateLocalEntityCaps(EntityCaps Manager.java:485)
at org.jivesoftware.smackx.caps.EntityCapsManager.(EntityCapsManager.java:31 3)
at org.jivesoftware.smackx.caps.EntityCapsManager.getInstanceFor(EntityCapsManager .java:376)
at org.jivesoftware.smackx.caps.EntityCapsManager$1.connectionCreated(EntityCapsMa nager.java:119)
at org.jivesoftware.smack.AbstractXMPPConnection.(AbstractXMPPConnection.jav a:304)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.(XMPPTCPConnection.java:306)
at com.niwodai.smack.smacktest.App.main(App.java:22)
Hm, looks like no Base64 implementation is set. What system are you on?
What Smack version? Which JRE? Which smack module do you include?
Please do not import the jars manually. Use a build system like gradle or maven instead.
wbb
9
the version is smack 4.2.0 , jre is 1.7.0_67, I have include all smack jar.
wbb
10
yes , I import jar with maven.
wbb
11
it looks like smack 4.2.0 have bugs or it’s code is not complete.
Since it works for me and most other people, I’d rather assume the problem is on your side.
wbb
13
mybe my problem. I’m so sadly, just a simple example,but I can’t work it out.
do you have some simple exmple? can you send to me? my email is wbbcg4426493@163.com.
Flow
14
I don’t see smack-java7 in this picture.
Also you can remove at least dnsjava and smack-experimental, as those are transitive dependencies.
wbb
15
thanks very much. there are no smack-java7 in my pom.xml. I download smack. but there are no smack-java7. I think it’s the key.
Flow
16
Please make sure to read the readme: Smack 4.2 Readme and Upgrade Guide · igniterealtime/Smack Wiki · GitHub
1 Like
wbb
17
thanks very much. I had created connection successfully to openfire server. thanks for your help, and patience.