Bug 87074 - If called NLP Solver macro is interrupted by an error on the line where the set ObjectiveCell.
Summary: If called NLP Solver macro is interrupted by an error on the line where the s...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.1.1.2 release
Hardware: All All
: medium major
Assignee: LeMoyne Castle
URL:
Whiteboard: target:4.5.0
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-07 15:38 UTC by Derka Ladislav
Modified: 2015-12-17 20:34 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Call NPL Solver using macros (43.87 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-12-07 15:38 UTC, Derka Ladislav
Details
Spreadsheet file .ods containing macro (43.87 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-12-07 15:44 UTC, Derka Ladislav
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Derka Ladislav 2014-12-07 15:38:29 UTC
Created attachment 110534 [details]
Call NPL Solver using macros

An operating system and software: Ubuntu 14.04LTS
LibreOffice 4.2.7.2, LibreOffice 4.3.2.2, LibreOffice 4.4.0.0.beta1.

The error is probably on all versions of LibreOffice Series 4, is not affected by LibreOffice 3 Series and all versions of Apache Open Office.

Reproduction of errors (attachment file .ods):

Sub RunSolveDEPS
	Dim Solver as Object    
	Set Solver = CreateUnoService("com.sun.star.comp.Calc.NLPSolver.DEPSSolverImpl")
	Solver.Document = ThisComponent
	
	Dim VariableCells(2) as new com.sun.star.table.CellAddress
	VariableCells(0).Sheet = 0
	VariableCells(0).Row = 1
	VariableCells(0).Column = 1
	
	VariableCells(1).Sheet = 0
	VariableCells(1).Row = 2
	VariableCells(1).Column = 1
	
	VariableCells(2).Sheet = 0
	VariableCells(2).Row = 3   
	VariableCells(2).Column = 1
	
	Solver.Variables = VariableCells
	
	Dim ObjectiveCell as new com.sun.star.table.CellAddress
	ObjectiveCell.Sheet = 0
	ObjectiveCell.Row = 3
	ObjectiveCell.Column = 3
	
	Solver.Objective = ObjectiveCell ' <== Error !!!	
	' Type: com.sun.star.uno.RuntimeException
	' Message: [jni_uno bridge error] UNO calling Java method Objective: [map_to_uno():com.sun.star.table.CellAddress] null-ref given!
	' java stack trace:
	' .
				
	Solver.Solve

End Sub

Error message:
"Type: com.sun.star.uno.RuntimeException
Message: [jni_uno bridge error] UNO calling Java method Objective: [map_to_uno (): com.sun.star.table.CellAddress] null-ref given!
java stack trace:
. "
Comment 1 Derka Ladislav 2014-12-07 15:44:22 UTC
Created attachment 110535 [details]
Spreadsheet file .ods containing macro

Spreadsheet file ods containing macro
Comment 2 Derka Ladislav 2014-12-07 15:46:29 UTC
Comment on attachment 110534 [details]
Call NPL Solver using macros

Sub RunSolveDEPS
	Dim Solver as Object    
	Set Solver = CreateUnoService("com.sun.star.comp.Calc.NLPSolver.DEPSSolverImpl")
	Solver.Document = ThisComponent
	
	Dim VariableCells(2) as new com.sun.star.table.CellAddress
	VariableCells(0).Sheet = 0
	VariableCells(0).Row = 1
	VariableCells(0).Column = 1
	
	VariableCells(1).Sheet = 0
	VariableCells(1).Row = 2
	VariableCells(1).Column = 1
	
	VariableCells(2).Sheet = 0
	VariableCells(2).Row = 3   
	VariableCells(2).Column = 1
	
	Solver.Variables = VariableCells
	
	Dim ObjectiveCell as new com.sun.star.table.CellAddress
	ObjectiveCell.Sheet = 0
	ObjectiveCell.Row = 3
	ObjectiveCell.Column = 3
	
	Solver.Objective = ObjectiveCell ' <== Error !!!	
	' Type: com.sun.star.uno.RuntimeException
	' Message: [jni_uno bridge error] UNO calling Java method Objective: [map_to_uno():com.sun.star.table.CellAddress] null-ref given!
	' java stack trace:
	' .
				
	Solver.Solve

End Sub

Sub RunSolveSCO
	Dim Solver as Object    
	Set Solver = CreateUnoService("com.sun.star.comp.Calc.NLPSolver.SCOSolverImpl")
	Solver.Document = ThisComponent
	
	Dim VariableCells(2) as new com.sun.star.table.CellAddress
	VariableCells(0).Sheet = 0
	VariableCells(0).Row = 1
	VariableCells(0).Column = 1
	
	VariableCells(1).Sheet = 0
	VariableCells(1).Row = 2
	VariableCells(1).Column = 1
	
	VariableCells(2).Sheet = 0
	VariableCells(2).Row = 3   
	VariableCells(2).Column = 1
	
	Solver.Variables = VariableCells
	
	Dim ObjectiveCell as new com.sun.star.table.CellAddress
	ObjectiveCell.Sheet = 0
	ObjectiveCell.Row = 3
	ObjectiveCell.Column = 3

	Solver.Objective = ObjectiveCell ' <== Error !!!
	' Type: com.sun.star.uno.RuntimeException
	' Message: [jni_uno bridge error] UNO calling Java method Objective: [map_to_uno():com.sun.star.table.CellAddress] null-ref given!
	' java stack trace:
	' .
				
	Solver.Solve

End Sub
Comment 3 Julien Nabet 2014-12-07 17:29:31 UTC
On pc Debian x86-64 with master sources updated yesterday, I could reproduce this.

Stephan: one for you?
Comment 4 LeMoyne Castle 2015-02-15 16:58:15 UTC
Set version 4.1.1.2 to match OO forum report Sept. 2013 (See Also -- https://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=64323 )
Set hardware to all because "null-ref" error message is coming from java-uno bridge map_to_uno when it is given a Null l-value for the CellAddress struct that describes the cell that contains the Objective value (value to be minimized). 
Patch forthcoming.
Comment 5 LeMoyne Castle 2015-02-17 07:18:18 UTC
Patch submitted -- https://gerrit.libreoffice.org/14499

Probem also appears in the User List: 
http://nabble.documentfoundation.org/Solver-bug-td4134802.html

Not sure if there is an immediate patch process possible.  It might be possible because the repair is in the AddIn java. However...
The corrected AddIn would not install (interface is already there) and 
the built-in NLPsolver cannot be removed (doesn't appear in Ext Mgr).
Comment 6 Adolfo Jayme Barrientos 2015-02-17 11:24:49 UTC
http://cgit.freedesktop.org/libreoffice/core/commit/?id=c290998df667bd2a8a12379642f79d09eca471c3

tdf#87074 null-ref error from NLPSolver in Basic
Comment 7 koukasio 2015-12-15 19:46:29 UTC
How can I have this macro to work on linux? (Ubuntu 14.04)
What do I have to do? I tried to install a more recent package
https://packages.debian.org/sid/all/libreoffice-nlpsolver/download
but it still did not work
Comment 8 Julien Nabet 2015-12-15 20:31:32 UTC
(In reply to koukasio from comment #7)
> How can I have this macro to work on linux? (Ubuntu 14.04)
> What do I have to do? I tried to install a more recent package
> https://packages.debian.org/sid/all/libreoffice-nlpsolver/download
> but it still did not work

Use LO ppa (see https://launchpad.net/~libreoffice/+archive/ubuntu/ppa) and use last stable LO version (5.0.3).
Also, please rename your LO directory profile (see https://wiki.documentfoundation.org/UserProfile#GNU.2FLinux)
Comment 9 koukasio 2015-12-16 04:36:46 UTC
Thanks . I had already installed 5.0.3. I deleted my .config/libreoffice folder and a new one was automatically created . Still, the macro returns the same error. I am using the attachment for testing. The nlpsolver is not included in the ppa, I used the old package. I can do things in Linux, I will be able to follow any directions you give me.
Comment 10 Julien Nabet 2015-12-16 06:22:28 UTC
(In reply to koukasio from comment #9)
> Thanks . I had already installed 5.0.3. I deleted my .config/libreoffice
> folder and a new one was automatically created . Still, the macro returns
> the same error. I am using the attachment for testing. The nlpsolver is not
> included in the ppa, I used the old package. I can do things in Linux, I
> will be able to follow any directions you give me.

It's perhaps a different error then.
Could you provide the precise error and attach a file with a minimal step by step process to reproduce this so we can give it a try?

Derka: is it ok for you with LeMoyne Castle's patch?
Comment 11 koukasio 2015-12-16 07:42:32 UTC
(In reply to Julien Nabet from comment #10)
> It's perhaps a different error then.
> Could you provide the precise error and attach a file with a minimal step by
> step process to reproduce this so we can give it a try?

BASIC runtime error.
An exception occurred 
Type: com.sun.star.uno.RuntimeException
Message: [jni_uno bridge error] UNO calling Java method Objective: [map_to_uno():com.sun.star.table.CellAddress] null-ref given!
java stack trace:
.

and the 	"Solver.Objective = ObjectiveCell ' <== Error !!!	" line gets highlighted in the macro editor

I just push the "Run DEPS Solver" button on the attachment above.


> 
> Derka: is it ok for you with LeMoyne Castle's patch?

No, I would need a bit more guidance.
Comment 12 Derka Ladislav 2015-12-16 19:00:52 UTC
In LibreOffice 5.0.3.2 nlpsolver works without error.
Thanks, good job

(Ubuntu 14.04.3, 64 bit)
Comment 13 Julien Nabet 2015-12-16 19:07:31 UTC
Koukasio: since Derka confirmed it's ok, please submit a new bug.
Comment 14 koukasio 2015-12-17 19:20:38 UTC
Derka: I tried everything.. updated to 14.04.3 (64bit) - uninstalled-purged-reinstalled several times... deleted my /config/libreoffice folder...
before submitting a new bug:
What else is there that could make the difference between you and me?
What jre are you using?
Are you using the attachment above for testing?
Are you using the "nlpsolver 0.9~beta1-9ubuntu1"   package from apt?
Comment 15 Derka Ladislav 2015-12-17 19:43:42 UTC
Currently installed on my system:
java version "1.7.0_91"
OpenJDK Runtime Environment (IcedTea 2.6.3) (7u91-2.6.3-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

Package "nlpsolver ~ 0.9 beta 1-ubuntu" is not used.
It introduced "libobasis5.0-extension-nlpsol 5.0.3.2-2", which is part of LibreOffice 5.0.3.2.
Comment 16 koukasio 2015-12-17 20:34:14 UTC
That last info was trivial. Thanks.
I installed from .deb files from
http://www.libreoffice.org/download/libreoffice-fresh/?type=deb-x86_64&version=5.0.3&lang=en-US
and everything worked fine.
When installed from ppa there is no nlpsolver.
Thanks everyone for the great work.