| View previous topic :: View next topic |
| Author |
Message |
Sixel Newbie

Joined: 31 Jul 2006 Posts: 3
|
Posted: Tue Aug 01, 2006 12:36 am Post subject: UnsatisfiedLinkError under Tomcat |
|
|
Hi all,
First of all, I'd like to mention I searched the forums for similar problems, but the only one close enough was not of much help [1]
Here's the background :
My web application reads .ott files, fills the fields up, and converts the resulting file to PDF.
All runs perfectly well under development environment (Eclipse 3.1, MyEclipse 4.1.1, Tomcat 5.5.17, OOo 2.0.3). Well, only if I "cheat" by setting
| Code: | | -Djava.library.path="C:\Archivos de programa\OpenOffice.org 2.0\program" |
as a java option to the Tomcat launching sequence, from the MyEclipse Application Server preferences.
Problem :
When deploying this webapp to the production environment, with the same tomcat launch option, always leads to this exception :
| Code: | java.lang.UnsatisfiedLinkError: createJNI
com.sun.star.lib.connections.pipe.PipeConnection.createJNI(Native Method)
com.sun.star.lib.connections.pipe.PipeConnection.<init>(PipeConnection.java:137)
com.sun.star.lib.connections.pipe.pipeConnector.connect(pipeConnector.java:145)
com.sun.star.comp.connections.Connector.connect(Connector.java:146)
com.sun.star.comp.urlresolver.UrlResolver$_UrlResolver.resolve(UrlResolver.java:133)
org.mypackage.CustomBootstrap.customBootstrap(CustomBootstrap.java:107)
org.mypackage.MyStrutsAction.execute(SolicitudesGeneralesAction.java:107)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) |
The CustomBootstrap class is an idea found on [2], itself inspired by someone on the forums
I know this sounds more like a Tomcat issue (how to set correctly classpath for Tomcat?) or even a MyEclipse question (I posted on the forums there too : [3]), but I thought someone here might have already managed to deploy a web application using Tomcat...
Anyway, thanks in advance for any help!
Cheers,
alexis
[1] : http://www.oooforum.org/forum/viewtopic.phtml?t=22425
[2] : http://technology.amis.nl/blog/?p=1284
[3] : http://myeclipseide.com/modules.php?op=modload&name=PNphpBB2&file=viewtopic&t=13559 |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3533 Location: Hamburg, Germany
|
Posted: Tue Aug 01, 2006 11:07 am Post subject: Re: UnsatisfiedLinkError under Tomcat |
|
|
| Sixel wrote: | The CustomBootstrap class is an idea found on [2], itself inspired by someone on the forums  |
Perhaps you shouldn't use the Bootstrap mechanism. It seems to cause at least some trouble. In this thread is the older no longer in the OOo Developer's Guide described connection mechanism discussed: http://www.oooforum.org/forum/viewtopic.phtml?t=39950
Some time ago my Java application for creating pdf files by using OOo was itself launched from within Tomcat. And it worked (and still works if needed) from within Eclipse and without Eclipse too. I'm not using that any longer because our pdf service runs now as a stand alone service which is called from various (web) applications through RMI.
I never tried the new Bootstrap mechanism and regarding the above mentioned thread I will not even try for quite some time.
With kind regards
hol.sten |
|
| Back to top |
|
 |
herringbone General User


Joined: 02 Aug 2006 Posts: 8
|
Posted: Wed Aug 02, 2006 2:32 pm Post subject: It's a pain! |
|
|
I have a similar application, sadly we are running under Oracle's application server but have also gotten it working under Jetty. We have a Java app that launches OpenOffice processes and can start multiple windows to generate PDF's concurrently.
You should check that the location exists that your java.library.path points to.
This is because whether you connect to OO.o through a socket or native, there is some JNI magic and JNI needs to find the native libraries. Is the production environment also Windows?
If you're looking for a better way to manage OO.o under a Java webapp, maybe you want to look further. We tried a number of ways to launch OpenOffice, this worked the best. This way you can deploy your webapp and not have to manually launch OO.o ahead of time. There's one issue though - in Windows, when the JVM is killed, the soffice.exe ends but the soffice.bin process won't end. Java can only send SIGTERM, but normally the user clicking close would send SIGQUIT - I don't know a way around this. You end up having to kill this process. Under Solaris, the process is terminated along with it's parent, the JVM.
Once we have the process, we pair it up with the com.sun.start.comp.beans.LocalOfficeConnection from officebean.jar to provide the remote component context.
Here's the method where I launch OO.o. Note that we're logging with log4j.
| Code: | public static java.lang.Process startOpenOffice(final int port,
final File openOfficePath) throws Exception {
LOG.info("Starting open office instance on port: " + port);
int nSizeCmdArray = 6;
String sOption = null;
// examine if user specified command-line options in system properties.
// We may offer later a more sophisticated way of providing options if
// the need arises. Currently this is intended to ease the pain during
// development with pre-release builds of OOo where one wants to start
// OOo with the -norestore options. The value of the property is simple
// passed on to the Runtime.exec call.
try {
sOption = System.getProperty("com.sun.star.officebean.Options");
if (sOption != null)
nSizeCmdArray++;
} catch (java.lang.SecurityException e) {
LOG.error("Problem with starting open office", e);
}
// create call with arguments
String[] cmdArray = new String[nSizeCmdArray];
cmdArray[0] = openOfficePath.getPath();
cmdArray[1] = "-nologo";
cmdArray[2] = "-nodefault";
cmdArray[3] = "-accept=socket,port=" + port + ";urp";
cmdArray[4] = "-invisible";
cmdArray[5] = "-norestore";
if (sOption != null) {
cmdArray[6] = sOption;
} // end if
LOG.info("Starting OOo instance: " + Arrays.asList(cmdArray));
// start process
Process process = Runtime.getRuntime().exec(cmdArray, null,
openOfficePath.getParentFile());
if (process == null) {
throw new RuntimeException("cannot start soffice: " + cmdArray);
} // end if
new OpenOfficeStreamProcessor(process.getInputStream(), Priority.DEBUG);
new OpenOfficeStreamProcessor(process.getErrorStream(), Priority.ERROR);
//check the exit status.. if we have one then thats an error.
try {
int exitValue = process.exitValue(); //should throw execption
throw new IllegalStateException("Unexpected termination of open office: " + exitValue);
}
catch (final Exception e) {
//no exit code so we are still running
LOG.debug("We seem to have a sucessful OOo launch");
} //end try catch
// wait for the port to become available
boolean connected = false;
long endTime = new Date().getTime() + (20 * 1000); // ten second wait
// time
while (!connected && (new Date().getTime() < endTime)) {
try {
Thread.sleep(PORT_POLLING_INTERVAL);
final Socket socket = new Socket(InetAddress.getByName(null),
port); // null is the loopback interface
// if this was successful then just shut down and set the
// connected flag
socket.close();
connected = true;
} catch (final Exception e) {
// I dont like not printing a stack trace.. but in this case its
// pretty ridiculous in the log.
LOG.debug("No connection yet for port (" + port + "): "
+ e.getMessage());
} // end try catch
Thread.sleep(100); // sleep for a bit
} // end while
if (!connected) {
throw new IllegalStateException("Open office not connected");
}
return process;
} // end startOpenOffice() |
the OpenOfficeStreamProcessor redirects stdout and stderr of the process to log4j so you can find out when it fails to start.
| Code: | public class OpenOfficeStreamProcessor implements Runnable {
private final static Logger LOG = Logger
.getLogger(OpenOfficeStreamProcessor.class);
private InputStream inputStream;
private Priority priority;
private Thread thread;
private boolean shutdown = false;
/**
* Constructor, duh.
*
* @param inputStream
* to pipe to log4j
* @param priority
* what priority are the messages going to be?
*/
public OpenOfficeStreamProcessor(final InputStream inputStream,
final Priority priority) {
this.inputStream = inputStream;
this.priority = priority;
this.shutdown = false;
thread = new Thread(this);
thread.start();
} // end OpenOfficeStreamProcessor(InputStream,Priority)
/**
* Does the piping. Note: runs until shutdown is called.
*
* @see java.lang.Runnable#run()
*/
public void run() {
BufferedReader r = new BufferedReader(
new InputStreamReader(inputStream));
//loop until shutdown
while (!shutdown) {
String s = null;
try {
s = r.readLine();
} catch (final IOException e) {
LOG.error(e);
} // end try catch
if (s == null) {
break;
} // end if
//actually do the logging
LOG.log(priority, s);
} // end while
} //end run();
public void shutdown() {
this.shutdown = true;
} // end shutdown()
} // end OpenOfficeStreamProcessor |
|
|
| Back to top |
|
 |
MartinWBrown General User

Joined: 26 Nov 2003 Posts: 27
|
Posted: Thu Aug 03, 2006 9:21 am Post subject: |
|
|
Our app (3BTransform) runs OOo in a managed pool via the command line. We need lots of control - it means that we can monitor OOo closely and restart instances if they cause any problems.
We hit problems killing OOo on both Windows and Linux. On Windows the cure was easy - don't run soffice.exe; just run soffice.bin. I know it is less than ideal - presumably soffice.exe is doing something vital - but under very heavy load it performs very well and we haven't hit any issues so far.
On Linux it appears that the Sun JVM sent SIGTERM rather than SIGKILL. So we've got a wrapper process (in C) that intercepts signals from the JVM and kills OOo as necessary.
My experience is that getting something working is pretty easy. Getting it reliable under heavy load and random documents is much harder... |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3533 Location: Hamburg, Germany
|
Posted: Thu Aug 03, 2006 11:10 am Post subject: |
|
|
| MartinWBrown wrote: | | My experience is that getting something working is pretty easy. Getting it reliable under heavy load and random documents is much harder... |
Full ACK!
With kind regards
hol.sten |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|