wood burning stoves 2.0*
The moose likes Applets and the fly likes Access Denied when trying to print Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Access Denied when trying to print" Watch "Access Denied when trying to print" New topic
Author

Access Denied when trying to print

Karen Gomes
Ranch Hand

Joined: Aug 25, 2003
Posts: 60
Hello Friends,

I'm trying to print a pdf document from an applet. I have managed to get it to the point that it detects the default [as well as all other network] printers. However, it gives me an Access Denied error, that I have no idea of how to tackle.

The url that I try to get the pdf doc from: http://shan:7001/printPDFApp/New_Test.pdf
"shan" is my machine name

Here's the Java console output:
======================================================
initializing...
starting...
pdfUrl after = http://shan:7001/printPDFApp/New_Test.pdf
initialising pdfprinter
pdfprintercom.activetree.pdfprint.AtPdfStreamPrinter@da2cef
defaultPrintService : Win32 Printer : Lexmark Z25-Z35
found printer: Win32 Printer : \\ocdc2\ALPHA
found printer: Win32 Printer : Lexmark Z25-Z35 (Copy 2)
found printer: Win32 Printer : Lexmark Z25-Z35
finally found printers: 3
printerSupportedPageFormat.getOrientation() : 1
java.lang.RuntimeException: access denied (java.net.SocketPermission shan:7001 connect,resolve)
at com.activetree.pdfprint.AtPdfStreamPrinter$a$a.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.RuntimeException: access denied (java.net.SocketPermission shan:7001 connect,resolve)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
=====================================================================
Any help will be appreciated.

Thanks
Karen
[ February 28, 2005: Message edited by: Karen Gomes ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Applets have a number of security restrictions to protect computers from malicious code. You may want to try putting your print functionality on a server or look into digitally signing your applet or developing an application with Java WebStart (distribute like an applet, run like an application).


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Karen Gomes
Ranch Hand

Joined: Aug 25, 2003
Posts: 60
I have signed the applet. Is there a way to find out what the problem is.
Also is using Java Web start the only way out of this?

Thanks
Karen
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Originally posted by Karen Gomes:
I have signed the applet.

Well why didn't you mention that?

Originally posted by Karen Gomes:

Is there a way to find out what the problem

The problem is right here:

You don't have permission to access port 7001 on the local computer.

Originally posted by Karen Gomes:

Also is using Java Web start the only way out of this?

No. I was mentioning WebStart as one of your options. I prefer it to using applets just because it doesn't depend on a browser. You still need to jar and sign your code.
About your problem: Your code is jar'd up right? Do you have any other copies of your .class file floating around? They may get picked up in the classpath before your signed versions.
Don't forget to re-start your browser and clear the cache after each test run. The browser will cache JAR files and the JVM may not reload classes just because you changed the remote JAR.
Are you creating a policy file?
Karen Gomes
Ranch Hand

Joined: Aug 25, 2003
Posts: 60
Sorry abt missing the info on signed applet. Yes, I jar up my applet, and sign it. I had created a policy file earlier, but deleted them all now and also every other version of the applet jar on my machine but the one on the server. Also clear the Browser cache everytime.

I do get the accept/deny the certificate dialog box. Any idea what else could be going wrong?
I have created a self signed certificate using keytool, could that be a cause for it?


I still get these messages in the logs:
/// Logs when attempting to connect to localhost

java.lang.RuntimeException: access denied (java.security.SecurityPermission putProviderProperty.BC)
at com.activetree.pdfprint.AtPdfStreamPrinter$a$a.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.RuntimeException: access denied (java.security.SecurityPermission putProviderProperty.BC)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)



/// Logs when attempting to connect to some remote site

java.lang.RuntimeException: access denied (java.net.SocketPermission www.hitmill.com:80 connect,resolve)
at com.activetree.pdfprint.AtPdfStreamPrinter$a$a.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.a(Unknown Source)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.RuntimeException: access denied (java.net.SocketPermission www.hitmill.com:80 connect,resolve)
at com.activetree.pdfprint.AtPdfStreamPrinter.print(Unknown Source)
at activetree.pdfprint.PdfPrintFromURLApplet.start(PdfPrintFromURLApplet.java:100)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
stopping...
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

You may have better luck with the support forum for the software you are using.
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
Please can you email me the whole code ie Java source, classes and other source jar etc if you are using any. Send it at adilsec@yahoo.com

I will try to solve ur problem...

I have used the a policy file for my website and the applet there is working fine.

Thanx,

Maki Jav


Help gets you when you need it!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access Denied when trying to print
 
Similar Threads
signed applet throws AccessControlException
Exception while running applets
HELP : SocketPermission proxy-iap...
RMI, access denied
MYSql Driver ClassNotFound Exception