carlosCharz / fcmxmppserverv2

XMPP Connection Server for FCM using the latest version of the Smack library (4.3.4) + Connection Draining Implementation
47 stars 33 forks source link

Exception class has interface as super class #15

Closed James-Guo closed 6 years ago

James-Guo commented 6 years ago

I'm having difficulty attempting to add the GcmPacketExtension where I'm encountering this exception:

Exception in thread "main" java.lang.IncompatibleClassChangeError: class de.measite.minidns.cache.LRUCache has interface de.measite.minidns.DNSCache as super class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at de.measite.minidns.AbstractDNSClient.<clinit>(AbstractDNSClient.java:40)
    at de.measite.minidns.hla.ResolverApi.<clinit>(ResolverApi.java:25)
    at org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver.<clinit>(MiniDnsResolver.java:54)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.java:219)
    at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitialization.java:199)
    at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:169)
    at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:154)
    at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:120)
    at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:97)
    at org.jivesoftware.smack.provider.ProviderManager.<clinit>(ProviderManager.java:122)
    at com.wedevol.xmpp.server.CcsClient.<init>(CcsClient.java:77)
    at com.wedevol.xmpp.server.CcsClient.<init>(CcsClient.java:69)
    at com.wedevol.xmpp.server.CcsClient.prepareClient(CcsClient.java:62)
    at com.wedevol.xmpp.EntryPoint.main(EntryPoint.java:35)

It's occurring here:

ProviderManager.addExtensionProvider(Util.FCM_ELEMENT_NAME, Util.FCM_NAMESPACE,
        new ExtensionElementProvider<GcmPacketExtension>() {
            @Override
            public GcmPacketExtension parse(XmlPullParser parser, int initialDepth)
                    throws XmlPullParserException, IOException, SmackException {
                String json = parser.nextText();
                return new GcmPacketExtension(json);
            }
        });
carlosCharz commented 6 years ago

Hello James, I have not experienced that issue. It looks like an invalid configuration? Have you changed something? Have you checked that the parameters are correct?

Anyway I was reading about your exception: https://stackoverflow.com/questions/1980452/what-causes-java-lang-incompatibleclasschangeerror

Check it out and let me know. Greetings!

James-Guo commented 6 years ago

Hi Carlos,

Thanks for the quick response. I'm not too sure if it's an invalid configuration. The only thing I've changed would have been in the EntryPoint class from using the args to just hard coding the values for testing

public static void main(String[] args) throws SmackException, IOException {
//    final String fcmProjectSenderId = args[0];
//    final String fcmServerKey = args[1];
//    final String toRegId = args[2];   

  final String fcmProjectSenderId = "XXXXXXXX";
  final String fcmServerKey = "XXXXXXXX";
  final String toRegId = "XXXXXXXX";
}

I'm quite new to Java so I'm not too certain on importing libraries and I was thinking it was potentially a problem with using multiple versions of a specific class within the libraries that I have imported. A similar problem is shown here. https://stackoverflow.com/questions/16209623/incompatibleclasschangeerror-class-classmetadatareadingvisitor-has-interface-cl

These are the libraries that I'm using: screenshot

Am I missing anything or have I made an importing overlap perhaps?

Thank you once again

carlosCharz commented 6 years ago
  1. Hard coding is not a problem
  2. It seems to be the libraries. The error is related to that. Are you using maven and eclipse?
James-Guo commented 6 years ago

I'm using eclipse and I've been looking into maven at the moment

James-Guo commented 6 years ago

Solved the issue. It was just a problem with how I was importing the project.

Another quick question. Would this server be able to receive XMPP messages from external sources i.e, not through Firebase?

To provide some context. I'm looking to create a web application that would be able to communicate with this Java server and the Java server can communicate with the Android devices.

carlosCharz commented 6 years ago

Hello James. That's good you solved the problem. About your question. I guess yes because Smack let you do that and the app was built on top of the Smack library (ccs client server).