• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Problems with start BACnet4j (java.lang.ClassNotFoundException)

    BACnet4J general discussion
    2
    4
    3.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      balak1
      last edited by

      Hi

      I am new to Bacnet4j.
      I just trying to start the BacnetTest example in Netbeans but I get an exception.
      Can anybody give me hint what it could be the problem?

      Here is the output I get from Netbeans

      Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/ObjectUtils
      	at com.serotonin.bacnet4j.obj.BACnetObject.setPropertyImpl(BACnetObject.java:269)
      	at com.serotonin.bacnet4j.obj.BACnetObject.setProperty(BACnetObject.java:193)
      	at com.serotonin.bacnet4j.obj.BACnetObject.<init>(BACnetObject.java:88)
      	at com.serotonin.bacnet4j.LocalDevice.<init>(LocalDevice.java:118)
      	at bacnettest.BacnetTest.main(BacnetTest.java:30)
      Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.ObjectUtils
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
      	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      	... 5 more
      Java Result: 1
      BUILD SUCCESSFUL (total time: 1 second)
      

      the original Code from infiniteautomation/BACnet4J

      
      import java.util.List;
      import com.serotonin.bacnet4j.LocalDevice;
      import com.serotonin.bacnet4j.RemoteDevice;
      import com.serotonin.bacnet4j.event.DeviceEventAdapter;
      import com.serotonin.bacnet4j.exception.BACnetException;
      import com.serotonin.bacnet4j.npdu.ip.IpNetwork;
      import com.serotonin.bacnet4j.service.acknowledgement.ReadPropertyAck;
      import com.serotonin.bacnet4j.service.confirmed.ReadPropertyRequest;
      import com.serotonin.bacnet4j.service.unconfirmed.WhoIsRequest;
      import com.serotonin.bacnet4j.transport.Transport;
      import com.serotonin.bacnet4j.type.constructed.SequenceOf;
      import com.serotonin.bacnet4j.type.constructed.ServicesSupported;
      import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
      import com.serotonin.bacnet4j.type.enumerated.Segmentation;
      import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
      import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
      import com.serotonin.bacnet4j.util.RequestUtils;
      public class BacnetTest {
      static LocalDevice localDevice;
      public static void main(String[] args) throws Exception {
      IpNetwork network = new IpNetwork();
      Transport transport = new Transport(network);
      // transport.setTimeout(15000);
      // transport.setSegTimeout(15000);
      localDevice = new LocalDevice(1234, transport);
      try {
      localDevice.initialize();
      localDevice.getEventHandler().addListener(new Listener());
      localDevice.sendGlobalBroadcast(new WhoIsRequest());
      Thread.sleep(200000);
      }
      finally {
      localDevice.terminate();
      }
      }
      static class Listener extends DeviceEventAdapter {
      @Override
      public void iAmReceived(final RemoteDevice d) {
      System.out.println("IAm received from " + d);
      System.out.println("Segmentation: " + d.getSegmentationSupported());
      d.setSegmentationSupported(Segmentation.noSegmentation);
      new Thread(new Runnable() {
      @Override
      public void run() {
      try {
      getExtendedDeviceInformation(d);
      System.out.println("Done getting extended information");
      List oids = ((SequenceOf) RequestUtils.sendReadPropertyAllowNull(localDevice, d,
      d.getObjectIdentifier(), PropertyIdentifier.objectList)).getValues();
      System.out.println(oids);
      }
      catch (BACnetException e) {
      e.printStackTrace();
      }
      }
      }).start();
      }
      }
      static void getExtendedDeviceInformation(RemoteDevice d) throws BACnetException {
      ObjectIdentifier oid = d.getObjectIdentifier();
      // Get the device's supported services
      System.out.println("protocolServicesSupported");
      ReadPropertyAck ack = (ReadPropertyAck) localDevice.send(d, new ReadPropertyRequest(oid,
      PropertyIdentifier.protocolServicesSupported));
      d.setServicesSupported((ServicesSupported) ack.getValue());
      System.out.println("objectName");
      ack = (ReadPropertyAck) localDevice.send(d, new ReadPropertyRequest(oid, PropertyIdentifier.objectName));
      d.setName(ack.getValue().toString());
      System.out.println("protocolVersion");
      ack = (ReadPropertyAck) localDevice.send(d, new ReadPropertyRequest(oid, PropertyIdentifier.protocolVersion));
      d.setProtocolVersion((UnsignedInteger) ack.getValue());
      // System.out.println("protocolRevision");
      // ack = (ReadPropertyAck) localDevice.send(d, new ReadPropertyRequest(oid, PropertyIdentifier.protocolRevision));
      // d.setProtocolRevision((UnsignedInteger) ack.getValue());
      }
      }
      
      
      1 Reply Last reply Reply Quote 0
      • J
        joolz
        last edited by

        Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/ObjectUtils  
        

        You are missing a jar file (commons-lang3-3.0.jar) in your classpath

        1 Reply Last reply Reply Quote 0
        • B
          balak1
          last edited by

          Thanks now it compiles :) (after i added one more jar file - seroUtils.jar).

          1 Reply Last reply Reply Quote 0
          • First post
            Last post