Basic Info:I’ve created an java application that is an OPC UA client with the help of Eclipse milo packages (org.eclipse.milo.opcua.sdk and org.eclipse.milo.opcua.sdk.stack.core).
The project is a Maven Project (as well as other dependencies).
Im using Java 1.8 when generating jar, because i have Oracle 19c database with the same java version.
What i want:
I just want to be able to run java application on Oracle Database.
What i tried::
-
I successfully managed to run application in windows enviroment by exporting project to Runnable jar.
-
I tried to import that jar to Oracle Database using
loadjava
tool:loadjava -user user/password@db OPCUA.jar
I got errors:
Error while creating class META-INF/versions/9/module-info
ORA-29509: incorrectly constructed binary Java class definition ORA-06512: at line 1Error while creating class module-info
ORA-29509: incorrectly constructed binary Java class definition ORA-06512: at line 1The following operations failed
class META-INF/versions/9/module-info: creation (createFailed)
class module-info: creation (createFailed) exiting : Failures occurred during processing
- After that i excluded module-info and META-INF from maven build adding neccessary code to pom.xml ([/questions/46959965/maven-exclude-meta-inf-maven-folder-from-jar/46960549#46960549][]) however, it didnt helped.
- After that i changed way of generating JAR’s in Eclipse from
Extract required libraries into generated Jar
toPackage required libraries into generated Jar
- I tried to import it with
loadjava
tool but got plenty of exceptions
Error while determining classes contained in
org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java
Exception oracle.aurora.sqljdecl.ParseException: Encountered “@” at
line 40, column 9.Error while determining classes contained in
org/eclipse/milo/opcua/stack/core/util/TaskQueue.java Exception
oracle.aurora.sqljdecl.ParseException: Encountered “default” at line
343, columnError while determining classes contained in
org/eclipse/milo/opcua/stack/core/types/DataTypeEncoding.java
Exception oracle.aurora.sqljdecl.ParseException: Encountered “default”
at line 39, columnError while determining classes contained in
org/eclipse/milo/opcua/stack/core/types/OpcUaDefaultBinaryEncoding.java
Exception oracle.aurora.sqljdecl.ParseException: Encountered “@” at
line 61, column 13.Error while determining classes contained in
org/eclipse/milo/opcua/stack/core/types/DataTypeDictionary.java
Exception oracle.aurora.sqljdecl.ParseException: Encountered “default”
at line 97, column
and so on and so on… error repeats, but reasonis the same…
How Application looks like:
package OPCUA.ORACLE;
import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
import org.eclipse.milo.opcua.sdk.client.api.UaClient;
import org.eclipse.milo.opcua.sdk.client.nodes.UaVariableNode;
import org.eclipse.milo.opcua.stack.core.Identifiers;
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText;
import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint;
import java.util.concurrent.CompletableFuture;
public class OPCUA {
public static void main(String[] args) {
try {
// Create OPC UA client
OpcUaClient client=OpcUaClient.create(
"opc.tcp://127.0.0.1:62541/milo",
endpoints ->
endpoints.stream()
.findFirst(),
configBuilder ->
configBuilder
.setApplicationName(LocalizedText.english("eclipse milo opc-ua client"))
.setApplicationUri("urn:eclipse:milo:examples:client")
.setRequestTimeout(uint(5000))
.build()
);
// Connect to the server
CompletableFuture<UaClient> future = client.connect();
UaClient connectedClient = future.get();
System.out.println("Connected to the OPC UA server.");
// Read a value from a variable node
NodeId nodeId = Identifiers.Server_ServerStatus_CurrentTime;
UaVariableNode variableNode = connectedClient.getAddressSpace().getVariableNode(nodeId);
DataValue value = variableNode.readValue();
System.out.println("Value: " + value.getValue().getValue());
// Disconnect the client
client.disconnect().get();
System.out.println("Disconnected from the OPC UA server.");
} catch (Exception e) {
e.printStackTrace();
}
}
}
On the end I would like to state that im not a java developer at any point, so im totally green on those topics.
I would want to ask you, if you know what i might be doing wrong that stops me from loading JAR into Oracle Database and being able to run it.
1