B4J Question COM connection

mik1214324

Member
Licensed User
Hi Guys!
Somebody please help me to get this code to work (the project and library is attached)

B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
    #AdditionalJar: c:\stuff\jacob\jacob.jar
#End Region   

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Show
    Dim jjo As JavaObject = Me
    jjo.RunMethod("cnct1c",Null)
End Sub

#If JAVA
    import com.jacob.activeX.ActiveXComponent;
    import com.jacob.com.ComFailException;
    import com.jacob.com.Dispatch;
    import com.jacob.com.Variant;
    import java.lang.String;

    public static void cnct1c() {

        ActiveXComponent v8 = new ActiveXComponent("V83.COMConnector");
        String conString = "File=d:\\1cbase\\auto;Usr=Admin;Pwd=";
        Variant connection = Dispatch.call(v8, "Connect", conString);
        return;
    }
#End If

It throws error:

main._appstart (java line: 64)
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.main._appstart(main.java:64)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:42)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ExceptionInInitializerError
at b4j.example.main.cnct1c(main.java:95)
... 22 more
Caused by: java.lang.IllegalStateException: Can't find META-INF/JacobVersion.properties using JacobReleaseInfo.class.getClassLoader().getResourceAsStream()
at com.jacob.com.JacobReleaseInfo.loadVersionProperties(JacobReleaseInfo.java:55)
at com.jacob.com.JacobReleaseInfo.getBuildVersion(JacobReleaseInfo.java:91)
at com.jacob.com.LibraryLoader.getPreferredDLLName(LibraryLoader.java:202)
at com.jacob.com.LibraryLoader.loadJacobLibrary(LibraryLoader.java:178)
at com.jacob.com.JacobObject.<clinit>(JacobObject.java:110)
... 23 more
 

Attachments

  • jcom.zip
    466 KB · Views: 286

mik1214324

Member
Licensed User
Try it with #MergeLibraries: False

Now

(this lib uses 2 dll files, which i'm copied to lib path. thse files are also in the attached archive)

main._appstart (java line: 64)
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.main._appstart(main.java:64)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:42)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.jacob.com.ComFailException: Can't co-create object
at com.jacob.com.Dispatch.createInstanceNative(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java:99)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58)
at b4j.example.main.cnct1c(main.java:95)
... 22 more
 
Upvote 0

mik1214324

Member
Licensed User
This is a different error. Looks like you are not using the API correctly.
Oooo...Solved!
"V83.COMConnector" lib was 32bit so I just changed JDK to 32bit.

PS. For those who want to use JACOB to integrate with 1c (actual for russian users mostly) - JACOB (and other COM connectors dont work with 1c version 8.3). It fails when connecting to "V83.COMConnector" because of backbas.dll and comcntr.dll of 1c.
It throws errors:

Event: 0.038 Thread 0x00921000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class; name or signature does not match> (0x0f206eb8) thrown at [C:\ws\workspace\jdk-8u252\label\windows-x86\type\b8\build\hotspot\src\share\v

Event: 0.038 Thread 0x00921000 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.prefetchRead(Ljava/lang/Object;J)V name or signature does not match> (0x0f207188) thrown at [C:\ws\workspace\jdk-8u252\label\windows-x86\type\b8\build\hotspot\src\share\vm\prims\jni.cpp, l

So as Im understood if someone could recompile JACOB to accept this functions it could work..

But "V83.Application" works well.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…