• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet Error using URLConnection

 
JimLooney
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet written in Jess which runs fine as an applet, reads in text files from the server, etc. However, I have now modified it to use a URLConnection to send some data to a Perl cgi on my webserver and the cgi saves the data to a text file on the server. I am getting errors when trying to use the setDoOutput method of the URLConnection class. It appears to be a security conflict based on the errors I am seeing (see below). I can post my code here, but be aware it is in Jess, so may look odd to some. Any suggestions would be much appreciated.

Code snippet:
.....
(bind ?dataString (new String "THIS IS THE DATA STRING"))
(bind ?url (new URL "http://www.myserver.com/cgi-bin/jim/update.pl"))
(bind ?con (?url openConnection))
(set-member ?con doOutput TRUE)
......
I have more code after this where I want to set the Content Type, etc., but I have all that commented out because it's bombing when I try to set doOutput to TRUE.

For any JESS users, note that I also tried this (?con setDoOutput TRUE) with no luck.

Here's the error dump (long)(I've set bold the error that seems to be the problem maker):

Jess reported an error in routine call
while executing (call (engine) runUntilHalt)
while executing deffunction run-until-halt
while executing (run-until-halt).
Message: Called method threw an exception.
Program text: ( run-until-halt ) at line 970.
Nested exception is:
Error during execution
Jess reported an error in routine Funcall.execute
while executing (set-member ?con doOutput TRUE)
while executing (if (= (str-compare ?C beginner) 0) then (bind ?dataString (new String "THIS IS THE DATA STRING")) (bind ?url (new URL "http://staging30.acuityweb.com/cgi-bin/jim/update.pl")) (bind ?con (call ?url openConnection)) (set-member ?con doOutput TRUE) else (if (= (str-compare (str-cat ?C) intermediate) 0) then (save-facts "distanceIntermediate.txt") else (if (= (str-compare (str-cat ?C) advanced) 0) then (save-facts "distanceAdvanced.txt"))))
while executing defrule MAIN::saveCurrentProblem.
Message: Error during execution.
at jess.Funcall.execute(Unknown Source)
at jess.FuncallValue.resolveValue(Unknown Source)
at jess.dw.call(Unknown Source)
at jess.ep.a(Unknown Source)
at jess.Funcall.execute(Unknown Source)
at jess.Defrule.a(Unknown Source)
at jess.Activation.if(Unknown Source)
at jess.a8.a(Unknown Source)
at jess.a8.for(Unknown Source)
at jess.a8.do(Unknown Source)
at jess.Rete.runUntilHalt(Unknown Source)
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:324)
at jess.v.call(Unknown Source)
at jess.ep.a(Unknown Source)
at jess.Funcall.execute(Unknown Source)
at jess.FuncallValue.resolveValue(Unknown Source)
at jess.Deffunction.call(Unknown Source)
at jess.ep.a(Unknown Source)
at jess.Funcall.execute(Unknown Source)
at jess.Jesp.a(Unknown Source)
at jess.Jesp.for(Unknown Source)
at jess.Jesp.parse(Unknown Source)
at jess.Jesp.parse(Unknown Source)
at jess.Main.execute(Unknown Source)
at jess.ConsoleApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:552)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.plugin.net.protocol.http)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1491)
at sun.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:190)
at java.lang.Class.checkMemberAccess(Class.java:1450)
at java.lang.Class.getField(Class.java:916)
at jess.af.call(Unknown Source)
at jess.ep.a(Unknown Source)
... 29 more
[ January 29, 2005: Message edited by: JimLooney ]
 
Joe Ess
Bartender
Posts: 9340
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applets are not allowed to connect to a server other than the one they are downloaded from, so if you are loading your servlet from somewhere other than www.myserver.com, that's your problem.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic