Results 1 to 20 of 20
  1. #1
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default getting error when applet access port of tomcat.

    hi all,
    i have applet and i am trying to access url to get some result. this url is basically contain localhost:8080 (i am using tomcat).
    i am getting error is :-
    Java Code:
    java.security.AccessControlException: access denied (java.net.SocketPermission l
    ocalhost:8080 connect,resolve)
            at java.security.AccessControlContext.checkPermission(AccessControlConte
    xt.java:323)
            at java.security.AccessController.checkPermission(AccessController.java:
    546)
            at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
            at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034)
            at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
            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(HttpURLC
    onnection.java:860)
            at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
    ction.java:801)
            at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
    .java:726)
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:1049)
            at java.net.URL.openStream(URL.java:1010)
            at AccessPointClient.getStream(AccessPointClient.java:157)
            at AccessPointClient.issueRequest(AccessPointClient.java:181)
            at AccessPointClient.login(AccessPointClient.java:90)
            at ApointTest.getData(ApointTest.java:84)
            at ApointTest.init(ApointTest.java:53)
            at sun.applet.AppletPanel.run(AppletPanel.java:424)
            at java.lang.Thread.run(Thread.java:619)
    java.lang.NullPointerException
            at ApointTest.printData(ApointTest.java:95)
            at ApointTest.init(ApointTest.java:62)
            at sun.applet.AppletPanel.run(AppletPanel.java:424)
            at java.lang.Thread.run(Thread.java:619)
    and my applet code is like:-
    Java Code:
    String uri = "http://localhost:8080/myapplication";
    when i run my application in eclipse it works fine but when i try to access in browser it give me this error.

    all jar which i am using in my application are signed.

    thanks
    Anchit

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: getting error when applet access port of tomcat.

    Is there more than one jar file?

    For testing, can you make a small,simple program that tries to connect, put it in a jar file, sign that jar file and load it in the browser?

  3. #3
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    hi norm,

    yes i am working with 4 .jar file ....
    and i tried with small program .. but this not working.

    main thing is, i started tomcat and run application(is used to fetch data from database). i am get data by drafting URL in applet any use that URL to get data and display in database.

    i think this error about, access "localhost:8080" in applet program:-
    java.security.AccessControlException: access denied (java.net.SocketPermission l
    ocalhost:8080 connect,resolve)


    thanks for reply norm

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: getting error when applet access port of tomcat.

    How are you loading the html with the applet into the browser? What URL are you using in the browser?
    For testing the Socket permission problem, a small simple program would be the easiest. When you get that to work then you will be able to work on the real program.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    i try open this file by two ways:-
    1. by open this file locally(just double click on .html file name which i write the code below) // here it give me warning message because i am having some signed .jar file
    2. by open this file as "appletviewer http://localhost:8080/myapp/index1.html" // here i am getting error which i mention in my last post.
    my applet code :-
    file name :- index1.html
    Java Code:
    <body>
    
    <applet code="Test1.class" archive="first.jar" height="200" width="200">
    
    </applet><br>
    </body>
    and code for test1.class is :-
    Java Code:
    public void init()
    	{
    
    String uri = "http://localhost:8080/myapp1/url_for_get_some_data";	    	
    // i am sending this url to other class which will fetch data from my application which is running on tomcat server
    // that application have some logic to retrieve data from database and pass this to applet and applet will show that data 
    //in browser or appletviewer
    	   }
    i hope this will help you to understand my problem.
    please let me know if you any problem to understand.

    thanks for reply norm.
    Last edited by anchitanc; 03-22-2012 at 01:58 PM.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: getting error when applet access port of tomcat.

    by open this file locally(just double click on .html file
    You need to load the html with the applet from the server using the http protocol.
    You are loading the file from a local disk using the file: protocol.

    An applet can only connect to a server it was loaded from. Loading it from a disk file is not connecting to a server.
    Use a URL with http://localhost:8080/htmlfilename.html to load the applet from the server.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    ya that is right .. got it ..
    but i am still getting same error.

    can you please suggest me how to use tomcat port in my program.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: getting error when applet access port of tomcat.

    How are you now loading the html page with the applet in the browser?
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    i tried with the both ..
    with browser :- not giving error and not a output.
    in appletviewer:- error only.

  10. #10
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    i tried same with JBOSS (put my application in JOSS which i was using with tomcat, with no change in applet and java code) also .. here i am getting correct output in browser without any error.
    and when i tried same thing with appletviewer i got this new error:-
    Java Code:
    appletviewer http://10.253.193.82:8080/myapp1/index1.html
    
    *** attempt to login ***
    
    java.lang.ExceptionInInitializerError
            at sun.misc.Unsafe.ensureClassInitialized(Native Method)
            at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAc
    cessorFactory.java:25)
            at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java
    :122)
            at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
            at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
            at java.lang.reflect.Field.getLong(Field.java:528)
            at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1614
    )
            at java.io.ObjectStreamClass.access$700(ObjectStreamClass.java:52)
            at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:425)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:413)
            at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)
            at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:547)
            at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:158
    3)
            at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
            at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:158
    3)
            at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
    732)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
            at test2.issueRequest(test2.java:210)
            at test2.login(test2.java:92)
            at test1.getData(test1.java:84)
            at test1.init(test1.java:53)
            at sun.applet.AppletPanel.run(test1.java:424)
            at java.lang.Thread.run(Thread.java:619)
            ... 28 more

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: getting error when applet access port of tomcat.

    i am getting correct output in browser without any error.
    I'd recommend that you use the browser.
    If you don't understand my response, don't ignore it, ask a question.

  12. #12
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    :) ya that is great option but ..... i need to use appletviewer.
    can please give me some idea about those errors. why i am getting?
    please suggest me if you have any idea about this.

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: getting error when applet access port of tomcat.

    Why does the code work in the browser and not in appletviewer? The error comes from the readObject() method call.
    Are they using the same version of java?
    If you don't understand my response, don't ignore it, ask a question.

  14. #14
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    yes...

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: getting error when applet access port of tomcat.

    Browser vs av
    If you don't understand my response, don't ignore it, ask a question.

  16. #16
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    i have no idea why i am seeing this error ....

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: getting error when applet access port of tomcat.

    I don't know why it works in the browser and fails in appletviewer if they use the same URL and the same version of java.
    If you don't understand my response, don't ignore it, ask a question.

  18. #18
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    thanks norm .... i will try to find out other solution.

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: getting error when applet access port of tomcat.

    Good luck. Be sure to come back and let us know what the problem was and how you solved it.
    If you don't understand my response, don't ignore it, ask a question.

  20. #20
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet access port of tomcat.

    hi norm,

    that problem has been resolved. by adding this statement in java.policy file

    grant {
    permission java.security.AllPermission;
    };

    and in my program i was using localhost in url and i started JBOSS as a run -b 0.0.0.0 (for access JBoss through ip address )


    thanks
    Anchit

Similar Threads

  1. getting error when applet try to access some jar file
    By anchitanc in forum Java Applets
    Replies: 21
    Last Post: 01-05-2012, 02:59 PM
  2. applet and mysql in jsp using tomcat servlets
    By gedas in forum Java Applets
    Replies: 4
    Last Post: 04-05-2011, 10:41 PM
  3. 'Admin port configuration not found' error in
    By javaquestions in forum IntelliJ IDEA
    Replies: 0
    Last Post: 10-26-2009, 08:30 PM
  4. Signed Applet to write on LPT1 port - permission error
    By ConvoyTh in forum Java Applets
    Replies: 0
    Last Post: 07-02-2009, 11:56 AM
  5. Access Serial port
    By hasani6leap in forum Advanced Java
    Replies: 0
    Last Post: 02-12-2008, 10:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •