• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Access Denied when trying to print

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Karen Gomes
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may have better luck with the support forum for the software you are using.
 
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic