Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5993397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:40:10+00:00 2026-05-22T23:40:10+00:00

I am generating a PDF file via fop 1.0 out of a java library.

  • 0

I am generating a PDF file via fop 1.0 out of a java library. The unit tests are running fine and the PDF is rendered as expected, including an external graphic:

<fo:external-graphic content-width="20mm" src="url('images/image.png')" />

If I render this within a Java EE application in glassfish 3.1, I always get the following error:

Image not found. URI: images/image.png. (No context info available)

I double-checked whether the image is available. It is available within the .jar file in the .ear file and should therfore be available by the ClasspathUriResolver. This is a code-snipplet of how I setup the fop-factory:

FopFactory fopFactory = FopFactory.newInstance();
URIResolver uriResolver = new ClasspathUriResolver();
fopFactory.setURIResolver(uriResolver);
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
...

I also assigned the URI resolver to the TransformerFactory and the Transformer with no success. Would be great if someone can help me out.

— Wintermute

Btw: the ClasspathUriResolver() looks like this

public class ClasspathUriResolver implements URIResolver {

  @Override
  public Source resolve(String href, String base) throws TransformerException {
    Source source = null;
    InputStream inputStream = ClassLoader.getSystemResourceAsStream(href);
    if (inputStream != null) {
      source = new StreamSource(inputStream);
    }
    return source;
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:40:10+00:00Added an answer on May 22, 2026 at 11:40 pm

    You consider a different class loader then ClassLoader.getSystemResourceAsStream(href);

    Try InputStream inputStream = getClass().getResourceAsStream(href); or something else, maybe.

    Does it work, then?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am writing some code in vb.net that will be generating a pdf file.
I am writing some XML -> PDF generating templates in Apache FOP for an
I'm automatically generating a PDF-file with Platypus that has dynamic content. This means that
I am facing a problem with FPDF while generating the PDF file with images
I'm working with generating .pdf's from PHP using this library: http://www.fpdf.org/ I am currently
i m generating a pdf file from the contents of email and that email
I have a button that is generating a PDF file on the server and
I've got a C# page that's generating a PDF file and returning it to
We are running tomcat, and we are generating pdf files on the fly. I
I can't figure out why I'm getting an extra page in my PDF file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.