centic9 / poi-on-android

A sample project that shows how Apache POI can be used in an Android application
Apache License 2.0
357 stars 89 forks source link

java.lang.NoSuchMethodException: org.openxmlformats.schemas.wordprocessingml.x2006.main.impl.CTPictureBaseImpl #78

Closed AhmadIzaz closed 4 years ago

AhmadIzaz commented 4 years ago

I am trying to get page count of docx file but by following code

if (ext.equals("docx")) {
                File file = new File(filePath);
                OPCPackage opcPackage = OPCPackage.open(file, PackageAccess.READ);
                XWPFDocument xwpfDocument = new XWPFDocument(opcPackage);
                sheetCount = xwpfDocument.getProperties().getExtendedProperties().getPages();
            }

but getting this exception

java.lang.NoSuchMethodException: org.openxmlformats.schemas.wordprocessingml.x2006.main.impl.CTPictureBaseImpl.<init> [interface org.apache.xmlbeans.SchemaType, boolean]
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at java.lang.Class.getConstructor0(Class.java:2328)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at java.lang.Class.getDeclaredConstructor(Class.java:2167)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getJavaImplConstructor2(SchemaTypeImpl.java:1817)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createUnattachedSubclass(SchemaTypeImpl.java:1961)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createUnattachedNode(SchemaTypeImpl.java:1950)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createElementType(SchemaTypeImpl.java:1051)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.values.XmlObjectBase.create_element_user(XmlObjectBase.java:938)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.store.Xobj.getUser(Xobj.java:1675)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.store.Cur.getUser(Cur.java:2659)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.store.Cur.getObject(Cur.java:2652)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.store.Cursor._getObject(Cursor.java:995)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.xmlbeans.impl.store.Cursor.getObject(Cursor.java:2904)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.poi.xwpf.usermodel.XWPFDocument.onDocumentRead(XWPFDocument.java:162)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:169)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:112)
2020-04-16 15:02:45.705 26436-26436/com..W/System.err:     at com.safarifone.im.core.manager.WaafiMSFileManager.getWordPageCount(MSFileManager.java:128)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at com.safarifone.im.adapters.IMChatAdapter.setUpMsgFile(IMChatAdapter.java:1450)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at com.safarifone.im.adapters.IMChatAdapter.onBindViewHolder(IMChatAdapter.java:266)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5752)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6019)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:587)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1888)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at androidx.recyclerview.widget.RecyclerView$1.run(RecyclerView.java:407)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at android.view.Choreographer.doCallbacks(Choreographer.java:761)
2020-04-16 15:02:45.706 26436-26436/com.safarifone.waafitest W/System.err:     at android.view.Choreographer.doFrame(Choreographer.java:693)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at android.os.Handler.handleCallback(Handler.java:873)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
2020-04-16 15:02:45.706 26436-26436/com..W/System.err:     at android.os.Looper.loop(Looper.java:214)
2020-04-16 15:02:45.707 26436-26436/com..W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7078)
2020-04-16 15:02:45.707 26436-26436/com..W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-04-16 15:02:45.707 26436-26436/com..W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
2020-04-16 15:02:45.707 26436-26436/ W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
centic9 commented 4 years ago

I could not reproduce this with a quick test, this sounds like you include some additional third party library which provides old versions of these classes instead of only the shadow-jar from this project.

centic9 commented 4 years ago

Couldn't reproduce this and no response for quite some time, thus closing this for now.