Config for Tika Windows Service with Apache Commons Daemon - jetty

I'm trying to get Tika JAXRS running as a Windows Service using Apache Commons Daemon.
I've got tika-server-1.7.jar from http://tika.apache.org/download.html
I've downloaded v1.0.15 of the Windows binaries for Apache Commons Daemon from http://commons.apache.org/proper/commons-daemon/binaries.html
I can get Tika started as a service, but I can't determine what to use for a stop method.
prunsrv.exe //IS//tika-daemon
--DisplayName "Tika Daemon"
--Classpath "C:\Tika Service\tika-server-1.7.jar"
--StartClass "org.apache.tika.server.TikaServerCli"
--StopClass "org.apache.tika.server.TikaServerCli"
--StartMethod main
--StopMethod main
--Description "Tika Daemon Windows Service"
--StartMode java
--StopMode java
This starts, and works as I'd hope, but when trying to stop the service it doesn't respond. Obviously org.apache.tika.server.TikaServerCli.main(string[] args) isn't a suitable stop method, but I'm lost for alternatives.
I'd also welcome any alternative methods for getting Tika running as a Windows Service, or otherwise auto-starting outside of an interactive session.

It would appear this is a known issue of Apache Commons Daemon 1.0.15. https://issues.apache.org/jira/browse/DAEMON-298
I swapped in version 1.0.14, downloaded from Apache archives http://archive.apache.org/dist/commons/daemon/binaries/windows/ and the service now does shut down.
The original java StartMode produces an error on shutdown but does shutdown. The exe StartMode though, works without issue.

I ran into this about a year ago and found a solution. Running Apache Commons Daemon in JVM mode will allow you to specify the StartClass and the StartMethod, which works fine because you can just point it to
static void Main(...){}
However, stop doesn't work because there's no stop method to call.
So, I built from source, and added a stop method. I've created a PR in the tika project for this. Babble's downvoted solution is basically the same thing, but I'd really like to see it available in the base jar file.
https://github.com/apache/tika/pull/324
https://www.michaelwda.com/post/tika_windows_service a few additional details and screenshots here.
C:\source\tika\commons-daemon-1.2.2-bin-windows\amd64\prunsrv.exe //IS//tika-daemon ^
--DisplayName "Tika Daemon" ^
--Description "Tika Daemon Windows Service" ^
--Classpath C:\source\tika\tika-server.jar ^
--StartClass "org.apache.tika.server.TikaServerCli" ^
--StopClass "org.apache.tika.server.TikaServerCli" ^
--StartMethod main ^
--StopMethod stop ^
--StartMode jvm ^
--StopMode jvm ^
--StdOutput auto ^
--StdError auto ^
--Jvm "C:\Program Files\Java\jdk1.8.0_211\jre\bin\server\jvm.dll" ^
++StartParams -spawnChild

I've created a MSI which does this all for you: https://github.com/wbicode/TikaService-Installer (or you can install the setup yourself: https://github.com/wbicode/TikaService)
You'll have to create a separate class which implements its own start/stop-class (tika-server-X.X.jar is in it's classpath).
public class WinService {
public static void start(String[] args) {
Class<?> clazz = Class.forName("org.apache.tika.server.TikaServerCli");
Method method = clazz.getMethod("main", String[].class);
method.setAccessible(true);
method.invoke(null, (Object)args.toArray(new String[0]));
}
public static void stop(String[] args) {
System.out.println("stopping... TikaService");
Runtime.getRuntime().exit(0);
}
}
And it's installed with this script (the tika-server-X.X.jar lies inside the lib folder):
prunsrv.exe //IS//tika-daemon ^
--DisplayName "Tika Daemon" ^
--Classpath "%SERVICE_PATH%\TikaService.jar;%SERVICE_PATH%\lib\*" ^
--StartMode java ^
--StartClass "your.namespace.WinService" ^
--StartMethod start ^
--StopMode java ^
--StopClass "your.namespace.WinService" ^
--StopMethod stop ^
--Description "Tika Daemon Windows Service" ^

Related

Running Robot Framework tests with VirtualBox and IE11

I'm a Linux user, but I have a need to run my Robot Framework tests with IE11. I have set up Virtual Box with Win7 + IE11. I set up system and run below test there:
*** Settings ***
Library Selenium2Library
*** Test Cases ***
Run a browser
Open Browser http://www.google.com ie None http://192.168.56.101:4444/wd/hub
Now in virtual machine IE is opened and www.google.com page is opened. So this simple test is working fine.
I'm just wondering, what would be best way for me to run actual tests in virtual machine. I have a lot of tests. Can I somehow give address http://192.168.56.101:4444/wd/hub to command line somehow with start command?
Or do I have to make special keyword to check, how to start testing.
Any suggestions? How have you solve this issue?
When you are using robot framework, you can declare this information in the command line using the appropriate arguments. An example of this could be formatted like:
robot --include smoke --variable HOST:[host_IP] path/to/tests/
This information can be found in more detail here:
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#id142

Wamp: The configuration file contains a syntax error on line 24

How can I start the wamp server on windows 7 using wamp version 2.4?
Following is the error message I get:
The configuration file contains a syntax error on line 24:
[EParseError][config] section directive "ImageList" already specified.
Error:
The configuration file contains a syntax error on line 7;
[EParseError] No tray icon was specified. Please assign a tray icon by
using on the of the Tray icon directives in the [Config] section.
Caused by:
Computer abruptly shutting down while server is running
Fix:
• Go to the wamp/scripts folder
• Open console/cmd as admin
• run: php refresh.php
• Done!
Make sure you have php in your system environment settings
then go to the wamp/scripts folder
open console
run:
php refresh.php
answer from here solved my issue, referenced above info from this stack answer
ISSUE
You have a duplicate entry on C:\wamp\wampmanager.ini
ImageList=images_off.bmp or something like that.
FIX
Remove one of them (probably line 24)
It sounds like you have been playing with \wamp\wampmanager.tpl
Never play with wampmanager.tpl unless you have taken a copy first!
WAMPServer rebuilds \wamp\wampmanager.ini using a script that uses \wamp\wampmanager.tpl among other files as input, each time you start WAMPServer or when you use the wampmanager menus and click refresh.
So to fix your problem edit of wampmanager.tpl to remove the duplicated line and then do:
rightclick wampmanager icon -> refresh
Or just exit wampmanager and restart it.
to rebuild the \wamp\wampmanager.ini file
Take a backup of your Wampmanager.ini file in your wamp installation directory (in my case it is c:\Wamp64). Then rename it or move it to some other folder.
Get the wampmanager.ini from a new installation or any similar installation if you already have, then paste it in the same path. It will work like charm. This may change any of the settings you had earlier but it will make your wamp working without reinstalling it.
Wamp Manager folder
Wamp Manager configuration file in CMD prompt
It is interesting that this error shows up after initial install of the current version 3.2.6 found on aviatechno (without being able to tamper with any installed configuration file, the .ini in the installation is broken). It reports an error with line 27: WAMPMARIADBOFF.
[Services]
Name: APACHESERVICE
WAMPMARIADBOFFName: MARIADBSERVICE
WAMPMYSQLOFFName: MYSQLSERVICE
Use the new ini repair tool you can find on the aviatechno website
which corrects the lines in the ini file as:
[Services]
Name: wampapache
Name: wampmysqld
Name: wampmariadb
...
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmariadb; ServiceAction: startresume; Flags: ignoreerrors
Only do this on new installs
Even after that wampserver does not start or does not start the services. To repair: stop the background process AeTrayMenu, head over to the folder c:\wamp64 removing its content and reinstall.
This did the trick for me.

qtdbus under windows 7

CONFIGURATION
I have this configuration:
QT Community 5.4.1
dbus-daemon.exe downloaded from http://sourceforge.net/projects/windbus/
link
I have copied in my local directory these qt example:
c:\Qt\Qt5.4.1\Examples\Qt-5.4\dbus\remotecontrolledcar\car
c:\Qt\Qt5.4.1\Examples\Qt-5.4\dbus\remotecontrolledcar\controller
I use Windows 7 and NOT Linux!!!!!!
Procedure:
I compiled both examples in debug mode in my local directory
I launched dbus-daemon.exe with these parameters:
DBUS_SESSION_BUS_ADDRESS sets to tcp; host sets to localhost,port sets to 12434.
set DBUS_SYSTEM_BUS_DEFAULT_ADDRESS=tcp:host=localhost,port=12434
dbus-daemon.exe --session --system --config-file=.\etc\session.conf
I execute car.exe
I execute controller.exe
PROBLEM
The dbus connection fails in particular the method sessionBus form DBusConnection class fails. Infact when i call the isConnected method, it returns false.
Someone can explain why? Is it wrong the way I call the daemon executable?
Or Qt Comunity 5.4.1 have problem with qtdbus? can someone pass me a correct configuration file (session.conf)?
Thank you very much for for the support.
Fausto

wmq-fte precall java failed

I am implementing a FTE network using Websphere MQ 7.5.
I have developped a java program to be ran as a precall transfert.
here is my procedure :
I have updated the agent.properties file with path to java.exe
restart my agent
create a new transfert
In the call panel, I configure a precall :
program : java
argument : -jar c:\PATH\TO\MY\JAR\myJar.jar myArgument
the transfert fails and the error shown is like java does not receive any argument.
When I test my command in a windows prompt it works.
In addition, my first attempt was to run a batch script containing the java command but it did not work either.
I do not want to use an exit as the program is specific to a transfer.
Edit : I have test a simple java -version command and it works.
<preSourceCall>
<command name="java" retryCount="0" retryWait="0" successRC="0" type="executable">
<argument>-jar C:\mqfteTest\ExitsJava.jar C:\mqfteTest\userExitTest\FileRef_20121023.txt</argument>
</command>
</preSourceCall>
Error returned :
<callResult outcome="failure" retries="0">
<result outcome="failure" returnCode="1" time="2012-10-24T12:39:52.419Z">
<stdout>
<line/>
<line>Syntaxe : java [-options] class [args...]</line>
<line> (pour l'ex‚cution d'une classe)</line>
<line> ou java [-jar] [-options] jarfile [args...]</line>
...
<line>JVMJ9VM007E Option de ligne de commande non identifiee : -jar C:\mqfteTest\ExitsJava.jar C:\mqfteTest\userExitTest\FileRef_20121023.txt</line>
<line>Could not create the Java virtual machine.</line>
</stderr>
Best Regards
I am not quite sure if I have understood the question. Assuming your aim is to invoke Java class before the transfer begins, you can use MFT exits to achieve that. Here is a link to WMQ MFT v7.5 sample source end user exit.
HTH
I finally managed to execute my precall:
for the windows platform, I used a batch script and i put the script and the jar in a folder without space in the path.
I did not manage to use the java command and will open a PMR to understand why.
edit :
Finally I have understood why!!
In fact the so called "argumentS" (in the precall conf) are in fact just one argument.
I have also manage to deploy my precall on iseries as400.
the command line is the same but the declaration of shell MUST be
#!/QOpenSys/usr/bin/sh
with #!/bin/sh wmq-fte does not manage to catch the exit of the program
Everything works great now.
I also found a strange behaviour (which will aim to another PMR) :
when the files to send are in a subdirectory of the command path, the transfert fail.
Hope this will help some one.
Regards

How to config apache for C++ CGI scripts?

I've found a lot of stuff for Perl, but nothing for C++. I'm running Ubuntu right now but I'm fairly inexperienced with it, so simple instructions would be awesome. I've just written a small C++ program made to work as a CGI, and I need to test it out. Thanks!
You shouldn't need to do anything special; just compile it to an executable file named *.cgi (or whatnot), and make sure you have
AddHandler cgi-script .cgi
(or whatnot) in your server config or .htaccess or whatnot.
(Disclaimer: It's been many years since I've done that, so I may be forgetting something. But I think that should be all you need.)
There is nothing special for C++ programs. CGI programs are executed by the Web Server. So the prerequisites are the same as for the Perl Scripts/programs, too.
Here are some hints getting a C++ CGI program up and running.
Put a simple executable in the cgi-bin directory and make it executable by the web server. Prepare a simple program returning a valid CGI response, e.g.
#include <iostream>
using namespace std;
int main()
{
cout << "Content-Type: text/html" << endl << endl;
cout << "Hello to Apache and Firefox!" << endl;
return 0;
}
Execute the program on the command line and check that the output starts with the following lines. Ensure the empty line after the Content-Type.
$ ./hello_world
Content-Type: text/html
Hello to Apache and Firefox!
Increase the LogLevel to debug and look into the web server error logs. Search the access log, the error log and the suexec.log. Look in the log from the virtual host you are using and in the main error.log, too. On my Ubuntu system the files are located in /var/log/apache2 and named access.log, error.log and suexec.log. One of my last problems was "directory is writable by others: ..."
When using DLLs ensure that the libraries are still available on the web server. Set the RPATH to point to a custom directory with the libraries. In this context ldd and objdump -x <executable> | grep RPATH are your friends.
(This tip from Apache documentation has not worked for me: Watch the input and output using the ScriptLog Directive from the mod_cgi module of Apache. ScriptLog should only be used on an Development Server. Further details are available from the mod_cgi page.)
More hints are shown in the article Debugging Apache Web Server Problems.