0

I have code ;

private void convert(ByteArrayInputStream byteArrayInputStream) {
        try {
            PDDocument pdf = PDDocument.load(byteArrayInputStream);
            PDFDomTree parser = new PDFDomTree();
            Document dom = parser.createDOM(pdf);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Return NoSuchMethodError when this line;

Document dom = parser.createDOM(pdf);

Error :

NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;

My jar list :...

activation-1.1
animal-sniffer-annotations-1.17
animal-sniffer-annotations-1.18
ant-1.6.5
antlr-2.7.7
antlr4-runtime-4.5.3
aopalliance-1.0
asm-5.0.3
asm-commons-5.0.3
asm-tree-5.0.3
asm-util-5.0.3
atmosphere-runtime-2.4.24.vaadin1
autocomplete-0.2.4
bcprov-jdk15-1.45
calendar-component-2.0.1
cas-client-core-3.3.3
checker-qual-2.5.2
checker-qual-2.8.1
classmate-1.3.0
colt-1.2.0
commons-codec-1.6
commons-collections-3.1
commons-collections-3.2.2
commons-collections4-4.1
commons-httpclient-3.1
commons-io-2.5
commons-lang-2.1
commons-lang3-3.0
commons-logging-1.1.3
commons-net-3.6
core-2.4.0
core-3.3.0
cssbox-4.15
cssparser-0.9.18
curvesapi-1.04
dom4j-1.6.1
ehcache-2.10.3
EnlilWebClient-1
error_prone_annotations-2.2.0
error_prone_annotations-2.3.2
esapi-2.0GA
exporter-2.0.0
failureaccess-1.0.1
failureaccess-1.0
FastInfoset-1.2.13
flute-1.3.0.gg2
fontbox-2.0.4
FontVerter-1.2.22
gelfclient-1.4.0
gentyref-1.2.0.vaadin1
gmbal-3.1.0-b001
gmbal-api-only-3.1.0-b001
gson-2.8.1
guava-28.1-jre
gwt-dev-2.8.2
gwt-elemental-2.8.2
gwt-user-2.8.2
ha-api-3.1.9
hamcrest-core-1.3
hibernate-commons-annotations-5.0.1.Final
hibernate-core-5.2.12.Final
hibernate-ehcache-5.2.12.Final
hibernate-jpa-2.1-api-1.0.0.Final
hibernate-validator-5.1.0.CR1
htmlunit-2.19
htmlunit-core-js-2.17
httpclient-4.3.1
httpcore-4.3
httpmime-4.5.1
icu4j-50.1.1
inputmask-1.0.2
istack-commons-runtime-2.19
itextpdf-5.5.10
j2objc-annotations-1.1
j2objc-annotations-1.3
jackson-annotations-2.5.0
jackson-core-2.4.1
jackson-databind-2.5.2
jackson-datatype-hibernate4-2.4.1
jai-imageio-core-1.3.1
jandex-2.0.3.Final
javaee-api-8.0
javaee-web-api-8.0
javase-2.4.0
javase-3.3.0
javassist-3.20.0-GA
javax.annotation-api-1.2
javax.mail-1.6.0
javax.servlet-api-3.1.0
javax.xml.rpc-api-1.1
javax.xml.soap-api-1.3.7
jaxb1-impl-2.2.4-1
jaxb-api-2.2.12-b140109.1041
jaxb-core-2.2.10-b140802.1033
jaxb-impl-2.2.10-b140802.1033
jaxrpc-api-1.1
jaxrpc-impl-1.1.3_01
jaxrpc-spi-1.1.3_01
jaxws-api-2.2.11
jaxws-rt-2.2.10
jboss-logging-3.3.0.Final
jboss-transaction-api_1.2_spec-1.0.1.Final
jcip-annotations-1.0
jcommander-1.48
jcommon-1.0.23
jersey-bundle-1.19
jersey-core-1.19
jersey-multipart-1.19
jersey-server-1.19
jetty-continuation-9.4.8.v20171121
jfreechart-1.0.19
jmac-1.0-rev-1
joda-time-1.6.2
jsinterop-annotations-1.0.2
jsinterop-annotations-1.0.2-sources
json-simple-1.1.1
jsoup-1.11.2
jsr105-api-1.0.1
jsr105-impl-1.0.2
jsr181-api-1.0-MR1
jsr305-1.3.9
jsr305-3.0.2
jsr311-api-1.1.1
jstyleparser-3.3
jul-to-slf4j-1.6.1
junit-4.11
kerberos-wss-extension-1.0
log4j-1.2.17
log4j-over-slf4j-1.6.1
mail-1.4.5
management-api-3.2.1-b001
messagebox-4.0.21
metro-cm-api-2.3.1
metro-commons-2.3.1
metro-config-api-2.3.1
metro-runtime-api-2.3.1
mimepull-1.9.4
nekohtml-1.9.22
netty-all-4.0.29.Final
not-yet-commons-ssl-0.3.9
ojdbc-8
opensaml-2.5.1-1
openws-1.4.2-1
PasswordEncoder-0.0.1
pdf2dom-1.8
pdfbox-2.0.4
poi-3.16
poi-ooxml-3.16
poi-ooxml-schemas-3.16
policy-2.4
popupbutton-3.0.0
popupextension-1.0.1
product-tour-0.5
reflections-0.9.11
resolver-20050927
saaj-impl-1.3.25
sac-1.3
saml-jaxb10-bindings-1.0
serializer-2.7.1
slf4j-api-1.7.1
slf4j-simple-1.7.25
soaptcp-api-2.3.1
spring-aop-4.3.9.RELEASE
spring-beans-4.3.9.RELEASE
spring-context-4.3.9.RELEASE
spring-core-4.3.9.RELEASE
spring-expression-4.3.9.RELEASE
spring-security-cas-4.2.3.RELEASE
spring-security-config-4.2.3.RELEASE
spring-security-core-4.2.3.RELEASE
spring-security-web-4.2.3.RELEASE
spring-web-4.3.9.RELEASE
stax2-api-3.1.1
stax-api-1.0.1
stax-ex-1.7.7
streambuffer-1.5.3
tapestry-4.0.2
timerextension-0.2.1
unbescape-1.1.6.RELEASE
vaadin-autocomplete-1.1.1
vaadin-charts-4.0.0
vaadin-charts-model-4.0.0
vaadin-client-8.5.1
vaadin-client-compiled-8.5.1
vaadin-client-compiler-8.5.1
vaadin-combobox-multiselect-2.6
vaadin-context-menu-2.1.0
vaadin-onoffswitch-1.1.0
vaadin-push-8.5.1
vaadin-sass-compiler-0.9.13
vaadin-scrollable-panel-2.0
vaadin-server-8.5.1
vaadin-shared-8.5.1
vaadin-slf4j-jdk14-1.6.1
vaadin-sliderpanel-2.2.0
vaadin-spring-3.1.0
vaadin-themes-8.5.1
validation-api-1.0.0.GA-sources
validation-api-1.1.0.Final
velocity-1.5
webservices-api-2.3.1
webservices-rt-2.3.1
webservices-tools-2.3.1
websocket-api-9.2.13.v20150730
websocket-client-9.2.13.v20150730
websocket-common-9.2.13.v20150730
woodstox-core-asl-4.2.0
wsit-api-2.3.1
wsit-impl-2.3.1
wsmc-api-2.3.1
wsrm-api-2.3.1
wssx-api-2.3.1
wstx-api-2.3.1
xalan-2.7.1
xercesImpl-2.10.0
xercesImpl-2.12.0
xml-apis-1.4.01
xmlbeans-2.6.0
xml-resolver-1.2
xmlsec-1.4.4
xmltooling-1.3.2-1

I have lots of library.But I dont know which one of these libraries may be conflict.My project is large project.I hope someone know this problem.Thank you..

Hasan Kaan TURAN
  • 391
  • 2
  • 13
  • 4
    Hi Hasan, please add full stacktrace. From this error I would suggest, that PDF2DOM depends on the Google Guava library and you or some other component also depends on Google Guava library, but different version. I would suggest to check, that your whole project depends only on one version of Guava. – Michal Krasny Nov 29 '19 at 12:31
  • I updated last version but still same error.And I have only one Guava lib – Hasan Kaan TURAN Nov 29 '19 at 13:32
  • I updated question with jar List – Hasan Kaan TURAN Nov 29 '19 at 14:41

1 Answers1

1

As far as I checked, when Maven resolves more dependencies to the same library, but different versions, it takes the first version it finds and ignores the others. In your case, you probably explicitly declared a dependency to Guava 28.1. However the pdfbox requires a different version, which you can't see amongs your libraries, because it is ignored. I suggest you to:

  1. Remove as much dependencies from your project as you can, leave there only the dependency to pdfbox.
  2. Check, what version it needs. The command mvn dependency:tree -Dverbose might help you.
  3. Revert your dependencies to the original state, set the Guava dependency to that version.
  4. Pray, that another library doesn't need different version of Guava as well.

Edit: You might find this thread usefull. It talks about ignoring the other versions of the same jar.

maven dependency plugin ignores dependency versions?

Edit 2: In my case, the Guava 15.0 was needed.

Michal Krasny
  • 5,434
  • 7
  • 36
  • 64