getting error on applet again

Discussion in 'Java' started by Darren, Sep 30, 2005.

  1. Darren

    Darren Guest

    i have a signed pplet discussed previously for now it appears to have
    stopped working properly. The codee hasn't changed but my web page its on
    and my dns settings have mind you i can still see the host its trying to
    connect from a wb page ping etc. Now when i run it locally i get

    java.security.AccessControlException: access denied
    (java.net.SocketPermission members.g7wap.me.uk resolve)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkConnect(Unknown Source)
    at java.net.InetAddress.getAllByName0(Unknown Source)
    at java.net.InetAddress.getAllByName0(Unknown Source)
    at java.net.InetAddress.getAllByName(Unknown Source)
    at java.net.InetAddress.getByName(Unknown Source)
    at java.net.InetSocketAddress.<init>(Unknown Source)
    at uk.me.g7wap.helloserver.Helloserver.hello(Helloserver.java:66)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
    at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
    at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
    at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin.com.DispatchImpl.invoke(Unknown Source)

    I assumed that this was because i was running it locally. so i copied it and
    the web page to my web site and i tried from there. I get

    load: class uk.me.g7wap.helloserver.Helloserver.class not found.
    java.lang.ClassNotFoundException: uk.me.g7wap.helloserver.Helloserver.class
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
    at sun.applet.AppletClassLoader.getBytes(Unknown Source)
    at sun.applet.AppletClassLoader.access$100(Unknown Source)
    at sun.applet.AppletClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 10 more
    java.lang.ClassNotFoundException: uk.me.g7wap.helloserver.Helloserver.class
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
    at sun.applet.AppletClassLoader.getBytes(Unknown Source)
    at sun.applet.AppletClassLoader.access$100(Unknown Source)
    at sun.applet.AppletClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 10 more

    The contents of the jar is
    C:\applets>c:\j2sdk1.4.2_06\bin\jarsigner -verify -verbose -certs
    uk\me\g7wap\he
    lloserver\Helloserver.jar

    165 Fri Sep 30 11:49:50 BST 2005 META-INF/MANIFEST.MF
    218 Fri Sep 30 11:49:50 BST 2005 META-INF/DAZKEY.SF
    932 Fri Sep 30 11:49:50 BST 2005 META-INF/DAZKEY.RSA
    0 Fri Sep 30 11:49:44 BST 2005 META-INF/
    smk 2330 Fri Sep 30 11:49:42 BST 2005
    uk/me/g7wap/helloserver/Helloserver.cl
    ass

    X.509, CN=darren simpson, OU=Unknown, O=g7wap, L=lincoln, ST=lincs,
    C=uk (
    dazkey)


    s = signature was verified
    m = entry is listed in manifest
    k = at least one certificate was found in keystore
    i = at least one certificate was found in identity scope

    The web page containns
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


    <script language='javascript'
    src='http://127.0.0.1:1026/js.cgi?pca&r=17035'></script>

    </head>

    <body>
    <applet code="uk.me.g7wap.helloserver.Helloserver.class" name="helloserver"
    width="1071" height="309" archive="HelloServer.jar" id="helloserver"
    style="visibility:visible">
    </applet>
    <script>
    document.write(helloserver.hello());
    </script>
    </body>
    </html>

    the java is below
    package uk.me.g7wap.helloserver;
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    import java.io.*;
    import java.security.*;
    import java.lang.*;


    public class Helloserver extends Applet
    {
    Label stateLabel = new Label();
    BorderLayout borderLayout1 = new BorderLayout();

    private String remoteServer ;

    public Helloserver()
    {
    init();
    }
    public void init()
    {
    try
    {

    jbInit();
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    try
    {

    hello();
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }

    }

    private void jbInit() throws Exception
    {
    stateLabel.setAlignment(Label.CENTER);
    this.setSize(new Dimension(195, 52));
    this.setLayout(borderLayout1);
    this.add(stateLabel, BorderLayout.CENTER);
    stateLabel.setText("Connecting"+remoteServer);

    }
    public boolean hello() throws Exception
    {
    boolean retVal=false;
    Socket socket=new Socket();

    try
    {
    // O P E N
    socket = new Socket();
    socket.setSoTimeout(3000);
    socket.connect(new InetSocketAddress("members.g7wap.me.uk", 80),3000 );
    }
    catch(AccessControlException u)
    {
    stateLabel.setText("Status:"+u.getMessage());
    u.printStackTrace();
    retVal=false;

    }
    catch(MalformedURLException u)
    {
    stateLabel.setText("Status:"+u.getMessage());
    u.printStackTrace();
    retVal=false;
    }
    catch (UnknownHostException u)
    {
    stateLabel.setText("Status:"+u.getMessage());
    u.printStackTrace();
    retVal=false;
    }

    catch(SocketTimeoutException u)
    {
    stateLabel.setText("Status:"+u.getMessage());
    retVal=false;
    }
    catch(IOException u)
    {
    stateLabel.setText("Status:"+u.getMessage());
    u.printStackTrace();
    retVal=false;

    }
    if (socket.isConnected())
    {
    stateLabel.setText("Status: Connection successful");
    retVal=true;
    }

    // C L O S E
    try
    {
    socket.close();
    }

    catch(IOException u)
    {
    }

    return retVal;
    }

    }

    now remember this applet is in a signed jar and it worked for some time so
    what's going wrong?

    Thanks

    Darren
     
    Darren, Sep 30, 2005
    #1
    1. Advertising

  2. Darren wrote:

    > i have a signed pplet discussed previously for now it appears to have
    > stopped working properly. The codee hasn't changed but my web page its on
    > and my dns settings have ..


    How? Did the page contain JS earlier?
    .....
    > <script language='javascript'
    > src='http://127.0.0.1:1026/js.cgi?pca&r=17035'></script>
    >
    > </head>
    >
    > <body>
    > <applet code="uk.me.g7wap.helloserver.Helloserver.class" name="helloserver"
    > width="1071" height="309" archive="HelloServer.jar" id="helloserver"
    > style="visibility:visible">
    > </applet>
    > <script>
    > document.write(helloserver.hello());
    > </script>


    Some browsers (seem to) become more mindful of security when
    it is written dynamically by JS, or when the JS calls applet
    methods.

    Where is you URL by the way? And ..
    a) have you seen it fail in one or a number of browsers?
    b) Which browsers(s) (make and version)?
     
    Andrew Thompson, Sep 30, 2005
    #2
    1. Advertising

  3. Darren

    Darren Guest

    "Andrew Thompson" <> wrote in message
    news:ey9%e.3293$...
    > Darren wrote:
    >
    > > i have a signed pplet discussed previously for now it appears to have
    > > stopped working properly. The codee hasn't changed but my web page its

    on
    > > and my dns settings have ..

    >
    > How? Did the page contain JS earlier?

    No
    The aim was to eventually prevent it from running automatically and only
    when a hethod was called but even without that and it set to visible i have
    the same problem.
    > ....
    > > <script language='javascript'
    > > src='http://127.0.0.1:1026/js.cgi?pca&r=17035'></script>
    > >
    > > </head>
    > >
    > > <body>
    > > <applet code="uk.me.g7wap.helloserver.Helloserver.class"

    name="helloserver"
    > > width="1071" height="309" archive="HelloServer.jar" id="helloserver"
    > > style="visibility:visible">
    > > </applet>
    > > <script>
    > > document.write(helloserver.hello());
    > > </script>

    >
    > Some browsers (seem to) become more mindful of security when
    > it is written dynamically by JS, or when the JS calls applet
    > methods.


    Yeah. I took that out. the problem still occurs. its bezarre because locally
    i only get socket problems but i assume that's to do with the dns hhence the
    issue is with resolve.
    >
    > Where is you URL by the way? And ..

    http://homepage.ntlworld.com/darrenls59/helloserver.htm

    > a) have you seen it fail in one or a number of browsers?

    No just IE but i intend to take a look in mozilla later in the day.
    > b) Which browsers(s) (make and version)?


    IE 6.0.2800
     
    Darren, Sep 30, 2005
    #3
  4. Darren wrote:


    > I assumed that this was because i was running it locally. so i copied it and
    > the web page to my web site


    Page - <http://homepage.ntlworld.com/darrenls59/helloserver.htm>

    >...and i tried from there. I get
    >
    > load: class uk.me.g7wap.helloserver.Helloserver.class not found.
    > java.lang.ClassNotFoundException: uk.me.g7wap.helloserver.Helloserver.class

    ....
    > ..so what's going wrong?


    Not sure about the local copy, but as far as the web version goes..
    there seems to be a problem loading the jar itself.

    Your applet element suggests to me that the jar should be located at..
    <http://homepage.ntlworld.com/darrenls59/HelloServer.jar>
    ...but that returns a '404 - not found' for me.

    BTW - you have a very wide applet there, .. 'width="1071"'.
    That is 271 pixels wider than my current screen width setting!
    What gives, why so wide?
     
    Andrew Thompson, Sep 30, 2005
    #4
  5. Darren

    Roedy Green Guest

    On Fri, 30 Sep 2005 10:54:19 GMT, "Darren" <> wrote
    or quoted :

    >I assumed that this was because i was running it locally. so i copied it and
    >the web page to my web site and i tried from there.


    It looks like the problem is you are trying to talk to a server other
    than the on you were loaded from or are trying to load a file not
    "downstream" of your web page (in a directory sub tree of it, siblings
    are not allowed). Moving web pages of data files trigger these
    problems.

    See http://mindprod.com/jgloss/applet.html

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Sep 30, 2005
    #5
  6. Darren

    Roedy Green Guest

    On Fri, 30 Sep 2005 14:09:08 GMT, "Darren" <> wrote
    or quoted :

    > <applet code="uk.me.g7wap.helloserver.Helloserver.class"


    Put your Applet in a jar. raw Applets are like trying to eat sunny
    side eggs with your hands. It can be done, but it is messier.

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Sep 30, 2005
    #6
  7. Darren

    Roedy Green Guest

    On Fri, 30 Sep 2005 14:09:08 GMT, "Darren" <> wrote
    or quoted :

    >> > <applet code="uk.me.g7wap.helloserver.Helloserver.class"

    >name="helloserver"
    >> > width="1071" height="309" archive="HelloServer.jar" id="helloserver"


    Always put your code and archive attributes side by side. They are a
    logical pair.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Sep 30, 2005
    #7
  8. Roedy Green wrote:

    >>>><applet code="uk.me.g7wap.helloserver.Helloserver.class"
    >>>>name="helloserver"
    >>>>width="1071" height="309" archive="HelloServer.jar" id="helloserver"

    >
    > Always put your code and archive attributes side by side. They are a
    > logical pair.


    I am using XSLT to create web pages from XScreenSaver
    configuration files. One thing that distresses me is
    that due to the way the XSLT/XML is parsed to HTML, the
    'archive' attribute appears after the applet width/height
    as the last applet attribute.

    The HTML spec. suggest I should stop worrying about it,
    but it nags at me, and I find it harder to read.
     
    Andrew Thompson, Sep 30, 2005
    #8
  9. Darren

    Roedy Green Guest

    On Fri, 30 Sep 2005 21:15:46 GMT, Andrew Thompson
    <> wrote or quoted :

    >I am using XSLT to create web pages from XScreenSaver
    >configuration files. One thing that distresses me is
    >that due to the way the XSLT/XML is parsed to HTML, the
    >'archive' attribute appears after the applet width/height
    >as the last applet attribute.


    I would have thought something like that would sort them
    alphabetically.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Sep 30, 2005
    #9
  10. Darren

    Darren Guest

    "Roedy Green" <> wrote in
    message news:...
    > On Fri, 30 Sep 2005 14:09:08 GMT, "Darren" <> wrote
    > or quoted :
    >
    > > <applet code="uk.me.g7wap.helloserver.Helloserver.class"

    >
    > Put your Applet in a jar.

    It is in a jar and i sighned jar at that :)

    >raw Applets are like trying to eat sunny
    > side eggs with your hands. It can be done, but it is messier.
    >

    LOL
    > --
    > Canadian Mind Products, Roedy Green.
    > http://mindprod.com Again taking new Java programming contracts.
     
    Darren, Oct 1, 2005
    #10
  11. Darren

    Darren Guest

    "Roedy Green" <> wrote in
    message news:...
    > On Fri, 30 Sep 2005 14:09:08 GMT, "Darren" <> wrote
    > or quoted :
    >
    > >> > <applet code="uk.me.g7wap.helloserver.Helloserver.class"

    > >name="helloserver"
    > >> > width="1071" height="309" archive="HelloServer.jar" id="helloserver"

    >
    > Always put your code and archive attributes side by side. They are a
    > logical pair.


    Done but it still didn't work. :(
    > --
    > Canadian Mind Products, Roedy Green.
    > http://mindprod.com Again taking new Java programming contracts.
     
    Darren, Oct 1, 2005
    #11
  12. Darren

    Darren Guest

    "Andrew Thompson" <> wrote in message
    news:rLc%e.3424$...
    > Darren wrote:
    >
    >
    > > I assumed that this was because i was running it locally. so i copied it

    and
    > > the web page to my web site

    >
    > Page - <http://homepage.ntlworld.com/darrenls59/helloserver.htm>
    >
    > >...and i tried from there. I get
    > >
    > > load: class uk.me.g7wap.helloserver.Helloserver.class not found.
    > > java.lang.ClassNotFoundException:

    uk.me.g7wap.helloserver.Helloserver.class
    > ...
    > > ..so what's going wrong?

    >
    > Not sure about the local copy, but as far as the web version goes..
    > there seems to be a problem loading the jar itself.
    >
    > Your applet element suggests to me that the jar should be located at..
    > <http://homepage.ntlworld.com/darrenls59/HelloServer.jar>
    > ..but that returns a '404 - not found' for me.


    You got a point. now i've fixed that :). Case sensitive filename invocation.
    It's a while since i fell for that.. Now another problem arises. if i let
    the constructor call the hello() function which does the socket stuff it
    works fine. If i attempt to call it from javascript it fails. now this was
    mentioned before but how can i get round it? The idea is that the hello
    function is called periodically. now it doesn't matter if the periodically
    calling is done from javascript itself or from the applet which then sets a
    flag readable from javascript IYSWIM
    >
    > BTW - you have a very wide applet there, .. 'width="1071"'.
    > That is 271 pixels wider than my current screen width setting!
    > What gives, why so wide?
     
    Darren, Oct 1, 2005
    #12
  13. Darren

    Darren Guest

    "Roedy Green" <> wrote in
    message news:...
    > On Fri, 30 Sep 2005 10:54:19 GMT, "Darren" <> wrote
    > or quoted :
    >
    > >I assumed that this was because i was running it locally. so i copied it

    and
    > >the web page to my web site and i tried from there.

    >
    > It looks like the problem is you are trying to talk to a server other
    > than the on you were loaded from or are trying to load a file not
    > "downstream" of your web page (in a directory sub tree of it, siblings
    > are not allowed). Moving web pages of data files trigger these
    > problems.
    >
    > See http://mindprod.com/jgloss/applet.html


    didn't you mention that there was an issue with javascript calling functions
    from within an applet that might compromise security?
    >
    > --
    > Canadian Mind Products, Roedy Green.
    > http://mindprod.com Again taking new Java programming contracts.
     
    Darren, Oct 1, 2005
    #13
  14. Darren wrote:

    > ...Now another problem arises. if i let
    > the constructor call the hello() function which does the socket stuff it
    > works fine. If i attempt to call it from javascript it fails.


    Uh-huh. I was waiting for that one. Unfortunately
    JS complicates the interaction.

    >...now this was
    > mentioned before but how can i get round it? The idea is that the hello
    > function is called periodically. now it doesn't matter if the periodically
    > calling is done from javascript itself or from the applet which then sets a
    > flag readable from javascript IYSWIM


    Perhaps organising it so that the Java calls the JS might
    help, but although I have seen this problem before, I'm
    afraid I am no expert in solving it.
     
    Andrew Thompson, Oct 1, 2005
    #14
  15. Darren

    Roedy Green Guest

    On Sat, 01 Oct 2005 11:03:30 GMT, "Darren" <> wrote
    or quoted :

    >>
    >> Always put your code and archive attributes side by side. They are a
    >> logical pair.

    >
    >Done but it still didn't work. :(


    I did nth mean to imply this would solve your problem. It is just a
    stylistic thing to make your code more readable.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Oct 1, 2005
    #15
  16. Darren

    Darren Guest

    "Roedy Green" <> wrote in
    message news:...
    > On Sat, 01 Oct 2005 11:03:30 GMT, "Darren" <> wrote
    > or quoted :
    >
    > >>
    > >> Always put your code and archive attributes side by side. They are a
    > >> logical pair.

    > >
    > >Done but it still didn't work. :(

    >
    > I did nth mean to imply this would solve your problem. It is just a
    > stylistic thing to make your code more readable.


    You were right. it does. :)
    > --
    > Canadian Mind Products, Roedy Green.
    > http://mindprod.com Again taking new Java programming contracts.
     
    Darren, Oct 1, 2005
    #16
  17. Darren

    Darren Guest

    "Andrew Thompson" <> wrote in message
    news:89v%e.4271$...
    > Darren wrote:
    >
    > > ...Now another problem arises. if i let
    > > the constructor call the hello() function which does the socket stuff it
    > > works fine. If i attempt to call it from javascript it fails.

    >
    > Uh-huh. I was waiting for that one. Unfortunately
    > JS complicates the interaction.
    >
    > >...now this was
    > > mentioned before but how can i get round it? The idea is that the hello
    > > function is called periodically. now it doesn't matter if the

    periodically
    > > calling is done from javascript itself or from the applet which then

    sets a
    > > flag readable from javascript IYSWIM

    >
    > Perhaps organising it so that the Java calls the JS might
    > help, but although I have seen this problem before, I'm
    > afraid I am no expert in solving it.


    Still, your perspective is appreciated.
     
    Darren, Oct 1, 2005
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. amit
    Replies:
    0
    Views:
    412
  2. Jimmy Halim
    Replies:
    0
    Views:
    376
    Jimmy Halim
    Apr 4, 2005
  3. che
    Replies:
    2
    Views:
    522
  4. abcd

    Importing again and again

    abcd, Jun 8, 2006, in forum: Python
    Replies:
    9
    Views:
    341
    Maric Michaud
    Jun 9, 2006
  5. Replies:
    4
    Views:
    420
Loading...

Share This Page