Issue 94036 - When starting open office in listening mode with java registered databases are not recognised
Summary: When starting open office in listening mode with java registered databases ar...
Status: UNCONFIRMED
Alias: None
Product: Base
Classification: Application
Component: code (show other issues)
Version: OOo 2.4.1
Hardware: PC All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-18 14:05 UTC by kpassey
Modified: 2013-01-29 21:59 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kpassey 2008-09-18 14:05:56 UTC
I have a small java app that does a mail merge with an ODBC data base.

I have set up the database and registered it with OO. I have also removed the
Bibliography database so my new database is the only registered database.

In my app 

XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(
					XNameAccess.class, xRemoteServiceManager
							.createInstanceWithContext(
									"com.sun.star.sdb.DatabaseContext",
									xRemoteContext));
			
			String[] elements = xNameAccess.getElementNames();
			
			for (int i = 0; i < elements.length; i++) {
				System.out.println(" Elements " + elements[i]);
			}

The above code returns "Elements Bibliography" if I start OpenOffice from within
the java app - even though is is not a "registered" database.

If I start it by keying soffice from a command line it returns the registered
database AS400.odb
Comment 1 kpassey 2008-09-18 14:07:46 UTC
The error thrown is:-

Error setting MailMerge
properties:com.sun.star.container.NoSuchElementException: AS400
Comment 2 Frank Schönheit 2008-09-18 14:39:00 UTC
That sounds *very much* as if your Java program connects to the wrong OOo
instance (for instance, it might implicitly start an own instance, if it for
whatever reason cannot connect to a running instance).

Do you by chance mix up some paths to the unoil.jar etc files? Perhaps you start
OOo from one installation, but your Java program is set up to use unoil.jar etc.
from another installation?
Comment 3 kpassey 2008-09-18 15:09:29 UTC
Well it's only a problem with the database access - if I just want to display a
document it works fine - starts office and connects to it - if I look at the
running processes I only have one soffice.exe and soffice.bin and a netstat
shows that listening on port 8100.

Here is my .bat file that I call.

@echo off
rem Init start parameters
set OOO_APP="C:\Program Files\OpenOffice.org 2.4\program\soffice.exe"
set OOO_PARAM=-quickstart -minimised 
set OOO_SOCKET="-accept=socket,host=localhost,port=8100;urp"
rem Start OpenOffice.org
echo start "OpenOffice.org" %OOO_APP% %OOO_PARAM% %OOO_SOCKET% >oo.log
start "OpenOffice.org" %OOO_APP% %OOO_PARAM% %OOO_SOCKET%

quickstart or headless does the same..I use quick start as the app prints many
single letters on the trot..

Here is what is in the java for connecting.

xRemoteServiceManager = this				
.getRemoteServiceManager("uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager");

And here is my "start oepenOffice code"
String cmd2 = "C:\\PJDocs\\StartOffice.bat";

		String cmdOut = cmd2;
		System.out.println(" Trying " + cmdOut);

		Runtime.getRuntime().exec(cmd2);

		Thread.sleep(10000); // Waits 10 seconds, because
		// Runtime.getRuntime().exec("...") does not
		// wait until OOo is really running in Listening
		// Mode

Comment 4 kpassey 2008-09-18 15:22:07 UTC
This is definitely correct

"Do you by chance mix up some paths to the unoil.jar etc files? Perhaps you start
OOo from one installation, but your Java program is set up to use unoil.jar etc.
from another installation?"

The answer is yes - is that what you mean by "instance"
Comment 5 kpassey 2008-09-18 16:57:32 UTC
The class path is now set to the OOinstall/programs/classes and all the jars in
there are now added to the classpath.

Results are still the same..NoSuchElementException..

Additional info - the application before the merge - opens a document "hidden"
changes the printer to print to and then saves the document - all fine.
Comment 6 Frank Schönheit 2008-09-18 20:54:29 UTC
> This is definitely correct
>
> "Do you by chance mix up some paths to the unoil.jar etc files? Perhaps you
> start OOo from one installation, but your Java program is set up to use
> unoil.jar etc. from another installation?"
>
> The answer is yes - is that what you mean by "instance"

Okay, just to be sure ...
- You have two OpenOffice.org installations
- you start the first OpenOffice.org (in "C:\Program Files\OpenOffice.org 2.4")
  with the accept=... parameter
- you start a Java program, which is set up to use the unoil.jar from
  the second OpenOffice.org installation (what version is this?)
- This Java program connects to the running OOo instance by using the same
  connection string (I do not know where getRemoteServiceManager comes from,
  but be it for now ...)
- in the Java program, the DatabaseContext lists you the wrong registered
  data sources

Correct so far?

Why I am asking that detailed: Connecting via Java to a running OOo instance and
working with (not only) registered data sources is the daily food of quite a
number of our test cases - if this would fail in the way you described, then
this would have been noticed much earlier.

So, there must be a difference between your setup and the setup we use for our
respective test cases - and I'm trying to find out which one.

One difference I see is that you use two OOo versions, so I'd like to stress
this a little ...

If you
- start the second OOo version
- via Tools/Options, register a few other data sources
- close this OOo version
- start the first OOo version
- run your Java program which prints the names of the elements of the
  DatabaseContext
, what is printed then? Does your program emit the names of all the newly
registered data sources then?
Comment 7 kpassey 2008-09-18 22:24:19 UTC
No I don't - sorry for the confusion...

I have - OpenOffice 2.4 installed once and had copied the jars to a folder
called openofficejars.  In my exe's I had the classpath of openofficejars
instead of openOffice 2.4/program/classes - I have now changed that so I use the
jars from the open office installation not copies. So there is only one copy of
jars used and one copy of open office on the PC

When I call soffice from say a command line to start office listening mailmerge
works fine also if I configure the quick starter by changing the setup file - it
works fine. The problem I have is when I call my start office .bat file from
within my java app, mailmerge fails - everything else within office works.

All that changes is where my start office .bat file is called. All I am trying
to acheive is to re-start office from within my java app after refreshing
documents and the odb file which is maintained seperately. Does that make sense..
Comment 8 Frank Schönheit 2008-09-18 22:34:52 UTC
Ah! Now I got you (/me thinks :) ... which doesn't give me any idea why this
should fail, sadly.

(As a slightly related note, there's a "simple bootstrap mechanism", which works
when the jars are located in their usual place inside the OOo installation,
which automatically starts the OOo the jars belong to. Maybe this is a
workaround for your problem, as you would not need the batch file anymore.)
Comment 9 kpassey 2008-09-19 11:51:17 UTC
OK - I've put the bootstrap code into one of my programs - normal merge/print
program.

If I kill open office then try and get my app to start it via bootstrap - it
works better than the .bat approach - however results are the same.
Interestingly then if I open a writer new document and look at options, my
registered database has been replaced with Bibliography - which is what we expected.

If I kill openoffice and re-start the AS400 database shows..and of course
everything works OK. It is like a different version is being started within java.

I now only have one set of jars on my PC so unoil.jar is the base one delivered
with OO2.4 - I've scanned the whole PC..

I did see a post saying that Boorstrap will not open OO listening on port 8100
as configured in the setup.xcu - is that correct - as this won't work for me?

Also why am I getting copies of all my past updates to this issue - 50+ now
every time I post. 

Thank for your patience - I have posted a previous isue which was a bug(fixed in
3.0 hopefully)
Comment 10 kpassey 2008-09-19 15:43:14 UTC
I have a handle on it now..

1.Clean install of OO 2.4 on windows XP and 2000
2.Register my ODBC database - no problems..
3.Configure the quickstarter
4.Modify Setup.xcu so start automatically listening on port 8100
5.Run my app - everything works fine...
6.Middle of the day - kill OpenOffice to refresh documents and odb file.
7.Connection manager within my app - sees OpenOffice is not Listening on port 8100
8.Try and start OpenOffice by calling within java StartOffice.bat - details above.
9.Only the Bibliography database is availabe - app fails.
10.Now if I go Tools>Options>Databases - I can see the Bibliography database.
11.If I change this by removing Bibliography and re-register my database here it
works and continues to work.
12.What I need to do is un-install OpenOffice and see if my error re-occurs - it
probably will.

So in essence it looks like there is two places where databases are registered -
there should only be one.

Any questions and thanks for your help.
Comment 11 Frank Schönheit 2008-09-19 21:57:48 UTC
if you literally *killed* your OOo, then perhaps the configuration data for the
registered data source was just not written to disc, yet, so it was lost when
you killed OOo?
Comment 12 kpassey 2008-09-19 22:39:56 UTC
No - once I've registered the database in both places it works continually
without problems. If I reboot the pc OpenOffice starts and it works correctly -
nothing is lost. If I kill open offfice and get my app to start it - it works
now. I just have to register the datbase twice - I am removing the Bibliography
database in the first instance - if I reboot the pc it is not there - why would
it appear again if I've removed it correctly and re-booted the PC and it remains
deleted in the first instance. 
Comment 13 kpassey 2008-09-21 19:52:36 UTC
Well - I've written something to stop OpenOffice correctly and the issue still
remains.

If I call the startOffice script within my application I get one set of
registered databases - the only way to access/see these is to start office using
the quickstarter - here is where my application "sees" the correct registered
databases - which I register there.

If I end this instance and re-sart OpenOffice from the Programs menu the
registered databases are different - this is where the default is Bibliography.

The class paths on all my exe's point to OpenOffice install /programs/classes

Any further ideas?

Tks
Comment 14 Frank Schönheit 2008-10-20 10:19:50 UTC
no, sorry, no further ideas. Have to hope for other people's flash of
inspiration ...
Comment 15 kpassey 2008-10-20 14:35:41 UTC
well it's easy to test.

Create a small batch file to start oo in listening mode use quickstart as the 
start option so that you can access the started instance.

Schedule a job on the pc to start this - don't call it manually. On a fresh 
install you will of course see the bibliography database..

If you have a current install you will see it's different. Well mine is..

If you only have bibliography - register a database..