1

When I am running this code, I am getting following Exception. Running fine with only PDFBox jar. getting this exception Lucene-PDFBox jar only.

 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.pdfbox.lucene.LucenePDFDocument;
 import org.apache.pdfbox.multipdf.Splitter;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.common.PDStream;

 Document doc1 = LucenePDFDocument.getDocument(new 
 File("C:\\Users\\E075551\\Downloads\\resume.pdf"));
 System.out.println("END-------"+doc1.getFields().get(1));

Throwing java.lang.ClassNotFoundException: org.apache.pdfbox.exceptions.CryptographyException

Traces are :

java.lang.NoClassDefFoundError: org/apache/pdfbox/exceptions/CryptographyException
    at com.mastercard.pts.integrated.issuing.utils.PDFUtils.getContentRow(PDFUtils.java:118)
    at com.mastercard.pts.integrated.issuing.workflows.customer.cardmanagement.ReportVerificationWorkflow.getReportContent(ReportVerificationWorkflow.java:77)
    at com.mastercard.pts.integrated.issuing.workflows.customer.cardmanagement.ReportVerificationWorkflow.verifyGenericReport(ReportVerificationWorkflow.java:70)
    at com.mastercard.pts.integrated.issuing.workflows.customer.cardmanagement.ReportVerificationWorkflow.verifyGenericReport(ReportVerificationWorkflow.java:54)
    at com.mastercard.pts.integrated.issuing.workflows.customer.cardmanagement.ReportVerificationWorkflow$$FastClassBySpringCGLIB$$c86b4458.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
    at com.mastercard.pts.integrated.issuing.aop.ReportingAspect.proceedAndReportStep(ReportingAspect.java:47)
    at com.mastercard.pts.integrated.issuing.aop.ReportingAspect.proceedStep(ReportingAspect.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:620)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:609)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
    at com.mastercard.pts.integrated.issuing.workflows.customer.cardmanagement.ReportVerificationWorkflow$$EnhancerBySpringCGLIB$$ab939610.verifyGenericReport(<generated>)
    at com.mastercard.pts.integrated.issuing.steps.customer.cardmanagement.ReportVerificationSteps.validateGenericReport(ReportVerificationSteps.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jbehave.core.steps.StepCreator$ParametrisedStep.perform(StepCreator.java:733)
    at org.jbehave.core.embedder.PerformableTree$FineSoFar.run(PerformableTree.java:346)
    at org.jbehave.core.embedder.PerformableTree$PerformableSteps.perform(PerformableTree.java:1088)
    at org.jbehave.core.embedder.PerformableTree$AbstractPerformableScenario.performRestartableSteps(PerformableTree.java:953)
    at org.jbehave.core.embedder.PerformableTree$NormalPerformableScenario.perform(PerformableTree.java:992)
    at org.jbehave.core.embedder.PerformableTree$PerformableScenario.perform(PerformableTree.java:902)
    at org.jbehave.core.embedder.PerformableTree$PerformableStory.performScenarios(PerformableTree.java:825)
    at org.jbehave.core.embedder.PerformableTree$PerformableStory.perform(PerformableTree.java:798)
    at org.jbehave.core.embedder.PerformableTree.performCancellable(PerformableTree.java:422)
    at org.jbehave.core.embedder.PerformableTree.perform(PerformableTree.java:393)
    at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:292)
    at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.pdfbox.exceptions.CryptographyException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 44 more
monty
  • 108
  • 1
  • 2
  • 7
  • Can you please some more code like the entire class here? Looks like it cannot somehow find your `CryptographyException`, can you check if this is available in your repository! – robot_alien Jul 23 '18 at 15:13
  • I do not need to declare the CryptographyException. Document.getFields() throwing this exception. – monty Jul 23 '18 at 15:18
  • How are you managing your dependencies? – Compass Jul 23 '18 at 15:23
  • ok, somewhere in your `(PDFUtils.java:118)` is there anything hinting towards something that is required but is missing? (or probably the one's that are utilizing this util class of yours?) To me I'm sure it looks like the dependency is missing this `org.apache.pdfbox.exceptions.CryptographyException` – robot_alien Jul 23 '18 at 15:23
  • @Compass Through Maven. and it doesn't show any missing library. – monty Jul 23 '18 at 15:26
  • @robot_alien Nope it is not hinting towards something. This can be a issue in Lucene-PDFBox jar. – monty Jul 23 '18 at 15:27
  • please do a complete clean build on your maven project and refresh your IDE in that case... – robot_alien Jul 23 '18 at 15:27
  • @robot_alien did that still getting the same Exception. – monty Jul 23 '18 at 15:32
  • 2
    Can we get the pom? I believe it might be an unmapped transitive dependency. – Compass Jul 23 '18 at 15:43
  • LucenePDFDocument is from PDFBox 1.8 and it is dependent of pdfbox. – Tilman Hausherr Jul 23 '18 at 17:53

0 Answers0