Script doesn't run correctly on Suse startup (systemd)

I’m using Suse 12 SP1 and I’m trying to startup a WebSphere Application Server on SO startup using systemd script. If I run it manually, it works perfectly, but when running using systemd, it doesn’t.

Here are the script I’m using to run it on SO startup.

ibmbpm.service

[CODE]
[Unit]
Description=IBM Business Process Management

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/opt/ibm/startBPM.sh

[Install]
WantedBy=multi-user.target[/CODE]

startBPM.sh

[CODE]#!/bin/bash

/opt/ibm/BPM/v8.5/profiles/Node1Profile/bin/startNode.sh
/opt/ibm/BPM/v8.5/profiles/Node1Profile/bin/startServer.sh SingleClusterMember1[/CODE]

I’ve checked the status of the service with systemctl status command, here is the output

systemctl status ibmbpm.service -l

[CODE]
ibmbpm.service - IBM Business Process Management
Loaded: loaded (/etc/systemd/system/ibmbpm.service; enabled)
Active: active (exited) since Thu 2016-11-17 09:06:37 BRST; 33min ago
Process: 2887 ExecStart=/opt/ibm/startBPM.sh (code=exited, status=0/SUCCESS)
Main PID: 2887 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/ibmbpm.service

Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:282)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.ecore.EFactory
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.net.URLClassLoader.findClass(URLClassLoader.java:600)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:243)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:777)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.lang.ClassLoader.loadClass(ClassLoader.java:754)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:134)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.lang.ClassLoader.loadClass(ClassLoader.java:731)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.lang.ClassLoader.defineClassImpl(Native Method)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: … 31 more[/CODE]

As the log above shows, something wrong is happening when it tries to start the server, but I really don’t understand what’s happening because running manually as root (/opt/ibm/startBPM.sh) everything works fine.

I really appreciate any help.

Am 17.11.2016 um 13:54 schrieb ranierimazili:[color=blue]

I’m using Suse 12 SP1 and I’m trying to startup a WebSphere Application
Server on SO startup using systemd script. If I run it manually, it
works perfectly, but when running using systemd, it doesn’t.

Here are the script I’m using to run it on SO startup.

IBMBPM.SERVICE

Code:

[Unit]
Description=IBM Business Process Management

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/opt/ibm/startBPM.sh

[Install]
WantedBy=multi-user.target

STARTBPM.SH

Code:

#!/bin/bash

/opt/ibm/BPM/v8.5/profiles/Node1Profile/bin/startNode.sh
/opt/ibm/BPM/v8.5/profiles/Node1Profile/bin/startServer.sh SingleClusterMember1

I’ve checked the status of the service with systemctl status command,
here is the output

SYSTEMCTL STATUS IBMBPM.SERVICE -L

Code:

ibmbpm.service - IBM Business Process Management
Loaded: loaded (/etc/systemd/system/ibmbpm.service; enabled)
Active: active (exited) since Thu 2016-11-17 09:06:37 BRST; 33min ago
Process: 2887 ExecStart=/opt/ibm/startBPM.sh (code=exited, status=0/SUCCESS)
Main PID: 2887 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/ibmbpm.service

Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:282)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.ecore.EFactory
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.net.URLClassLoader.findClass(URLClassLoader.java:600)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:243)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:777)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.lang.ClassLoader.loadClass(ClassLoader.java:754)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:134)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.lang.ClassLoader.loadClass(ClassLoader.java:731)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: at java.lang.ClassLoader.defineClassImpl(Native Method)
Nov 17 09:06:37 bpm857 startBPM.sh[2887]: … 31 more

As the log above shows, something wrong is happening when it tries to
start the server, but I really don’t understand what’s happening because
running manually as root (/opt/ibm/startBPM.sh) everything works fine.

I really appreciate any help.

[/color]

Well, it’s a class not found error, so it’s save to assume some
environment variable/(java)path isn’t set the way your app needs it
unless a “real” user is logged in. But which one, that’s a good question.

CU,

Massimo Rosen
Micro Focus Knowledge Partner
No emails please!
http://www.cfc-it.de

On 11/17/2016 06:05 AM, Massimo Rosen wrote:[color=blue]

Am 17.11.2016 um 13:54 schrieb ranierimazili:[color=green]

I’m using Suse 12 SP1 and I’m trying to startup a WebSphere Application
Server on SO startup using systemd script. If I run it manually, it
works perfectly, but when running using systemd, it doesn’t.[/color][/color]

Just to be sure, when you say “If I run it manually” do you mean the
script, or the systemd service via its unit file? The data below (in
ibmbpm.service) is not a script, but is a service unit file, so when you
run something and it works I assume you mean you run the script itself
(sartBPM.sh) and that works, where anything via systemd does not.

If that is all correct, then it would be interesting to know if you could
start WebSphere properly using systemd but started manually:

systemd start ibmbpm

[color=blue][color=green]

Here are the script I’m using to run it on SO startup.

IBMBPM.SERVICE

Code:

[Unit]
Description=IBM Business Process Management

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/opt/ibm/startBPM.sh

[Install]
WantedBy=multi-user.target
--------------------[/color][/color]

Is it safe to assume that IBM has not yet shipped a service unit file for
WebSphere already? Creating your own, while fine, seems like something
you should not need to do, just to avoid problems with the configuration
which the vendor would have worked out. With that written, I am
definitely not a WAS expert, so if this is all silly just ignore me.
[color=blue][color=green]

STARTBPM.SH

Code:

#!/bin/bash

/opt/ibm/BPM/v8.5/profiles/Node1Profile/bin/startNode.sh
/opt/ibm/BPM/v8.5/profiles/Node1Profile/bin/startServer.sh
SingleClusterMember1
--------------------[/color][/color]

Adding debugging lines to this script, or to the scripts called here as
shown above, may give you some clue as to what is different
environment-wise when calling the script manually vs. via systemd (or
systemd at bootup). For example, if a classpath variable is set for users
when you call the script, that could impact things, as could things like
LD_LIBRARY_PATH or LD_PRELOAD, or a whole host of other things. Iss it
correct for this script to run as ‘root’ most of the time?


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

Hi,

that’s where I would look. Is there anything mentioned in the docs which user is supposed to run that application? I had a similar issue recently, a java based application only wanted to run as root, so I had to set the environment variable “RUN_AS_USER=root” to get it started (luckily, that hint was part of the cli output ;)). So I guess you should first check if there are any permissions to set (take a look into syslog) for a specific user, or you could set an environment variable in your startBPM.sh (I don’t know which it could be, but you could try the same I had to use).

Hi Guys,
thanks for your attention and help.
I’ve found the solutions to make it work.

First of all, when I say “manually”, I mean run the script (startBPM.sh), not the service.
Run the service using systemctl start ibmbpm wasn’t working.

The script was being executed… I’ve added some log lines and they tracked the execution… the problem was with the command startNode.sh…
Not sure why, but instead of use

/opt/ibm/BPM/v8.5/profiles/Node1Profile/bin/startNode.sh

I had to use

su - root -c "cd /opt/ibm/BPM/v8.5/profiles/Node1Profile/bin/ && ./startNode.sh"

Now it works great… I’ll perform more tests to try without su, because I’m setting to run it as root inside ibmbpm.service file, but if it doesn’t work, I already know a solution.

Thanks