• 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

Getting Error When Using PDFBox to Merge Files

 
Ranch Hand
Posts: 2223
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my following code I get "FAIReportToJasper: jcifs.smb.SmbException: Access is denied."
On this line of code: out = new BufferedOutputStream(new SmbFileOutputStream( new SmbFile(pdffilePathMerged, cifsContext() )));

 
Saloon Keeper
Posts: 27882
197
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ewww. Those are some ugly URL path constructors there. I'd probably look for a cleaner approach myself.

But the key error is "Access is denied". That means that irrespective of whether we're talking Java, PDFs, or anything else that the userid under which this app doesn't have necessary filesystem access rights.

Most likely cause is that one (or more) of your URLs didn't form the way you thought it would and I'd add some log messages to see what you're actually getting.
 
Saloon Keeper
Posts: 7601
177
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mentioning PDFBox is likely a red herring when the exception points to an issue surfaced by jCifs.

Is "pdffilePathMerged" something valid that SMB can make sense of?

Does the process owner have access to whatever file that is?

Note that "access denied" can mean that the file/path doesn't exist.

Are you using a current SMB implementation like https://github.com/AgNO3/jcifs-ng?
 
Steve Dyke
Ranch Hand
Posts: 2223
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Most likely cause is that one (or more) of your URLs didn't form the way you thought it would and I'd add some log messages to see what you're actually getting.



This is what the System.out.println is showing:
FAIReportToJasper: pdffilePathMerged: smb://sgai-fs02.corp.zodiac.lan/qmsattachments$/QMSAttachments/Temp/FAIReportMerged_4248917.pdf

My scenario is I write three pdf files to a particular directory. Then I want to merge them into one pdf file.
This is all done on the same share. The three files are written just fine and accessible using HTTP.
I also use the same cifsContext parameter for all the smb access.

So I am trying to understand why I can write the initial three files to the share but not the merged file.

 
Steve Dyke
Ranch Hand
Posts: 2223
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Are you using a current SMB implementation like https://github.com/AgNO3/jcifs-ng?



Using jcifs-2.1.35.
I use this for my entire application with no issues.
This is just the first time I am attempting to use the merge utility.
 
Tim Holloway
Saloon Keeper
Posts: 27882
197
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing to note.

You'll probably get better performance if you create your PDF merge to a local temporary file and then copy it to the network share.
 
Steve Dyke
Ranch Hand
Posts: 2223
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like most of my issues that take the most of my time to figure out, this one took about 5 hours and the help from this forum group.
The first time I tried the code a blank file was created with my merge file name.
The code failed but I did not realize the blank file had been created.
So every attempt I made thereafter, changing code to test, gave me the Access Denied message.
I was attacking the wrong source. After I removed the blank file, everything started working as expected.
 
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic