AnsweredAssumed Answered

Missing classes: de/measite/minidns/DNSCache

Question asked by Justas on Apr 11, 2015
Latest reply on Apr 13, 2015 by Justas

I get this errors while launching my app. I added smack4.1.0 to my classpath.

 

 

Exception in thread "main" java.lang.NoClassDefFoundError: de/measite/minidns/DNSCache
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:340)
  at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.java:213)
  at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitialization.java:193)
  at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:163)
  at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:148)
  at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:116)
  at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96)
  at org.jivesoftware.smack.AbstractXMPPConnection.<clinit>(AbstractXMPPConnection.java:98)
  at lt.maze.SmackCcsClient.connect(SmackCcsClient.java:177)
  at lt.maze.Main.main(Main.java:22)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.ClassNotFoundException: de.measite.minidns.DNSCache
  at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  ... 16 more

For what its worth, here is the code:

 

 

public void connect(long senderId, String apiKey) throws XMPPException, IOException, SmackException {
   //config.setReconnectionAllowed(true);
  //config.setRosterLoadedAtLogin(false);


   connection = new XMPPTCPConnection(XMPPTCPConnectionConfiguration.builder()
  .setHost(GCM_SERVER)
  .setPort(GCM_PORT)
  .setSecurityMode(SecurityMode.required)
  .setSendPresence(false)
  .setSocketFactory(SSLSocketFactory.getDefault())
  .build());

   connection.setUseStreamManagement(true);
   connection.connect();


   connection.addConnectionListener(new LoggingConnectionListener());

   // Handle incoming packets
   connection.addAsyncStanzaListener(new StanzaListener() {

   @Override
   public void processPacket(Stanza packet) {
   logger.log(Level.INFO, "Received: " + packet.toXML());
   Message incomingMessage = (Message) packet;
   GcmPacketExtension gcmPacket = (GcmPacketExtension) incomingMessage.getExtension(GCM_NAMESPACE);
   String json = gcmPacket.getJson();
  try {
  JsonParser jsonParser = new JsonParser();
   JsonObject jsonObject = jsonParser.parse(json).getAsJsonObject();
   //Map<String, Object> jsonObject = (Map<String, Object>) JSONValue.parseWithException(json);

  // present for "ack"/"nack", null otherwise
   Object messageType = jsonObject.get("message_type");

  if (messageType == null) {
   // Normal upstream data message
   handleUpstreamMessage(jsonObject);

   // Send ACK to CCS
   connection.sendSmAcknowledgement();
   } else if ("ack".equals(messageType.toString())) {
   // Process Ack
   handleAckReceipt(jsonObject);
   } else if ("nack".equals(messageType.toString())) {
   // Process Nack
   handleNackReceipt(jsonObject);
   } else if ("control".equals(messageType.toString())) {
   // Process control message
   handleControlMessage(jsonObject);
   } else {
   logger.log(Level.WARNING,
   "Unrecognized message type (%s)",
   messageType.toString());
   }
  } catch (JsonParseException e) {
   logger.log(Level.SEVERE, "Error parsing JSON " + json, e);
   } catch (Exception e) {
   logger.log(Level.SEVERE, "Failed to process packet", e);
   }
  }
  }, new StanzaTypeFilter(Message.class));

   // Log all outgoing packets
   connection.addPacketInterceptor(new StanzaListener() {
   @Override
   public void processPacket(Stanza packet) throws NotConnectedException {
   logger.log(Level.INFO, "Sent: {0}", packet.toXML());
   }
  }, new StanzaTypeFilter(Message.class));
   connection.login(senderId + "@gcm.googleapis.com", apiKey);
}

 

This code is basend on Android GCM server implementation code.

Outcomes