org/dom4j/DocumentException - java

Good morning every body ,
I have java code that alllows me to create an excel file from xml flie.. But it can not create correctly the file, i have this exception that I do not inderstand its meaning :
Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.apache.poi.openxml4j.opc.Package.init(Package.java:145)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:132)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:67)
at org.apache.poi.openxml4j.opc.Package.create(Package.java:271)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.newPackage(XSSFWorkbook.java:245)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:145)
at escel1.Escel1.main(Escel1.java:104)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
If someone knows what that means , it will be very helpfull for me :)

I have found the key about your problem. you shouldn't add the jar file of dom4j-1.6.1-sources.jar but dom4j-1.x.jar into the project library. Because the jar file's name with sources is pure java file(xx.java), that means it's not compiled at all.
then rebuild your project, it'll work fine.
Hope to help you :)

Apache POI have a handy page listing all the components and their dependencies, you should start by reading that!
Secondly, if you downloaded the binary zip/tarball of Apache POI, then it comes with all of the dependencies you need in the /lib/ and /ooxml-lib/ directories. Make sure you include all the dependencies required from there on your classpath! (You've missed some out, hence the error)

Related

XML-BEANS compiled schema: Could not locate compiled schema resource schemaorg_apache_xmlbeans/system/sE130CAA0A01A7CDE5A2B4FEB8B311707/index.xsb

I am writing an aplication to export data to an Excel sheet.
I wont to use the XSSFWorkbook class because my Excel exceeds the limit of 255 column of HSSFWorkbook class.
I downloaded the Apache POI libraries and I included the folowing libraries to my proyect:
- poi-3.9.jar
- poi-excelant-3.9.jar
- poi-ooxml-3.9.jar
- poi-ooxml-schemas-3.9.jar
- poi-scratchpad-3.9.jar
- dom4j-1.6.1.jar
- stax-api-1.0.1.jar
- xmlbeans-2.3.0.jar
When I export the data to get the Excel sheet I get this runtime error:
java.lang.ExceptionInInitializerError
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
Truncated. see log file for complete stacktrace
Caused By: java.lang.RuntimeException: Could not instantiate SchemaTypeSystemImpl (java.lang.reflect.InvocationTargetException): is the version of xbean.jar correct?
at schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707.TypeSystemHolder.loadTypeSystem(Unknown Source)
at schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707.TypeSystemHolder.<clinit>(Unknown Source)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
Truncated. see log file for complete stacktrace
Caused By: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707.TypeSystemHolder.loadTypeSystem(Unknown Source)
Truncated. see log file for complete stacktrace
Caused By: org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS compiled schema: Could not locate compiled schema resource schemaorg_apache_xmlbeans/system/sE130CAA0A01A7CDE5A2B4FEB8B311707/index.xsb (schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707.index) - code 0
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.<init>(SchemaTypeSystemImpl.java:1519)
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.initFromHeader(SchemaTypeSystemImpl.java:273)
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(SchemaTypeSystemImpl.java:185)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
Truncated. see log file for complete stacktrace
I read in a post that cant be because of the version of xbean-xx.jar and I notice that I don't have this library, I included in my project the version xbean-2.3.jar and has not change anything.
I read in another post of stackoverflow other solution: xmlbeans could not locate schema resource when repacking xml beans jar into my own jar . I don't know if I understood the solution correctly but the file /schemaorg_apache_xmlbeans/system/sE130CAA0A01A7CDE5A2B4FEB8B311707/index.xsb is in the jar poi-ooxml-schemas-3.9.jar so I figured that this is not my problem.
Can anyone help me please? thanks.
I've spotted your problem
The key line of the exception is this:
XML-BEANS compiled schema: Could not locate compiled schema resource schemaorg_apache_xmlbeans/system/sE130CAA0A01A7CDE5A2B4FEB8B311707/index.xsb
Next up, we see your rather non-standard way of including all the jars (which isn't usually recommended, including for reasons like this), and we see these lines:
<zipfileset src="../lib/poi-ooxml-3.10-FINAL-20140208.jar" includes="**/*.class, **/*.properties, **/*.txt" />
<zipfileset src="../lib/ooxml-schemas-1.1.jar" includes="**/*.class, **/*.properties" />
You are explicitly only pulling in certain kinds of files, and excluding all others from those jars. Look at the extension of the missing file in the exception - .xsb. Look at your explicit include list. See what you've missed?
You should either re-visit your whole way of building jars to pick something more "normal", or make sure you actually include all the relevant parts of the jars you're inlining, such as the .xsb files that the exception states you need

How to solve com.intellij.uiDesigner.core.Spacer class not found exception in Eclipse java swing projects

I developed a Java Swing project in Intellij Idea, now have to convert that to Eclipse. I imported the project in Eclipse and then converted the form using 'Convert to JFormDesigner form'. While running the application getting the below mentioned exception.
Caused by: java.lang.ClassNotFoundException: com.intellij.uiDesigner.core.Spacer
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 31 more
I added forms_rt-6.0.5.jar and its dependencies to Lib, but still getting the same exception. Any idea how to solve this.. Thanks in Advance..
Issue got solved. Added that forms_rt.jar into the class path via manifest.mf file.

Method not found for Jackson

I am trying to start my webapp to WAS 8 and I am seeing the following error....
Caused by: java.lang.NoSuchMethodError: org/codehaus/jackson/map/ObjectMapper.setPropertyNamingStrategy(Lorg/codehaus/jackson/map/PropertyNamingStrategy;)Lorg/codehaus/jackson/map/ObjectMapper;
at org.springframework.social.facebook.web.SignedRequestDecoder.<init>(SignedRequestDecoder.java:49)
at org.springframework.social.facebook.web.CanvasSignInController.<init>(CanvasSignInController.java:79)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
at java.lang.reflect.Constructor.newInstance(Constructor.java:527)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 41 more
From what I have read this is a conflict between versions of Jackson, however, all of my versions appear to be 1.9.9 and the javadocs say that method should exist.
Can anyone help? I am using maven so it could be a dependency chaining issue.
UPDATE
Here are the dependencies in my WEB-INF/lib
https://gist.github.com/jrgleason/7932960
The issue with this was a missing XML file in my case. So if anyone gets this weird warning it looks like a missing XML file is causing an initialization error that is not propagated very well.
The file (for me) was...
WEB-INF\classes\META-INF\spring\backbase-portal-business-security.xml

NoClassDefFoundError in Osgi w/ Felix, ant

After a lot of work migrating our code to another & fixing all the manifests and the bundles,
when I try to run the applet on the server I get many errors like this one:
java.lang.NoClassDefFoundError: org/jitsi/service/configuration/ConfigurationService
at net.java.sip.communicator.service.resources.AbstractResourcesService.<init>(AbstractResourcesService.java:127)
at net.java.sip.communicator.impl.resources.ResourceManagementServiceImpl.<init>(ResourceManagementServiceImpl.java:48)
at net.java.sip.communicator.impl.resources.ResourceManagementActivator.start(ResourceManagementActivator.java:36)
at org.apache.felix.framework.util.SecureAction$Actions.run(SecureAction.java:1243)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:620)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1904)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1822)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.jitsi.service.configuration.ConfigurationService not found by [12515]
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:812)
at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1807)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:670)
at org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:102)
at org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1426)
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:747)
at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1807)
at java.lang.ClassLoader.loadClass(Unknown Source)
All the bundles are getting resolved properly, and even when I tried to get some code out of the external jar into our code, it still threw me that error, I know that's a problem in Felix that I need to fix, but I don't know where can I start, all the bundles starting in their proper time...
I'm building the app with ant/Felix.
Maybe it's a problem with the activator?
Thanks for all the help, love to hear some opinions...
Your bundle is using the class org.jitsi.service.configuration.ConfigurationService but it doesn't import the package. Make sure that org.jitsi.service.configuration is listed in the Import-Package header in your bundle's manifest.

java.lang.NoClassDefFoundError

I got "java.lang.NoClassDefFoundError" Exception when I want to use a certain jar file.
Exception in thread "main" java.lang.NoClassDefFoundError: .
org/apache/http/client/ClientProtocolException
at ?uk.org.taverna.server.client.connection.ConnectionFactory.getConnection(ConnectionFactory.java:63)
at uk.org.taverna.server.client.Server.<init>(Server.java:99)
at uk.org.taverna.server.client.Server.<init>(Server.java:126)
at uk.org.taverna.server.client.Server.connect(Server.java:293)
at uk.org.taverna.server.usage.ServerUsage.Usage(ServerUsage.java:24)
at Test.main(Test.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.ClientProtocolException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
I import this jar file to jar library, when I call the method in that jar file I got this Exception. By the way, This jar file be wrote by myself, and I can run it correctly.
I have no idea how to solve this problem, I am quite new in java.
Thanks in advance.
Sandy
You need also at least HttpClient jar-library. You can get it at Apache Commons web-site.
Jar libraries may and often refer to another jar libraries. In your case library you are using refers to HttpClient library from Apache Commons framework. You need to add this library to your project.
You should but all the jar files you use in you application in the libs folder in your application directory .
so if you use the apachecommons jar file copy and paste the jar file to the libs folder in your application .

Categories

Resources