| View previous topic :: View next topic |
| Author |
Message |
eckobar General User


Joined: 20 Jul 2006 Posts: 35
|
Posted: Thu Jul 20, 2006 10:14 pm Post subject: OO + Loader + Log4j |
|
|
hi everybody!
i have the following problem.....
I use the oo sdk to generate a file on the fly with my own java program. everything works fine for me and oo does what i want. to load my code i first execute the Loader.java (described in the OO Developer Guide) and give this Loader my own Main.java as Argument.
Everything was fine. But now I want to use Log4J to log my actions. When i execute my Main.java standalone (only for testpurpose) logging is working fine. But when i really want to use Connection to OO and Load my Main.java via the Loader.java i get an ClassCastException for the Appenders.
I use current OO SDK & current Log4J (both downloaded yesterday) and JAVA SDK 1.4.2_11.
What can the reason for this behavior? maybe i thougth, that OO API also have i FileAppender, etc. ... but my Configuration uses full qualified Classes, so that can not be the reason. I also debugged the Configuration Procedure from Log4J but can not find any reason for the classcastexception.
PS: I use the DOMConfigurator to init my Log4J
Can anybody help me?. |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3531 Location: Hamburg, Germany
|
Posted: Fri Jul 21, 2006 10:50 am Post subject: Re: OO + Loader + Log4j |
|
|
| eckobar wrote: | I use the oo sdk to generate a file on the fly with my own java program. everything works fine for me and oo does what i want. to load my code i first execute the Loader.java (described in the OO Developer Guide) and give this Loader my own Main.java as Argument.
Everything was fine. But now I want to use Log4J to log my actions. When i execute my Main.java standalone (only for testpurpose) logging is working fine. But when i really want to use Connection to OO and Load my Main.java via the Loader.java i get an ClassCastException for the Appenders.
I use current OO SDK & current Log4J (both downloaded yesterday) and JAVA SDK 1.4.2_11.
What can the reason for this behavior? |
I'm using Java, Log4J and the Java-UNO-API myself. Never had a problem with that.
For what reason do you use Loader.java, which i'm not using?
With kind regards
hol.sten |
|
| Back to top |
|
 |
eckobar General User


Joined: 20 Jul 2006 Posts: 35
|
Posted: Fri Jul 21, 2006 11:02 am Post subject: loader.java |
|
|
i use loader.java for the reason that i can connect to oo. because when i use not loader.java i get "no soffice executeable found".
i readed in any faq, that loader.java is not needed for windows. but on my system it seems to be needed. nevertheless for linux the loader.java is needed 100%.
do you have a better solution? any code snippet?? tutorial?? would be thankful because i am not very happy with this way to handle. |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3531 Location: Hamburg, Germany
|
Posted: Fri Jul 21, 2006 11:21 am Post subject: Re: loader.java |
|
|
| eckobar wrote: | | i readed in any faq, that loader.java is not needed for windows. but on my system it seems to be needed. nevertheless for linux the loader.java is needed 100%. |
I never heard or read this. I'm using OOo and the Java-UNO-API on Windows, Linux and Solaris and I never used something called "Loader.java". Do you have a link so that I can give it a quick check? Just out of curiosity.
| eckobar wrote: | | do you have a better solution? |
Better? I can describe what I do to connect to OOo. I started using OOo with OOo 1.1.x. And there you have to make the office listen (which was described in detail in the First Steps chapter of the OOo 1.1.x Developer's Guide). After that I'm using something like this to get the connection: | Code: | XComponentContext xLocalContext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
Object urlResolver = xLocalServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",xLocalContext);
XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(XUnoUrlResolver.class,urlResolver);
Object initialObject = xUnoUrlResolver.resolve(getUnoURL());
XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,initialObject);
Object remoteContext = xPropertySet.getPropertyValue("DefaultContext");
|
This is not my code. I got it from the OOo 1.1.x Developer's Guide.
If this code fails to get a connection, I'm starting OOo through a script which I call from Java with "Runtime.exec(callMyScript)".
I never tried to get a connection through "Bootstrap.bootstrap()" which is now described in the OOo 2.0.x Developer's Guide.
I have no idea why the old mechanism is no longer described because it works without a problem with OOo 2.0.x.
With kind regards
hol.sten
Last edited by hol.sten on Mon Jul 02, 2007 8:18 am; edited 1 time in total |
|
| Back to top |
|
 |
eckobar General User


Joined: 20 Jul 2006 Posts: 35
|
Posted: Fri Jul 21, 2006 11:55 am Post subject: |
|
|
| will check out. will put my (positiv) result in the thread. *gg*. |
|
| Back to top |
|
 |
eckobar General User


Joined: 20 Jul 2006 Posts: 35
|
Posted: Thu Jul 27, 2006 1:26 am Post subject: fine |
|
|
thanks. checked out the old developer code and you code snippet, was very helpful.
now i can use log4j without any restriction and everything is fine.
now it is also possible to connect in a nutshell to another computer with the help of remotecontext. preconditioned the remote openoffice is in listener mode which is started with "soffice -accept=socket,host=,port=8100;urp;" in the console |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3531 Location: Hamburg, Germany
|
Posted: Thu Jul 27, 2006 10:32 am Post subject: Re: fine |
|
|
| eckobar wrote: | now i can use log4j without any restriction and everything is fine.
now it is also possible to connect in a nutshell to another computer with the help of remotecontext. |
Thanks to let me know that it is working now. I guess I will not switch to the newer connection type for quite some time.
With kind regards
hol.sten |
|
| Back to top |
|
 |
|