2 Replies Latest reply on Oct 21, 2010 12:29 AM by 806597

    Connection refused trying execute applet from clients but in server works

    806597
      Hi to All Sun members
      I have a web application on a server Linux Debian with apache version tomcat-6.0.24 and jre-6u19 and jdk-6u21. There is an embedded signed applet that prints documents; locally in the web server run it successfully printing from my web application. The clients workstations can access the web aplication fine even can load that applet but when they (clients) try execute this applet in order to print, it doesn't run and the java console shows an error like this (Connection refused o Conexión rehusada):

      java.security.PrivilegedActionException: java.net.ConnectException: Connection refused
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.deploy.net.CrossDomainXML.check(CrossDomainXML.java:354)
      at com.sun.deploy.net.CrossDomainXML.check(CrossDomainXML.java:148)
      at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Applet2SecurityManager.java:508)
      at sun.net.www.protocol.http.HttpURLConnection.checkURLFile(HttpURLConnection.java:512)
      at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:362)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1070)
      at sun.print.CUPSPrinter.getDefaultPrinter(CUPSPrinter.java:251)
      at sun.print.UnixPrintServiceLookup.getDefaultPrintService(UnixPrintServiceLookup.java:506)
      at javax.print.PrintServiceLookup.lookupDefaultPrintService(PrintServiceLookup.java:166)
      at AppletPrint.prep(AppletPrint.java:87)
      at AppletPrint.print(AppletPrint.java:101)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at sun.plugin.javascript.JSInvoke.invoke(JSInvoke.java:20)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at sun.plugin.javascript.JSClassLoader.invoke(JSClassLoader.java:72)
      at sun.plugin2.liveconnect.JavaClass$MethodInfo.invoke(JavaClass.java:123)
      at sun.plugin2.liveconnect.JavaClass$MemberBundle.invoke(JavaClass.java:278)
      at sun.plugin2.liveconnect.JavaClass.invoke0(JavaClass.java:429)
      at sun.plugin2.liveconnect.JavaClass.invoke(JavaClass.java:410)
      at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$DefaultInvocationDelegate.invoke (LiveConnectSupport.java:980)
      at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$3.run(LiveConnectSupport.java:637)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo.doObjectOp(LiveConnectSupport.java:632)
      at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$LiveConnectWorker.run (LiveConnectSupport.java:1743)
      at java.lang.Thread.run(Thread.java:619)

      Caused by: java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
      at java.net.Socket.connect(Socket.java:529)
      at sun.net.NetworkClient.doConnect(NetworkClient.java:161)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
      at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
      at sun.net.www.http.HttpClient.New(HttpClient.java:306)
      at sun.net.www.http.HttpClient.New(HttpClient.java:323)
      at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801)
      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726)
      at com.sun.deploy.net.CrossDomainXML$2.run(CrossDomainXML.java:358)
      ... 32 more


      My applet receives parameters from the java web application through one of its functions and this function prints to the default printer installed.

      In a Windows Network it prints fine in a client, i mean my clients load and run that applet whitout errors. And i repeat, in the same linux apache server that applet run and prints without errors but the clients don't.
      I created and put the crossdomain.xml in ROOT folder also inside the webapps folder but nothing.

      The content of my crossdomain file is:
      <?xml version="1.0"?>
      <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
      <cross-domain-policy>
      <allow-access-from domain="*" />
      </cross-domain-policy>


      The permissions in java.policy that i set for the applet for prints are: queuprintjob, Execute-write-read-delete to ALL FILES, createrobot and ReadDisplayPixels.

      The .keystore certificated file is created like in the server with the same credentials.
      Like in the server, in the clients i run the web-browser with root privileges.


      Please can you help, i thought that the crossdomain.xml file works but it didn´t.
      Any other solution ?
        • 1. Re: Connection refused trying execute applet from clients but in server works
          793415
          803594 wrote:
          ..Any other solution ?
          Digitally sign the applet and induce the user to trust it.

          Alternately, if the problem is only the printing, deploy the applet in a 1.6.0_10+ JRE using JNLP and use the PrintService of the JNLP API services. I have a small demo. of the Print Service at http://pscode.org/jws/api.html#ps.
          • 2. Re: Connection refused trying execute applet from clients but in server works
            806597
            Andrew Thompson, thanks for the alternative but my applet works fine in the way that this read a jpg file from the hard disk and print it automatically without user intervention. I forgot to tell you that this is an intranet. This works on Windows XP clients when the applet is in the apache server, also works locally in the same server (windows or linux). But in linux clients shows me the error.

            I have signed digitally the applet to jar with jarsigner tool in the apache server; in my clients (also in the server) I created the certificated using keytool, all with the same credentials. On this way the server locally prints fine, but besides the keystore on user home, something i missing in my clients so i can induce them to trust it.

            Wiil it be a crossdomain problem or grant another permission in java-policy on the client or set a value in the Java PanelControl ?