I need your help to resolve a conflict between Tapestry and JaxB. The error is :
com.sun.xml.stream.ZephyrParserFactory cannot be cast to org.codehaus.stax2.XMLInputFactory2
I 开发者_Python百科find a way to resolve it, but it is for jetty : http://tynamo.org/tapestry-resteasy+guide
The solution seems to be to add a system properties to declare :
javax.xml.stream.XMLInputFactory = com.ctc.wstx.stax.WstxInputFactory
But i don't know how to do this for Tomcat. I try to do it int he web.xml like :
<env-entry>
<env-entry-name>
javax.xml.stream.XMLInputFactory
</env-entry-name>
<env-entry-value>
com.ctc.wstx.stax.WstxInputFactory
</env-entry-value>
<env-entry-type>
com.ctc.wstx.stax.WstxInputFactory
</env-entry-type>
</env-entry>
without success...
I am also aware for another solution :)
thx for helping me.
The <env-entry>
properties are accessible via JNDI, and not as system properties, so that won't work. System properties must be specified on the command line when starting the Java VM.
How do you start your tomcat? If it is from the command line, try adding this snippet to JAVA_OPTS:
java -Djavax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory [...]
You should be able to do that either as an environment variable (Unix: export JAVA_OPTS='-Djavax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory'
, Windows: SET JAVA_OPTS='-Djavax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory'
) or in the Tomcat startup script itself (catalina.sh/catalina.bat).
If you start Tomcat from Eclipse, you can add the parameter via Debug Configurations | JRE | VM Arguments. Just paste -Djavax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory
and you're good.
Edit based on comment: AFAIK, you cannot specify system properties in web.xml, sorry.
An idea: You can set system properties programmatically. Maybe you could add a call to System.setProperty() in your Tapestry application module. It will have to be executed before JAXB initializes.
精彩评论