Java 未找到FOP类

Java 未找到FOP类,java,apache-fop,Java,Apache Fop,大家好,我正在尝试使用FOP将xml文件转换为pdf,但我一直遇到错误,现在我遇到了错误 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlgraphics/io/ResourceResolver at org.apache.fop.apps.FopConfParser.<init>(FopConfParser.java:122) at org.apache.fop.apps.FopFac

大家好,我正在尝试使用FOP将xml文件转换为pdf,但我一直遇到错误,现在我遇到了错误

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlgraphics/io/ResourceResolver
at org.apache.fop.apps.FopConfParser.<init>(FopConfParser.java:122)
at org.apache.fop.apps.FopFactory.newInstance(FopFactory.java:132)
at run.ExampleFO2PDF.main(ExampleFO2PDF.java:62)

我找不到
xmlgraphics
jar,但找到了。这就是你的意思吗


从我上面链接的页面来看,它似乎不包含
org.apache.xmlgraphics.io
包,但它确实包含
org.apache.xmlgraphics.util.io
。也许你的意思是这个?

我想你已经明白了这一点-但不管怎样,对于那些没有: FOP1.1的主干确实有引用xmlgraphics.io.ResourceResolver的FopConfParser

xmlgraphics commons的主干也有ResourceResolver:


因此,作为一个解决方案,更新到主干!快乐编码:)

旧线程,为完整性增加了一点

我在从0.92b更新到FOP1.1时遇到了类似的问题,没有找到MimeConstants类

我通过在我使用的FOP版本的源发行版中使用xmlgraphics commons版本解决了这个问题

尝试使用构建FOP版本时使用的xmlgraphics commons jar,该jar可以在FOP源发行版的lib文件夹中找到

abstract interface org.apache.fop.apps.MimeConstants implements org.apache.xmlgraphics.util.MimeConstants

org.apache.xmlgraphics.util.MimeConstants
属于xmlgraphics-commons-1.5.jar。只需在类路径中包含xmlgraphics-commons-1.5.jar就可以解决问题。

非常旧的线程,但我花了很长时间来解决这个问题,所以从FOP 1.1迁移到2.0在pom中做了如下更改:

发件人:


org.apache.xmlgraphics
fop
1.1
致:

org.apache.xmlgraphics
fop
2
org.apache.xmlgraphics
xmlgraphics commons
org.apache.xmlgraphics
蜡染
org.apache.xmlgraphics
蜡染桥
org.apache.xmlgraphics
蜡染织物
org.apache.xmlgraphics
蜡染gvt
org.apache.xmlgraphics
蜡染转码器
org.apache.xmlgraphics
蜡染延伸
org.apache.xmlgraphics
蜡染分机
org.apache.xmlgraphics
xmlgraphics commons
2.0.1
org.apache.xmlgraphics
蜡染
1.8
org.apache.xmlgraphics
蜡染桥
1.8
org.apache.xmlgraphics
蜡染织物
1.8
org.apache.xmlgraphics
蜡染gvt
1.8
org.apache.xmlgraphics
蜡染转码器
1.8
org.apache.xmlgraphics
fop
org.apache.xmlgraphics
蜡染延伸
1.8
org.apache.xmlgraphics
蜡染分机
1.8

请告诉我们您是如何运行代码的。看起来类路径中没有xmlgraphics。您能描述一下您更改了什么吗?变化涉及从一点到另一点的移动。我只看到你改变的结果。很高兴看到一个增量。对不起,我认为这很明显,
org.apache.xmlgraphics fop 1.1
为了完成这个主题,我还更改了fopFactory创建-从:
fopFactory fopFactory=fopFactory.newInstance();FOPFFactory.SetStritValidation(假);fopFactory.getFontManager()
to
FopFactoryBuilder=newfopfactorybuilder(新文件(“.”.toURI());建造商。设置TrictFovalidation(假);FopFactory FopFactory=builder.build()
根据问题,缺少的类是
org/apache/xmlgraphics/io/resourcesolver
。这不包含在
xmlgraphics-commons-1.5.jar中,因此包含此jar不会解决OP的问题。
abstract interface org.apache.fop.apps.MimeConstants implements org.apache.xmlgraphics.util.MimeConstants
<dependency>
    <groupId>org.apache.xmlgraphics</groupId> 
    <artifactId>fop</artifactId> 
    <version>1.1</version>
</dependency>