Page 1 of 1

[Dropped] Java macro running from Basic can't find method

Posted: Fri Oct 03, 2025 3:16 pm
by JulianR
I am writing a JDBC replacement for ODBC since it is unstable and fails at random on some queries, and I have run into a problem.

Java code is called from Basic with this subrutine.

Code: Select all

Sub CallJava()
    Dim mspf As Object, provider As Object, script As Object
    mspf = createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory")
    provider = mspf.createScriptProvider("")
    script = provider.getScript("vnd.sun.star.script:SWILODB.pl.ms.oknadrewniane.libreoffice.database.DoorHingeSheetData.getDoorData?language=Java&location=user")
    xray script.invoke(Array(Array("Julian", 2)), Array(), Array())
    script = provider.getScript("vnd.sun.star.script:SWILODB.pl.ms.oknadrewniane.libreoffice.database.DoorHingeSheetData.getDoorData?language=Java&location=user")
    xray script.invoke(Array(Array("192.168.56.101", "T25_0625")), Array(), Array())
End Sub
First call works correctly, I get my message about wrong data types.But when I try to run it second time, I get and error:
Type: com.sun.star.script.provider.ScriptFrameworkErrorException
Message: java.lang.NoSuchMethodException: StrictResolver.getProxy: Can't find method: getDoorData.


My parcel-descriptor for this code looks like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<parcel language="Java" xmlns:parcel="scripting.dtd">
	<script language="Java">
		<locale lang="en">
			<displayname value="Get Door Data"/>
			<description>
				Downloads data for doors in a given queue
			</description>
		</locale>
		<locale lang="pl">
			<displayname value="Get Door Data"/>
			<description>
				Pobiera dane drzwi w podanej kolejce
			</description>
		</locale>
		<functionname value="pl.ms.oknadrewniane.libreoffice.database.DoorHingeSheetData.getDoorData"/>
		<logicalname value="getDoorData"/>
		<languagedepprops>
			<prop name="classpath" value="SWILODB.jar"/>
		</languagedepprops>
	</script>
</parcel>
Java code is using some dependencies like mysql-connector-j-8.0.33.jar and protobuf-java-3.21.9.jar (this is dependency from previous file). But I am unsure how to specify them as dependencies, since when I put them on classpath (separated with semicolon) script could not find the class at all.

Re: Java macro running from Basic can't find method

Posted: Mon Oct 06, 2025 9:53 am
by Bidouille
JulianR wrote: Fri Oct 03, 2025 3:16 pmApache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
Which one?

JulianR wrote: Fri Oct 03, 2025 3:16 pmJava code is using some dependencies like mysql-connector-j-8.0.33.jar
Native MySQL connector is provided under extension: https://extensions.openoffice.org/fr/pr ... ffice.html

Re: Java macro running from Basic can't find method

Posted: Mon Oct 06, 2025 9:58 am
by JulianR
Apologies, forgot to update my signature. I am targeting LibreOffice 7+ on Windows.

Re: Java macro running from Basic can't find method

Posted: Tue Oct 07, 2025 9:57 am
by Bidouille
JulianR wrote: Mon Oct 06, 2025 9:58 am LibreOffice 7.6.2.1 on Windows 10
This build is largely obsolete and Windows 10 is at the end of its life cycle.
Perhaps you should update first.

Re: Java macro running from Basic can't find method

Posted: Tue Oct 07, 2025 10:24 am
by JulianR
Upgrading is problematic due to lack of time to do manual testing of other applications. I will switch to temporary files and executing external software with shell.