Using FOP and JBOSS EAP 7
When using JBOSS EAP 7 and Apache FOP, I randomly (?) get an exception when instantiating a new Fop object. When restarted, the code might work. I suspect a classload issue.
In a standalone situation (Eclipse) everything works fine. Some people suggest the FOP implementation is already loaded in a different security context. Beats me what that means.
Here is the Exception :
Caused by: java.lang.ClassCastException: org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory cannot be cast to org.apache.fop.util.ContentHandlerFactory
Sample code :
import java.io.File;
import javax.annotation.PostConstruct;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Force classloader to use FOP apache implementations first (experimental)
*/
@Singleton
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class InitBean {
private static final Logger logger = LogManager.getLogger(InitBean.class.getName());
public InitBean() {
super();
}
@PostConstruct
public void initClassloader() {
try {
FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, new NullOutputStream());
logger.debug("Created FOP handler {}", fop.getDefaultHandler().getClass().getName());
}
catch (Exception e) {
logger.error(e.getMessage());
}
}
}
Libraries : Apache fop 2.2; xalan-2.7.2; docx4j-export-fo-6.0.1; xmlgraphics-commons-2.2; xercesImpl-2.11.0; docx4j-6.0.1; serializer-2.7.2
How can I fix this issue?
fop docx4j jboss-eap-7
add a comment |
When using JBOSS EAP 7 and Apache FOP, I randomly (?) get an exception when instantiating a new Fop object. When restarted, the code might work. I suspect a classload issue.
In a standalone situation (Eclipse) everything works fine. Some people suggest the FOP implementation is already loaded in a different security context. Beats me what that means.
Here is the Exception :
Caused by: java.lang.ClassCastException: org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory cannot be cast to org.apache.fop.util.ContentHandlerFactory
Sample code :
import java.io.File;
import javax.annotation.PostConstruct;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Force classloader to use FOP apache implementations first (experimental)
*/
@Singleton
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class InitBean {
private static final Logger logger = LogManager.getLogger(InitBean.class.getName());
public InitBean() {
super();
}
@PostConstruct
public void initClassloader() {
try {
FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, new NullOutputStream());
logger.debug("Created FOP handler {}", fop.getDefaultHandler().getClass().getName());
}
catch (Exception e) {
logger.error(e.getMessage());
}
}
}
Libraries : Apache fop 2.2; xalan-2.7.2; docx4j-export-fo-6.0.1; xmlgraphics-commons-2.2; xercesImpl-2.11.0; docx4j-6.0.1; serializer-2.7.2
How can I fix this issue?
fop docx4j jboss-eap-7
add a comment |
When using JBOSS EAP 7 and Apache FOP, I randomly (?) get an exception when instantiating a new Fop object. When restarted, the code might work. I suspect a classload issue.
In a standalone situation (Eclipse) everything works fine. Some people suggest the FOP implementation is already loaded in a different security context. Beats me what that means.
Here is the Exception :
Caused by: java.lang.ClassCastException: org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory cannot be cast to org.apache.fop.util.ContentHandlerFactory
Sample code :
import java.io.File;
import javax.annotation.PostConstruct;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Force classloader to use FOP apache implementations first (experimental)
*/
@Singleton
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class InitBean {
private static final Logger logger = LogManager.getLogger(InitBean.class.getName());
public InitBean() {
super();
}
@PostConstruct
public void initClassloader() {
try {
FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, new NullOutputStream());
logger.debug("Created FOP handler {}", fop.getDefaultHandler().getClass().getName());
}
catch (Exception e) {
logger.error(e.getMessage());
}
}
}
Libraries : Apache fop 2.2; xalan-2.7.2; docx4j-export-fo-6.0.1; xmlgraphics-commons-2.2; xercesImpl-2.11.0; docx4j-6.0.1; serializer-2.7.2
How can I fix this issue?
fop docx4j jboss-eap-7
When using JBOSS EAP 7 and Apache FOP, I randomly (?) get an exception when instantiating a new Fop object. When restarted, the code might work. I suspect a classload issue.
In a standalone situation (Eclipse) everything works fine. Some people suggest the FOP implementation is already loaded in a different security context. Beats me what that means.
Here is the Exception :
Caused by: java.lang.ClassCastException: org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory cannot be cast to org.apache.fop.util.ContentHandlerFactory
Sample code :
import java.io.File;
import javax.annotation.PostConstruct;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Force classloader to use FOP apache implementations first (experimental)
*/
@Singleton
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class InitBean {
private static final Logger logger = LogManager.getLogger(InitBean.class.getName());
public InitBean() {
super();
}
@PostConstruct
public void initClassloader() {
try {
FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, new NullOutputStream());
logger.debug("Created FOP handler {}", fop.getDefaultHandler().getClass().getName());
}
catch (Exception e) {
logger.error(e.getMessage());
}
}
}
Libraries : Apache fop 2.2; xalan-2.7.2; docx4j-export-fo-6.0.1; xmlgraphics-commons-2.2; xercesImpl-2.11.0; docx4j-6.0.1; serializer-2.7.2
How can I fix this issue?
fop docx4j jboss-eap-7
fop docx4j jboss-eap-7
edited Nov 13 '18 at 0:39
James R. Perkins
12.4k3348
12.4k3348
asked Nov 5 '18 at 16:25
Luc De KeselLuc De Kesel
13
13
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53158351%2fusing-fop-and-jboss-eap-7%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53158351%2fusing-fop-and-jboss-eap-7%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown