Index

Running JReport Enterprise Server as a Standalone server

JReport Enterprise Server can be started from the wrapping servlet-enabled web server that is contained in the JReport Enterprise Server package. We will learn how to start JReport Enterprise Server from this wrapping web server, how to send commands to this wrapping server and how to take advantage of the batch files under the %JREntServerHome%\bin directory.

Launchers

After you have installed JReport Enterprise Server, a set of utilities will be generated automatically under %JREntServerHome%\bin. All of these batch files can be edited to suit different circumstances. However, always do this before making sure of their functions.

Full command to run from Wrapping Web Server

jet.server.JREntServer is the class of the wrapping web server, you can start it with the following command instead of using the generated batch files:

JAVA -classpath <classpath> -Djava.compiler=NONE -Dreporthome=<install_root> jet.server.JREntServer [options]

Notes:

Sending commands to JReport Enterprise Server via the Wrapping Server

After JReport Enterprise Server is started from the wrapping web server, you can send commands to that web server to either shut it down or pop up the user interactive interface for administrating. All of these can be done through the class jet.server.CommandSender. The full command is as follows:

JAVA -classpath <classpath> -Djava.compiler=NONE [-Dreporthome=<install_root>] jet.server.CommandSender [-s:server -p:port] -w:password [-?]|admin|shutdown|gc|(local:on|off)

Note: We will use some of the common options in the later chapters. In addition, we have automatically generated the batch file CmdSender.bat for you so that you will not have to write a complicated command line.

Running Server on Unix without GUI

JReport requires java AWT to layout and render reports at runtime. For example, JReport requires AWT to

Due to the above reason, JReport (actually not only JReport, but also any Java Server products that require AWT) would encounter the X11 relative issue if there were no X Window available. Since V7.2, JReport will check the X environment before starting. If no X server or equivalent X is found, JReport Enterprise Server/Servlets will not be loaded.

Using XVFB

Since Java 1.2's AWT needs support by too many features, for example, certain Java 2D implementations, it is very hard to present our own Java 1.2 AWT Toolkit to Java VM. We were aware that this bug has been fixed by Sun and we think it would be included in next JDK public release. However, before the next public release of JDK, there is a compromise solution - XVFB. XVFB is acronym of Xserver Virtual Frame Buffer. It can provide a virtual Xserver and release you from the need of real Xserver. It runs without a head or graphics card. XVFB is freeware and can be gotten from x.org's X11R6 distribution. Compiling it is supposedly very difficult, but there are some Solaris binaries on certain sites, including:

http://ferret.wrc.noaa.gov/Ferret/FAQ/graphics/Solaris_Xvfb.html
ftp.xfree86.org/pub/XFree86/3.3.6/binaries/Solaris
ftp.xfree86.org/pub/XFree86/4.0.1/binaries/Solaris
ftp.xfree86.org/pub/XFree86/4.0.1/binaries/Solaris-8
http://ferret.wrc.noaa.gov/Ferret/FAQ/graphics/Solaris_Xvfb.html (probably run on Solaris 7)

Take the following steps to run JReport Enterprise Server with Xvfb:

  1. Install Xvfb.
  2. To have Xvfb start up automatically when a workstation boots, you can add the Virtual Framebuffer to the Automatic Startup. That is, write a script /etc/init.d/xvfb as below, and make it executable.

    #!/bin/sh
    
    mode=$1
    
    case "$mode" in
    'start') 
    # start the X Virtual Framebuffer (Xvfb)
    if [ -f /usr/X11R6/bin/Xvfb ]; then
    echo "***Starting up the Virtual Frame Buffer on Screen 1***"
    /usr/X11R6/bin/Xvfb :1 -screen 0 1152x900x8 &
    fi
    ;;
     
    *)
    echo " Usage: "
    echo " $0 start (start XVFB)"
    echo " $0 stop (stop XVFB - not supported)"
    exit 1
    ;;
    esac
    exit 0

    Then create a soft link to /etc/rc2.d/S98xvfb:

    ln -s /etc/init.d/xvfb /etc/rc2.d/S98xvfb

    If you need not to start Xvfb automatically, you can manually start up XVFB:

    /usr/X11R6/bin/Xvfb :1 -screen 0 1152x900x8 &
  3. Set DISPLAY to screen 1 (assuming that JREntServer is running on machine jaguar).

    DISPLAY=jaguar:1.0
    export DISPLAY

    Then, you can start JREntServer. In case of JREntServer shutting down when you close the remote terminal, you can start JREntServer in the background using the command nohup:

    nohup ./JREntServer &

Using PJA toolkit

When there is no X Window, or even Xvfb available, a PJA (Pure Java AWT) Toolkit is supported to run JReport Enterprise Server. This is a Java library for drawing graphics developed by eTeks. It supplies a replacement AWT toolkit and eliminates the requirement of an X display. To use it,

1. Install PJA. The PJA package is not included in our product, please go to http://www.eteks.com/pja/en/ to download PJA and install it.

2. Install JReport Enterprise Server. For details on installing JReport Enterprise Server, see User's Guide | Installing and Launching JReport Enterprise Server | Installing JReport Enterprise Server on Non-GUI Environment.

3. Assuming that EntSvrSetup.sh has been used to install JReport Enterprise Server on a Non-Gui platform. Modify the file JREntServer under %JREntServerHome%\bin and append /pja_2.4/lib/pjatools.jar to the classpath and add following options:

Below is an example of the modified file JREntServer that is used to start up JReport Enterprise Server:

#!/bin/sh

CLASSPATH="${CLASSPATH}":"${REPORTHOME}"/lib/servlet.jar:
"${REPORTHOME}"/lib/ant.jar:"${REPORTHOME}"/lib/jasper-compiler.jar:"${REPORTHOME}"/lib/jasper-runtime.jar:
"${REPORTHOME}"/lib/JREngine.jar:"${REPORTHOME}"/lib/JRESServlets.jar:"${REPORTHOME}"/lib/JREntServer.jar:
"${REPORTHOME}"/lib/dom.jar:"${REPORTHOME}"/lib/sax.jar:"${REPORTHOME}"/lib/mail.jar:
"${REPORTHOME}"/lib/activation.jar:"${REPORTHOME}"/lib/unicode.zip:
"${REPORTHOME}"/lib/JRWebDesign.jar:"${REPORTHOME}"/lib/Itext.jar:"${REPORTHOME}"/lib/poiHSSF_151.jar:
"${REPORTHOME}"/lib/xerces.jar:"${REPORTHOME}"/lib/jakarta-regexp-1.3.jar:"${REPORTHOME}"/lib/hsqldb.jar:
"${REPORTHOME}"/lib/tar.jar:"${REPORTHOME}"/lib/xalan.jar:
"${REPORTHOME}"/lib/jai_core.jar:"${REPORTHOME}"/lib/jai_codec.jar:"${REPORTHOME}"/lib/commons-codec-1.2.jar:
"${REPORTHOME}"/lib/cos.jar:"${REPORTHOME}"/lib/batik.zip:"${REPORTHOME}"/lib/log4j-1.2.8.jar:"
"${JAVAHOME}"/lib/tools.jar":"${ADDCLASSPATH}"

export CLASSPATH exec "${JAVAHOME}"/bin/java -Dawt.toolkit=com.eteks.awt.PJAToolkit
-Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment -Djava2d.font.usePlatformFont=false -Djava.awt.fonts=/usr/j2se/jre/lib/fonts:/JREntServer/font:/usr/openwin/lib/X11/fonts/TrueType -Dinstall.root="${REPORTHOME}"/ -Xmx512m -Dreporthome="${REPORTHOME}" jet.server.JREntServer "$@"

Notes:

  1. When using JDK 1.2.x, the bug of JDK 1.2.x can break down the JVM.
  2. Printing reports is not supported.
  3. To support multiple encoding, the file "i18.jar" under %JDK 1.3.x%\jre\lib should be added to -Xbootclasspath. Without the jar file, only the default encoding (iso8859-1) can be applied to JReport. ("i18.jar" is not included in JDK 1.4. If there is only JDK 1.4 on your computer, you need to get the file "i18.jar" and save it on your computer, and then add this file with a valid path to -Xbootclasspath.)
  4. If you are using other True Type Fonts instead of the fonts under X11, you should add the directory where the Lucida*.ttf files can be found to -Djava.awt.fonts.

Start JReport from Telnet session with an X Server installed

If your are using telnet to start JReport and your Unix has X Server installed, you can directly point to your X server for the display

$ DISPLAY=hostname(or IP):0.0
$ export DISPLAY

Then, you can run JREntServer or your application with JReport embedded.

Running JReport Enterprise Server as an OS Service

JReport Enterprise Server can be configured as an OS service. We will learn how to run JReport Enterprise Server as a service of Windows NT and Unix.

Service on NT

Installing and removing JReport Enterprise Server service

A tool is provided to assist you in installing JReport Enterprise Server as an NT Service. This tool can be found under %JREntServerHome%\bin\JRservice.exe

You will get the following information if you run JRService.exe without any options :

Usage:
JRService -install [-interactive] to install the service
JRService -remove to remove the service
-interactive to enable JReport Enterprise Server service
to interact with the desktop

JRService -install
Running JRService.exe with the-install option will install JReport Enterprise Server as a NT Service. If you open the Services item in the Control Panel, you will find a service named JReport Enterprise Sever in the list.

JRService -install -interactive
If you use -interactive option together with -install, the service installed will be run in the interactive mode. That is, when you start the service, a Command Prompt Window will pop up, and if you choose to start JReport Enterprise Server service with administration/configuration GUI, you will have that interface loaded on screen. However, if you don't specify this option when you install the service, neither the Command Prompt Window nor a graphic interface is displayed on the screen when you start the service. After you have installed JREntServer as a service, you will be prompted to restart your computer for the service installation to take effect.

JRService -remove
Running JRservice.exe with -remove option removes the NT service of JReport Enterprise Server from Windows NT. However, before you run this, you should stop the service.

Configuring JReport Enterprise Server service

The parameters for the NT service of JReport Enterprise Server are read from the file:
%JREntServerHome%\bin\NTService.ini

In this file you will find three parameters specified, as shown in the following example.:

JavaVM="C:\jdk1.2\jre\bin\java.exe" 
StartArg= "-Dinstall.root=C:\JREntServer" -classpath "C:\JREntServer\lib\JREntServer.jar;
C:\JREntServer\lib\JREngine.jar;C:\JREntServer\lib\servlet.jar;C:\TEMP"... 
-Djava.compiler=NONE -Dreporthome=C:\JREntServer jet.server.JREntServer
ShutdownArg= "-Dinstall.root=C:\JREntServer" -classpath "C:\JREntServer\lib\JREntServer.jar;
C:\JREntServer\lib\JREngine.jar;C:\JREntServer\lib\servlet.jar;C:\TEMP" ...
-Djava.compiler=NONE -Dreporthome=C:\JREntServer jet.server.CommandSender localshutdown

Start Service

There are two ways to start JREntServer service.

You can change the options in the file <JREntServerHome>\bin\NTService.ini before you start the service. In the example above, there are no options specified in StartArg. If you would like to start server with the administration dialog, you would need to append -a at the end, as in the following example:

... 
StartArg= "-Dinstall.root=C:\JREntServer" -classpath "C:\JREntServer\lib\JREntServer.jar;
C:\JREntServer\lib\JREngine.jar;C:\JREntServer\lib\servlet.jar;C:\JREntServer\lib\log4j-1.2.8.jar;
C:\TEMP" -Djava.compiler=NONE -Dreporthome=C:\JREntServer jet.server.JREntServer -a
...

Reference Note: For more information on options available, refer to the Full Command to Run from Wrapping Web Server | options section in this page.

Stop Service
There are two ways for you to stop the service:

Note: All ODBC datasources used by JREntSrv NT Service belong to the System DSN. System data sources can be used by all users on a computer and are visible to all users on the computer and system-wide services, such as Microsoft Windows NT services. User data sources can be used only by the current user and are visible only to that user. To establish JREntServer as a service, users should choose "System Data Source". That is, define the datasource in the System DSN. To do so, open Data Source (ODBC) in Control Panel, add the datasource used by JREntServer to System DSN panel. Remove the old ones from User DSN.

Service on Unix

Let's assume that JReport Enterprise Server has been installed to /user/report/jns.

  1. Write a script /etc/init.d/jrserver as below, and make it executable.

    #!/bin/sh
    
    mode=$1
    
    if [ ! -d /user/report/jns ]
    then # JReport not installed
    exit 1
    fi
    
    case "$mode" in
    'start')
    if [ -d /user/report/jns ]
    then
    echo "Starting JReport Enterprise Server"
    /user/report/jns/bin/NJREntServer.sh &
    fi
    ;;
    
    'stop')
    if [ -d /user/report/jns ]
    then
    echo "Stopping JReport Enterprise Server"
    /user/report/jns/bin/CmdSender.sh localshutdown &
    fi
    ;;
    
    *)
    echo " Usage: "
    echo " $0 start (start JReport Enterprise Server)"
    echo " $0 stop (stop JReport Enterprise Server)"
    exit 1
    ;;
    esac
    exit 0
  2. Create a soft link to /etc/rc2.d/S99jrserver.

    ln -s /etc/init.d/jrserver /etc/rc2.d/S99jrserver
  3. Create a soft link to /etc/rc0.d/K99jrserver.

    ln -s /etc/init.d/jrserver /etc/rc0.d/K99jrserver

Service on Linux

Running JReport Enterprise Server as an OS Service on Linux is more or less the same as that on Unix. Let's assume that your default start up rc is rc5.

JDK 1.2 and above

Setting up XVFB

1. Install XVFB.

2. Write a script /etc/init.d/xvfb as below, and make it executable.

#!/bin/sh
mode=$1
case "$mode" in
'start')
echo "start xvfb "
if [ -f /usr/X11R6/bin/Xvfb ]
then
/usr/X11R6/bin/Xvfb :1 -screen 0 1152x900x8 &
fi
;;
*)
echo " Usage: "
echo " $0 start (start XVFB)"    
echo " $0 stop (stop XVFB not support)"
exit 1
esac  
exit 0


3. Create a soft link to /etc/rc5.d/S97xvfb

ln -s /etc/init.d/xvfb /etc/rc5.d/S97xvfb

Using rc to run JReport Enterprise Server as a service

Let's assume that JReport Enterprise Server is installed to /JREntServer.

1. Write a script /JREntServer/bin/JREntServer.silent as below, and make it executable. We assume that JREntServer is running on machine with IP 192.168.126.28.

#!/bin/sh
DISPLAY=192.168.126.28:1.0
export DISPLAY
/JREntServer/bin/JREntServer -silent "$@"


2. Write a script /etc/init.d/jrserver as below, and make it executable.

#!/bin/sh

mode=$1
if [ ! -d /JREntServer ]
then # JReport not installed
exit 1
fi

case "$mode" in
'start')
if [ -d /JREntServer ]
then
echo "Starting JReport Enterprise Server"
cd /JREntServer/bin/JREntServer/bin/JREntServer.silent & 
fi
;;

'stop')
if [ -d /JREntServer ]
then
echo "Stopping JReport Enterprise Server"
/JREntServer/bin/CmdSender localshutdown &
fi
;;

*)
echo " Usage: "
echo " $0 start (start JReport Enterprise Server)"
echo " $0 stop (stop JReport Enterprise Server)"
exit 1
;;
esac
exit 0


3. Create a soft link to /etc/rc5.d/S98jrserver

ln -s /etc/init.d/jrserver /etc/rc5.d/S98jrserver

4. Create a soft link to /etc/rc5.d/K98jrserver

ln -s /etc/init.d/jrserver /etc/rc5.d/K98jrserver

If everything has been done successfully, now the installation of service is finished. JReport Enterprise Server is now ready to run as a daemon process.

Running with third Party's Servlet-Enabled Web Server

In addition to a standalone server and service, the third mode that JReport Enterprise Server can run is as a servlet inside other servers. Since JReport Enterprise Server is implemented using a servlet, it can work with other servlet-enabled web servers by assembling the shipped servlet.

Reference:

Index