Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4323062

Any Windows NT Service embedding Java VM aborts, when user logs out from Windows

    Details

    • Subcomponent:
    • Resolved In Build:
      04
    • CPU:
      generic, x86
    • OS:
      solaris_2.3, windows_nt, windows_2000
    • Verification:
      Verified

      Backports

        Description

           IHAC with a NT Service program which starts a Java program. The java
         program is a simple program with a server socket waiting to accept socket
         connections. The program is installed and everything works fine until the user
         decides to log off. Since the Java program is installed through the NT Service,
         the program should continue to work even when the user logs out of the
         system. But on the contrary, the program goes into an unstable state and the
         program hangs. I have enclosed the stack trace which I managed to capture by
         making the NT Service interact with the desktop, so we get to see the console.

         This problem does not occur with JDK1.1.x. This happens only for JDK1.2 and
         greater versions. The Java thread dump and testcase TestNTSvc.tar.Z is
         in the attachments.
         

        Follow these instructions to reproduce the problems:
        SOURCE MODIFICATION
        =============================================================
        1)In the clienttest.java file edit line 16:
           s = new Socket("sworks.eng.sun.com",7990);
          with your test system's host address. Save and recompile.


        INSTRUCTIONS FOR INSTALLING SERVICE ON WINDOW NT 4.0
        ==============================================================

        1. Extract the contents of the zip file to say C:\
        2. Assuming this, you would now have a directory C:\testntsvc
        3. Create an "System Variable" TEST_ROOT in Environment tab of the System
           Properties from the "Control Panel" Settings
        and set C:\testntsvc
        to
           TEST_ROOT.
        4. Append C:\testntsvc to your classpath settings in control panel and also
           make sure your CLASSPATH is a "System Variable".
        5. Go to DOS command prompt and go to the directory c:\testntsvc
        6. Type TestNTSvc -install to install the NTService.
        7. Now go to your control panel settings and click on the "Services"
           icon to see if the NT Service "TestNTSvc" is installed.
        8. If it has not been installed please contact me at ###@###.###
        or 650 526 3336.
        9. If it has been installed, then select the "TestNTSvc"
        in the services window, click on the button "Startup" and set
        the "StartUp Type" to Manual(from Automatic).
        Also check the checkbox for "Allow Service to interact with the Desktop".
        10. Now click on OK Button and close the control panel settings.
        11. Now ensure that you have installed JDK1.1.6, JDK1.1.7b and Java2 on your
        NT Workstation.
        12. Open the file "cmdscripts.cfg" file in C:\testntsvc, and update your
        directory path for the various jre vms. You can comment all the lines
        except the line which you intend to invoke a particular JVM, so for example
        you intend to run jre1.2.2, then the following would be the text in the
        file cmdscripts.cfg file:

        ================================================================================
        adm=d:/jdk1.2.2/jre/bin/java -mx256m -DTEST_ROOT=%TEST_ROOT% testserver
        #adm=f:/jdk1.1.7b/bin/java -mx256m -classpath %classpath%;f:/testntsvc -DTEST_ROOT=%TEST_ROOT% testserver
        #adm=f:/jdk1.1.7b/bin/jre -mx256m -cp f:/testntsvc -DTEST_ROOT=%TEST_ROOT% testserver
        adm=f:/jdk1.1.6/bin/jre -cp f:/testntsvc -DTEST_ROOT=%TEST_ROOT% testserver
        #adm=f:/jdk1.1.6/bin/java -classpath %classpath%;f:/testntsvc -DTEST_ROOT=%TEST_ROOT% testserver
        ================================================================================
        13. Save the file and close it.
        14. Reboot your workstation so that the classpath and the new "System
        variables" comes into effect.
        15. After booting go to the control panel.
        16. Go to the services panel in control panel and
        start the NT Service "TestNTSvc". You should now see the Java console
        for d:/jdk1.2.2/bin/jre with the statement "Getting Connected" being printed
        in the console.

        17. Run the Java test program testclient.java on the command prompt,
        by typing in at the command prompt c:\testntsvc>java testclient
        18. The program works and exits normally after printing the statements
        "Creating a Socket", "Created the client Socket" on the console. This
        is what a remote client system would see when accessing the Server service.

        19. Now try logging off the NT Workstation and you will see in the Java console
            that the JVM dumps a Java thread trace and the service hangs unresponsive
            when you log back in.



        Name: rlT66838 Date: 03/29/2000


        java version "1.3.0rc2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc2-Y)
        Java HotSpot(TM) Client VM (build 1.3.0rc2-Y, mixed mode)


        I'm writing NT-service by JDK1.3 (and some C codes).

        1.NT-service start by manual. (check "System Account")
        2.logoff

        ...then, NT-service(running JVM in service) stop process.

        I hope, cancel shutdown JVM.
        (Review ID: 103003)
        ======================================================================

        Name: rlT66838 Date: 04/04/2000


        java version "1.3.0rc1"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
        Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)

        Using ServiceInstaller 1.1 (http://www.kcmultimedia.com/smaster) install a
        simple Java app as a service that outputs some trivial data to a file every
        10 seconds.

        Here's the simple demo service:

        import java.io.*;
        import java.util.*;


        public class Test2
        {
            public static void main(String[] args)
            {

                Date now;
                PrintWriter out;

                try{

                    

                    while(true){

                        now = new Date();
                        out = new PrintWriter(new FileWriter("test2.out",true), true);
                        out.println(now.toString());
                        out.close();

                        Thread.sleep(10000);

                    }

                }catch(Exception e){

                    System.out.println(e.toString());

                }
            }
        }

        Start the service from the Control Panel|Services Applet, and check the
        contents of the file test2.out, which should append a line showing the
        date and time each 10 sec.

        Log off, and log back in.

        Although NT thinks the service is still running, it is not. You will see
        that lines are no longer appended to the file.

        This seems to only occur with JDK 1.3 RC1. Under JDK 1.2.2, the test app
        keeps running thru the login/logout
        (Review ID: 102993)
        ======================================================================

        Name: yyT116575 Date: 11/09/2000


        java version "1.3.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
        Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

        I am using JNI 1.2 with JRE 1.3:

        Write an NT Service that uses JNI to call the main method of a Java class
        (NOTE user.name will be "SYSTEM")

        Install & start the service.

        Logoff.

        Service dies!!!

        NOTE: JRE 1.2 deals with this correctly--when user logs back in the service is
        still running.

        I have thoroughly checked that my code is not exiting--
            env->CallStaticVoidMethod(jcl, m_methID, m_jobjArr);
        never returns & there exists NO System.exit() in my java class.
        (Review ID: 111892)
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  kbr Kenneth Russell (Inactive)
                  Reporter:
                  atongschsunw Albert Tong-schmidt (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: