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());
}
}