Menu

How to set environment variables in wrapper.c

Naveen KVM
2008-05-19
2012-12-11
  • Naveen KVM

    Naveen KVM - 2008-05-19

    Hi, I am trying to pass some environment variables to my application. I have tried the options like set.variablename=varibali value, but it's not working fine. Please let me know how to set environment variables. Ex: log4j=c:/log4j.properties.

    In my java code, iam accessign it as System.getProperty("log4j");
    But it's returning null.

    If anybody knows the solution, please email me at naveen.manga@theaa.com and naveenkvm@gmail.com

     
    • Naveen KVM

      Naveen KVM - 2008-05-19

      I am using wrapper 3.3.0. Please help me. It's urgent.

       
    • Naveen KVM

      Naveen KVM - 2008-05-19

      Sorry i am using wrapper 3.0.5 and jdk 1.5 to run my jaav application as a windows service.

       
    • Naveen KVM

      Naveen KVM - 2008-05-19

      Following is the error i am getting:

      wrapper  | --> Wrapper Started as Console
      wrapper  | Launching a JVM...
      jvm 1    | DEV_LOG4J value is: null
      jvm 1    | Error in DeploymentProperties.getParameter : could not access log4j.p
      roperties
      jvm 1    | Systerm reported error : javax.naming.NameNotFoundException: No objec
      t bound for java:comp/env
      jvm 1    | Assinging default value
      jvm 1    | Unable to load log4j.properties file. It must be specified as a JVM a
      rgument, i.e. one of the following values should be setjava -Dlog4j.properties=<
      <path to log4j.properties file>> or java -Dresources.dir=<<path to resources dir
      ectory>>
      jvm 1    | proxy properties path is: null
      jvm 1    | log4j:WARN No appenders could be found for logger (com.centrica.mti.c
      lient.EPYXMessageListener).
      jvm 1    | log4j:WARN Please initialize the log4j system properly.
      jvm 1    | proxy properties path is: null
      jvm 1    | java.lang.NullPointerException
      jvm 1    |      at java.io.File.<init>(Unknown Source)
      jvm 1    |      at com.centrica.mti.client.EPYXMessageListener.init(EPYXMessageL
      istener.java:68)
      jvm 1    |      at com.centrica.mti.client.EPYXMessageListener.main(EPYXMessageL
      istener.java:376)
      wrapper  | JVM exited while loading the application.

      Here it's saying the variable should be passed as JVM argument. How can i do that in java wrapper?

      In normal batch file, i can do it like the following way:

      java -classpath %CLASSPATH% -DError.xml=C:\EPYX\Error.xml -Dloader.properties=C:\EPYX\loader.properties -Dlog4j.properties=C:\EPYX\log4j.properties -Dproxy.settings=C:\EPYX\proxySettings.properties com.centrica.mti.client.EPYXMessageListener

      But i don't know how to do it ni java service wrapper.

      Please help me.

      Thanks in advance.

       
    • Leif Mortenson

      Leif Mortenson - 2008-05-19

      Naveen,
      I think you are confusing environment variables and java system properties.

      This will set an environment variable names LOG4J.  It will be visible to the system environment but Java does NOT have direct access to environment variables:
      set.LOG4J=c:/log4j.properties

      If you want to pass a system property named "log4j" to the JVM, it must be done with a command line argument to the JVM like this:
      -Dlog4j=c:/log4j.properties
      With the Wrapper, this is done as follows:
      wrapper.java.additional.1=-Dlog4j=c:/log4j.properties

      If you like, you can also combine the two of these methods as follows:
      set.LOG4J=c:/log4j.properties
      wrapper.java.additional.1=-Dlog4j=%LOG4J%

      Both of these are documented here:
      http://wrapper.tanukisoftware.org/doc/english/props-envvars.html
      http://wrapper.tanukisoftware.org/doc/english/prop-java-additional-n.html

      Cheers,
      Leif

       
    • Naveen KVM

      Naveen KVM - 2008-05-19

      Hi Leif,
                Thank u for the valuable info. Now my service is able to call the main method and when the main method is started, after sometime i am getting the following error:

      ERROR  | wrapper  | 2008/05/19 14:05:22 | Startup failed: Timed out waiting for signal from JVM.
      ERROR  | wrapper  | 2008/05/19 14:05:22 | Java Virtual Machine did not exit on request, terminated

       
    • Naveen KVM

      Naveen KVM - 2008-05-19

      My wrapper.conf:

      #********************************************************************
      # Wrapper Properties
      #********************************************************************
      # Java Application
      java
      # Java Main class.  This class must implement the WrapperListener interface
      #  or guarantee that the WrapperManager class is initialized.  Helper
      #  classes are provided to do this for you.  See the Integration section
      #  of the documentation for details.

      wrapper.java.mainclass=com.centrica.mti.client.EPYXMessageListener

      # Java Classpath (include wrapper.jar)  Add class path elements as
      #  needed starting from 1
      wrapper.java.classpath.1=../lib/wrapper.jar
      wrapper.java.classpath.2=../lib/wrappertest.jar
      wrapper.java.classpath.3=../lib/weblogic.jar
      wrapper.java.classpath.4=../lib/webservices.jar
      wrapper.java.classpath.5=../lib/activation.jar
      wrapper.java.classpath.6=../lib/axis.jar
      wrapper.java.classpath.7=../lib/classes12.jar
      wrapper.java.classpath.8=../lib/comm.jar
      wrapper.java.classpath.9=../lib/commons-beanutils.jar
      wrapper.java.classpath.10=../lib/commons-codec-1.3.jar
      wrapper.java.classpath.11=../lib/commons-discovery-0.2.jar
      wrapper.java.classpath.12=../lib/commons-logging.jar
      wrapper.java.classpath.13=../lib/commons-pool-1.2.jar
      wrapper.java.classpath.14=../lib/dom4j-1.6.1.jar
      wrapper.java.classpath.15=../lib/j2ee.jar
      wrapper.java.classpath.16=../lib/jaxen-1.1-beta-2.jar
      wrapper.java.classpath.17=../lib/jaxrpc.jar
      wrapper.java.classpath.18=../lib/jaxrpc-impl.jar
      wrapper.java.classpath.19=../lib/jcert.jar
      wrapper.java.classpath.20=../lib/jnet.jar
      wrapper.java.classpath.21=../lib/jsse.jar
      wrapper.java.classpath.22=../lib/log4j-1.2.8.jar
      wrapper.java.classpath.23=../lib/mail.jar
      wrapper.java.classpath.24=../lib/serializer.jar
      wrapper.java.classpath.25=../lib/soap.jar
      wrapper.java.classpath.26=../lib/webserviceutils.jar
      wrapper.java.classpath.27=../lib/ws-commons-util-1.0.1.jar
      wrapper.java.classpath.28=../lib/wsdl4j.jar
      wrapper.java.classpath.29=../lib/xalan.jar
      wrapper.java.classpath.30=../lib/xbean_xpath.jar
      wrapper.java.classpath.31=../lib/xbean.jar
      wrapper.java.classpath.32=../lib/xerces.jar
      wrapper.java.classpath.33=../lib/xercesImpl.jar
      wrapper.java.classpath.34=../lib/xml-apis.jar
      wrapper.java.classpath.35=../lib/xpath.jar
      wrapper.java.classpath.36=../lib/xsltc.jar
      wrapper.java.classpath.36=../lib/commons-httpclient-3.1.jar
      wrapper.java.classpath.37=../classes

      # Java Library Path (location of Wrapper.DLL or libwrapper.so)
      wrapper.java.library.path.1=../lib

      # Java Additional Parameters
      #wrapper.java.additional.1=

      # Initial Java Heap Size (in MB)
      wrapper.java.initmemory=3

      # Maximum Java Heap Size (in MB)
      wrapper.java.maxmemory=64

      # Application parameters.  Add parameters as needed starting from 1
      #wrapper.app.parameter.1=

      #********************************************************************
      # Wrapper Logging Properties
      #********************************************************************
      # Format of output for the console.  (See docs for formats)
      wrapper.console.format=PM

      # Log Level for console output.  (See docs for log levels)
      wrapper.console.loglevel=INFO

      # Log file to use for wrapper output logging.
      wrapper.logfile=../logs/wrapper.log

      # Format of output for the log file.  (See docs for formats)
      wrapper.logfile.format=LPTM

      # Log Level for log file output.  (See docs for log levels)
      wrapper.logfile.loglevel=INFO

      # Maximum size that the log file will be allowed to grow to before
      #  the log is rolled. Size is specified in bytes.  The default value
      #  of 0, disables log rolling.  May abbreviate with the 'k' (kb) or
      #  'm' (mb) suffix.  For example: 10m = 10 megabytes.
      wrapper.logfile.maxsize=0

      # Maximum number of rolled log files which will be allowed before old
      #  files are deleted.  The default value of 0 implies no limit.
      wrapper.logfile.maxfiles=0

      # Log Level for sys/event log output.  (See docs for log levels)
      wrapper.syslog.loglevel=NONE

      #********************************************************************
      # Wrapper NT Service Properties
      #********************************************************************
      # WARNING - Do not modify any of these properties when an application
      #  using this configuration file has been installed as a service.
      #  Please uninstall the service before modifying this section.  The
      #  service can then be reinstalled.

      # Name of the service
      wrapper.ntservice.name=EPYX Car Hire service

      # Display name of the service
      wrapper.ntservice.displayname=EPYX Listener Service

      # Description of the service
      wrapper.ntservice.description=EPYX Listener Service Description

      # Service dependencies.  Add dependencies as needed starting from 1
      wrapper.ntservice.dependency.1=

      # Mode in which the service is installed.  AUTO_START or DEMAND_START
      wrapper.ntservice.starttype=AUTO_START

      # Allow the service to interact with the desktop.
      wrapper.ntservice.interactive=false

      wrapper.java.additional.1=-Dlog4J=../bin/log4j.properties
      wrapper.java.additional.2=-DError.xml=../bin/Error.xml
      wrapper.java.additional.3=-Dloader.properties=../bin/loader.properties
      wrapper.java.additional.4=-DproxyProps=../bin/proxySettings.properties

      MYEPYXAPP.bat:

      @echo off
      rem
      rem Find the application home.
      rem

      if "%OS%"=="Windows_NT" goto nt

      echo This is not NT, so please edit this script and set _APP_HOME manually
      set _APP_HOME=..

      goto conf

      :nt
      rem %~dp0 is name of current script under NT
      set _APP_HOME=%~dp0
      rem : operator works similar to make : operator
      set _APP_HOME=%_APP_HOME:\bin\=%

      rem
      rem Find the wrapper.conf
      rem
      :conf
      set _WRAPPER_CONF="%~f1"
      if not %_WRAPPER_CONF%=="" goto startup
      set _WRAPPER_CONF="%_APP_HOME%\conf\wrapper.conf"

      rem
      rem Run the application.
      rem At runtime, the current directory will be that of Wrapper.exe
      rem
      :startup
      "%_APP_HOME%\bin\Wrapper.exe" -c %_WRAPPER_CONF%
      if not errorlevel 1 goto end
      pause

      :end
      set _APP_HOME=
      set _WRAPPER_CONF=

      wrapper.log:

      STATUS | wrapper  | 2008/05/19 14:03:00 | Launching a JVM...
      INFO   | jvm 1    | 2008/05/19 14:03:00 | DEV_LOG4J value is: ../bin/log4j.properties
      INFO   | jvm 1    | 2008/05/19 14:03:01 | Error in DeploymentProperties.getParameter : could not access log4j.properties
      INFO   | jvm 1    | 2008/05/19 14:03:01 | Systerm reported error : javax.naming.NameNotFoundException: No object bound for java:comp/env
      INFO   | jvm 1    | 2008/05/19 14:03:01 | Assinging default value
      INFO   | jvm 1    | 2008/05/19 14:03:02 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 1    | 2008/05/19 14:03:02 | <IHub><INFO ><19/May/08 14:03:02 BST>Entered EPYXMessageListener !!                                                      
      INFO   | jvm 1    | 2008/05/19 14:03:02 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 1    | 2008/05/19 14:03:02 | <IHub><INFO ><19/May/08 14:03:02 BST>Provider url while getting topic connection is: t3://10.87.23.219:17111             
      ERROR  | wrapper  | 2008/05/19 14:03:31 | Startup failed: Timed out waiting for signal from JVM.
      ERROR  | wrapper  | 2008/05/19 14:03:31 | Java Virtual Machine did not exit on request, terminated
      STATUS | wrapper  | 2008/05/19 14:03:37 | Launching a JVM...
      INFO   | jvm 2    | 2008/05/19 14:03:37 | DEV_LOG4J value is: ../bin/log4j.properties
      INFO   | jvm 2    | 2008/05/19 14:03:38 | Error in DeploymentProperties.getParameter : could not access log4j.properties
      INFO   | jvm 2    | 2008/05/19 14:03:38 | Systerm reported error : javax.naming.NameNotFoundException: No object bound for java:comp/env
      INFO   | jvm 2    | 2008/05/19 14:03:38 | Assinging default value
      INFO   | jvm 2    | 2008/05/19 14:03:39 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 2    | 2008/05/19 14:03:39 | <IHub><INFO ><19/May/08 14:03:38 BST>Entered EPYXMessageListener !!                                                      
      INFO   | jvm 2    | 2008/05/19 14:03:39 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 2    | 2008/05/19 14:03:39 | <IHub><INFO ><19/May/08 14:03:38 BST>Provider url while getting topic connection is: t3://10.87.23.219:17111             
      ERROR  | wrapper  | 2008/05/19 14:04:08 | Startup failed: Timed out waiting for signal from JVM.
      ERROR  | wrapper  | 2008/05/19 14:04:08 | Java Virtual Machine did not exit on request, terminated
      STATUS | wrapper  | 2008/05/19 14:04:14 | Launching a JVM...
      INFO   | jvm 3    | 2008/05/19 14:04:14 | DEV_LOG4J value is: ../bin/log4j.properties
      INFO   | jvm 3    | 2008/05/19 14:04:15 | Error in DeploymentProperties.getParameter : could not access log4j.properties
      INFO   | jvm 3    | 2008/05/19 14:04:15 | Systerm reported error : javax.naming.NameNotFoundException: No object bound for java:comp/env
      INFO   | jvm 3    | 2008/05/19 14:04:15 | Assinging default value
      INFO   | jvm 3    | 2008/05/19 14:04:16 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 3    | 2008/05/19 14:04:16 | <IHub><INFO ><19/May/08 14:04:15 BST>Entered EPYXMessageListener !!                                                      
      INFO   | jvm 3    | 2008/05/19 14:04:16 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 3    | 2008/05/19 14:04:16 | <IHub><INFO ><19/May/08 14:04:15 BST>Provider url while getting topic connection is: t3://10.87.23.219:17111             
      ERROR  | wrapper  | 2008/05/19 14:04:45 | Startup failed: Timed out waiting for signal from JVM.
      ERROR  | wrapper  | 2008/05/19 14:04:45 | Java Virtual Machine did not exit on request, terminated
      STATUS | wrapper  | 2008/05/19 14:04:51 | Launching a JVM...
      INFO   | jvm 4    | 2008/05/19 14:04:51 | DEV_LOG4J value is: ../bin/log4j.properties
      INFO   | jvm 4    | 2008/05/19 14:04:52 | Error in DeploymentProperties.getParameter : could not access log4j.properties
      INFO   | jvm 4    | 2008/05/19 14:04:52 | Systerm reported error : javax.naming.NameNotFoundException: No object bound for java:comp/env
      INFO   | jvm 4    | 2008/05/19 14:04:52 | Assinging default value
      INFO   | jvm 4    | 2008/05/19 14:04:53 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 4    | 2008/05/19 14:04:53 | <IHub><INFO ><19/May/08 14:04:52 BST>Entered EPYXMessageListener !!                                                      
      INFO   | jvm 4    | 2008/05/19 14:04:53 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 4    | 2008/05/19 14:04:53 | <IHub><INFO ><19/May/08 14:04:52 BST>Provider url while getting topic connection is: t3://10.87.23.219:17111             
      ERROR  | wrapper  | 2008/05/19 14:05:22 | Startup failed: Timed out waiting for signal from JVM.
      ERROR  | wrapper  | 2008/05/19 14:05:22 | Java Virtual Machine did not exit on request, terminated
      STATUS | wrapper  | 2008/05/19 14:05:28 | Launching a JVM...
      INFO   | jvm 5    | 2008/05/19 14:05:28 | DEV_LOG4J value is: ../bin/log4j.properties
      INFO   | jvm 5    | 2008/05/19 14:05:29 | Error in DeploymentProperties.getParameter : could not access log4j.properties
      INFO   | jvm 5    | 2008/05/19 14:05:29 | Systerm reported error : javax.naming.NameNotFoundException: No object bound for java:comp/env
      INFO   | jvm 5    | 2008/05/19 14:05:29 | Assinging default value
      INFO   | jvm 5    | 2008/05/19 14:05:30 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 5    | 2008/05/19 14:05:30 | <IHub><INFO ><19/May/08 14:05:30 BST>Entered EPYXMessageListener !!                                                      
      INFO   | jvm 5    | 2008/05/19 14:05:30 | proxy properties path is: ../bin/proxySettings.properties
      INFO   | jvm 5    | 2008/05/19 14:05:30 | <IHub><INFO ><19/May/08 14:05:30 BST>Provider url while getting topic connection is: t3://10.87.23.219:17111             
      ERROR  | wrapper  | 2008/05/19 14:05:59 | Startup failed: Timed out waiting for signal from JVM.
      ERROR  | wrapper  | 2008/05/19 14:05:59 | Java Virtual Machine did not exit on request, terminated
      FATAL  | wrapper  | 2008/05/19 14:05:59 | There were 5 failed launches in a row, each lasting less than 300 seconds.  Giving up.
      FATAL  | wrapper  | 2008/05/19 14:05:59 |   There may be a configuration problem: please check the logs.
      STATUS | wrapper  | 2008/05/19 14:06:00 | <-- Wrapper Stopped

       
      • Leif Mortenson

        Leif Mortenson - 2008-05-19

        Naveen、
        Which integration method are you implementing?
        http://wrapper.tanukisoftware.org/doc/english/integrate.html

        Unless your com.centrica.mti.client.EPYXMessageListener class implements the org.tanukisoftware.wrapper.WrapperListener, you are not doing things correctly.

        Most likely method 1 will work for you.  Read over the docs.  Try using the following two values:

        wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
        wrapper.app.parameter.1=com.centrica.mti.client.EPYXMessageListener

        It is also possible for you to GREATLY simplify your classpath by using wildcards.  The following should do the same thing as you have implemented and will be much more stable under changes.

        wrapper.java.classpath.1=../lib/*.jar
        wrapper.java.classpath.2=../classes

        Cheers,
        Leif

         
    • Naveen KVM

      Naveen KVM - 2008-05-19

      I am uding wrapper_win32_3.0.5 wrapper.jar. Is there anything wrong? My jaav version is 1.5.

       
    • Naveen KVM

      Naveen KVM - 2008-05-20

      I am using the 3rd method bcoz i am not using either JBOSS or Tomcat. I took the Main class in 3rd integration method and inside the start method of that Main class i am calling the main() method of EPYXMessageListener. I am getting " Start up failed, time out waitig for signal" error. Later i set the  following properties in wrapper.conf file:

      wrapper.startup.timeout=300000
      wrapper.shutdown.timeout=300000

      It is starting well but in the services it is showing the status as starting always. I am confused. Please help me.

       
    • Naveen KVM

      Naveen KVM - 2008-05-20

      Hi Leif,
                 I have used the first integration method without JBOSS. Now the service getting started and stopped properly. Thanks a lot for your valueable help and service which is helping lot of developers/consultants.

      Regards,
      Naveen.

       
      • Leif Mortenson

        Leif Mortenson - 2008-05-20

        Naveen,
        I think you have figured it out but the Tomcat and JBoss examples are simply that.  Example applications that can be integrated with each application.

        For your Method 3 implementation.  Most likely the problem was that your WrapperListener.start method was not returning.  If you read the javadocs for the class, you will see that it is critical that the start method return with a startup status code in a short period of time.

        Glad you got things working.

        Cheers,
        Leif

         

Log in to post a comment.