I'm trying to use the spire.office.free library to manage office files from java. For this I have a project using spring tool suite with maven for the download of that library. The problem is that when I run the code I get the following error.
Exception in thread "main" java.lang.IllegalAccessError: class com.spire.office.packages.sprkzh (in unnamed module #0x29647f75) cannot access class sun.security.action.GetPropertyAction (in module java.base) because module java.base does not export sun.security.action to unnamed module #0x29647f75
at com.spire.office.packages.sprkzh.spr??(Unknown Source)
at com.spire.office.packages.sprkzh.spr??(Unknown Source)
at com.spire.office.packages.sprkzh.<init>(Unknown Source)
at com.spire.office.packages.sprfqg.<init>(Unknown Source)
at com.spire.office.packages.sprhqg.<init>(Unknown Source)
at com.spire.xls.core.spreadsheet.XlsWorkbook.<init>(Unknown Source)
at com.spire.xls.Workbook.<init>(Unknown Source)
at Eu.Extrae.Principal.main(Principal.java:21)
At this moment java console informs me that it is not able to access the code of the library
Class file editor
The curious thing about the matter is that if I download the spire.office.free and use it as an external library the problem disappears and everything works correctly.
I know that is a solution to the problem but I prefer to use maven in any case
Any solution?
Thanks in advance
You muss download and add Jar file. I have this problem with excel, and I added the jar build path/configure build pat/maven dependencies and add the downloaded jar and problem solved
Related
I made myself a fancy TikZ-Api which allows to make a visualisation of Data (Plotting, diagram). The way it works is, you make an instance of the API like
TikZAPI api = new TikZAPI(); and then you add your Data for the plot (simple plot with dots) like api.addPoint(xCoord, yCoord). After I collected some data, I can print the entire code for the plot with api.print();. Then the code will appear in the console and I can copy and paste it manually into a LaTeX-Document where I can view the plot. Now the actual problem has nothing to do with the API, the API works perfectly fine. I want to collect some data of my minecraft server for example the maximum player count per hour and add this data to a plot to let it print into the console. BUT when I use my API as a library (IntelliJ: Project Structure -> Libraries -> + -> Library, which works fine, I can access all methods of my API in my plugin) and reload the server I get this error:
org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin TestAPI v1.0.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[Spi
got.jar:git-Spigot-ad703da-e2403a3]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:14
9) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at org.bukkit.craftbukkit.v1_16_R1.CraftServer.dispatchCommand(CraftServ
er.java:755) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.PlayerConnection.handleCommand(PlayerCo
nnection.java:1703) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.PlayerConnection.a(PlayerConnection.jav
a:1546) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.PacketPlayInChat.a(PacketPlayInChat.jav
a:47) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.PacketPlayInChat.a(PacketPlayInChat.jav
a:1) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.PlayerConnectionUtils.lambda$0(PlayerCo
nnectionUtils.java:19) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.TickTask.run(SourceFile:18) ~[Spigot.ja
r:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.executeTask(SourceFil
e:144) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.IAsyncTaskHandlerReentrant.executeTask(
SourceFile:23) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.executeNext(SourceFil
e:118) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.MinecraftServer.aZ(MinecraftServer.java
:943) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.MinecraftServer.executeNext(MinecraftSe
rver.java:936) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.awaitTasks(SourceFile
:127) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.MinecraftServer.sleepForTick(MinecraftS
erver.java:920) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:
852) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$0(MinecraftServe
r.java:164) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.lang.NoClassDefFoundError: tikzapi/TikZAPI
at test.Commands.onCommand(Commands.java:39) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[Spi
got.jar:git-Spigot-ad703da-e2403a3]
... 18 more
Caused by: java.lang.ClassNotFoundException: tikzapi.TikZAPI
at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_291]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
java:167) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
java:96) ~[Spigot.jar:git-Spigot-ad703da-e2403a3]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_291]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_291]
at test.Commands.onCommand(Commands.java:39) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[Spi
got.jar:git-Spigot-ad703da-e2403a3]
... 18 more
Well, I think the error is that the API is not getting loaded. But HOW can I do this? I already put the API into the plugins folder of my server, does not work. I made a subfolder in the plugins folder called "lib", did not work either. It does not matter if I use Eclipse or IntelliJ, both IDEs do not work. I have read that it has something to do with the manifest file but how do I make such an manifest file and does it really fix my problem? I cant use maven, because its my own API I made for myself and I want to use it like a normal library. Any ideas?
I assume your TikZ-Api is already compiled .jar file.
I will try to give you solution for IntelliJ IDEA, but general idea is same for all IDEs. When you add .jar into the libraries and then compile your plugin, IDE assumes that all these sources will be provided by VM instance during run and IDE does not have to pack the library sources with your plugin JAR file. This is true ONLY for bukkit.jar since bukkit starts first and then it loads plugins. It does not know that there is another API JAR somewhere which should be also loaded...
First simple solution is to copy raw (non-compiled) API .java sources into your plugin in the IDE and not add library at all. (Useful only if your API has few .java files and you still have them available)
Second solution is to add .jar API into libraries (as you mentioned) and tell the IDE that some libraries should be packed with your plugin during compilation and final .jar file will contain them. In IDEA, you have to create artifact configuration before compiling into .jar.
Then choose extract.
Then remove your bukkit entry from there (because we do not want to pack whole bukkit sources into our plugin) and you should see your API .jar file there. Then click Apply / OK.
Now when you build (compile) your plugin with Build artifacts, your API .jar will be compiled as well and packed into your plugin JAR file which will generate in out\artifacts
The best way here is to make the API as a plugin and load the dependency in the plugin.yml. That way, it is very easy to access it via any other plugin and there is no update compatibility issues if you use the API in different plugins. It is the norme with API in MC Server to create a plugin that acts as an API.
I've compiled the JAssimp library, and I'm trying to use the library in NetBeans with a project.
I'm setting the library path in Netbeans in the 'run' options of the project as such:
-Djava.library.path=D:\VB2013Projects\jassimpfinal\x64\Debug
That path is where jassimp.dll is located.
However, when I try to run my project, I get this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\VB2013Projects\jassimpfinal\x64\Debug\jassimp.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at jassimp.Jassimp.<clinit>(Unknown Source)
at opengltutorials.Mesh.loadMesh(Mesh.java:131)
at opengltutorials.Tutorial.init(Tutorial.java:124)
at opengltutorials.Tutorial.main(Tutorial.java:238)
I've checked the dependencies with Dependency Walker, and it shows that
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module. for jassimp.dll. However, it doesn't show any functions in red, so I think this is just a red herring (I am probably wrong, though).
What's going wrong with this?
Fixed this by putting the appropriate .dll's in the working directory.
(I just asked this in the Gradle forum, but I concluded that SO just works better.)
I'm looking at modifying an existing Gradle build script. It currently tries to execute "ant" in order to run a target from a specific Ant build script. This appears to be platform-specific, and it fails on my Windows box. I'm attempting to convert it to the more portable (?) process of importing the build script and executing the desired converted task.
The first thing I did was just add the "ant.importBuild" statement just before the existing target, and ran that. This fails with the following root cause:
Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
at org.apache.tools.ant.util.JAXPUtils.newSAXParser(JAXPUtils.java:215)
at org.apache.tools.ant.util.JAXPUtils.getNamespaceXMLReader(JAXPUtils.java:172)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:244)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:177)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
at org.apache.tools.ant.ProjectHelper$configureProject.call(Unknown Source)
at org.gradle.api.internal.project.DefaultAntBuilder.importBuild(DefaultAntBuilder.groovy:76)
From the related occurrences of this on the web, it's clear there's a classpath conflict (that didn't tell me anything that wasn't obvious), but I don't know how to resolve this.
The build scripts in question are from the Mockito code base (https://github.com/mockito/mockito), so you can see them there. I only added "ant.importBuild 'build-ant.xml'" just before the place where the Ant target is executed.
I got similar problem with xerces before which caused by a newer version xerces was used automatically due to gradle use newer one by default.
I will suggest you use gradle's dependencies task to check
I am using javax.mail .jar file to read the mail messages. But when i m running the code i am getting the following exception.
I added mail.jar in classpath.
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingE
xception
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: MasterProcess. Program will exit.
any suggetionsn to solve this issue please ...
You're not getting a MessagingException, the VM is complaining that it can't find MessagingException (although it's probably that it's looking for it because it wants to throw it, but those are issues for later).
Check if your mail.jar actually contains this class, and check if your mail.jar really is on the classpath.
The last thing that could happen is that the class is incompatible with your version of Java. Classes compiled for 1.5 won't run on 1.4, for example.
Working in eclipse and not in command line clearly say that there is multiple versions of mail jar present in the project.
Ex:
You have 3 Jars , Jar X, Jar Y and Jar Z.
With out you knowing JAR X might be already be bundled inside JAR Z ( in this case mail jar but some different version.
So what is the problem in having multiple version of same jar ?
You have two different versions and you will not know which will be referenced in your project. (so if you are looking for some class from mail-2.jar in your project you will get class not found exception if the reference is made to mail-1.jar by class loader)
So how come its working properly on Eclipse ?
In eclipse you can see there is an option for ORDER the library, these will be reference in the same order, but while running in command prompt we used to load the as lib/* which loads all to gather and we will not know which lib will get loaded first.
How to identify the culprit and fix the issue ?
Option 1 :
See docs page / user guide of the libs you are using to see what they have in them.
Option 2 :
In eclipse move the JAR in question (mail.jar here) to TOP in the class path order. (your program should work now)
Now bring down the order one by one to see where you get the error. (if you wish to find the jar which is causing this issue , duplicate reference)
Extract the jar which has the duplicate reference remove the duplicate inside the JAR and repackage it. (if required)
Also be sure you're having also the java activation.jar jar.
Are you by any chance working with an App Server (eg. Jboss), if so, just check classloading model (in jboss with single classloading model you may be loading a not so up-to-date version of the jars)
I've also faced the same error. It happens to me that while compiling i used the jars correctly. While running it on command line i noticed the mail.jar (javamail API) was not included.
I'm developing a eclipse plugin rcp and I'm running into a NoClassDefFoundError
Exception in thread "Thread-7" java.lang.NoClassDefFoundError: org/jdom/input/SAXBuilder
at org.geonames.WebService.search(WebService.java:783)
at geo.GeocoderGeonames$SearchThread.run(GeocoderGeonames.java:119)
Caused by: java.lang.ClassNotFoundException: org.jdom.input.SAXBuilder
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:483)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:399)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:387)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 2 more
The class that supposedly cannot be found is in a jar that I have added to the buildpath. I don't get any compile error etc only this exception when the running application enters the code where this class is needed...
Is there some other place I need to add the jar
After reading this added the jar to the MANIFEST.MF, which solved the problem.
As I understand it, eclipse starts several classloaders which only sees what MANIFEST.MF tells them to see and ingnores the build path...
How are you running your plug-in? You may need to add the JAR to the class path in the VM arguments.
In our experience a NoClassDefFoundError can sometimes mean that more than one version of a Class are found, as there is also a ClassNotFoundException that's normally thrown if a class cannot be found.
Another reason in your case (XML parser) might be something with endorsed classes. Are you directly importing the jdom classes or something like org.w3c...? If so, have a look at the "endorsed classes" system of Java, something that I just recently came across.