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.
Related
I am trying to create a Spigot plugin that allows players to use a compass to track other players. While exporting and running the server, I noticed that it was giving me an error:
[21:57:15 ERROR]: Could not load 'plugins\Manhunt.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:172) ~[patched_1.16.5.jar:git-Paper-683]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:148) ~[patched_1.16.5.jar:git-Paper-683]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:252) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1066) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:290) ~[patched_1.16.5.jar:git-Paper-683]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more
I have never seen this error before and I'm not sure how to fix it. I have made sure to export the .yml file while in Eclipse, but it still shows me this error.
The plugin.yml file is a required part of a SpigotMC plugin that defines some basic information about the plugin like its name and the version of the Spigot API that it uses. For example, here's one for a Minecraft plugin I'm currently working on.
The error you're getting comes from that file not getting bundled into the jar. As a result, when the Spigot server tries to load your plugin, it can't find the plugin.yml because it's literally not present in your compiled jar.
I recommend setting up a build system like Gradle or Maven that will handle the complexities of building the jar for you independent of the IDE you use.
Set up a SpigotMC plugin using Maven
Set up a SpigotMC plugin using Gradle
I personally use Gradle, so feel free to see how I implemented it in one of my plugins. If you'd prefer Maven, there are many examples available including the popular Multiverse-Core.
You need the plugin.yml to run your plugin. If you're using spigot or bukkit, you should make your plugin.yml inside the src folder, in there, you need to include a minimum of:
name: (plugin name, no spaces allowed in name)
author: (your name)
version: (your plugin version)
api-version: (use 1.14)
main: (your main class)
description: (optional description, otherwise delete this line)
then you can export or rebuild the jar
This is an example of what my plugin.yml looks like:
name: ThornsPlugin
version: 1.0
author: MOREORLESS
api-version: 1.14
main: com.MOREORLESS.plugin.plugin
description: MC Stuff
Learn more about Plugin.yml here: https://www.spigotmc.org/wiki/plugin-yml/
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
(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'm attempting to create a Minecraft mod using the 1.7.2 release of MCP, version 9.03. I may be doing the installation steps wrong, as when I complete the installation, open Eclipse and select the workspace, it gives me 7 errors that I have no idea how to solve. These are the errors:
Project 'Client' is missing required library: 'jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.0/lwjgl-2.9.0.jar'
Project 'Client' is missing required library: 'jars/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.0/lwjgl_util-2.9.0.jar'
Project 'Client' is missing required library: 'jars/libraries/org/lwjgl/lwjgl/lwjgl- platform/2.9.0/lwjgl-platform-2.9.0-natives-windows.jar'
Project 'Server' is missing required library: 'jars/minecraft_server.1.7.2.jar'
Project 'Client' is missing required library: 'jars/libraries/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-windows.jar'
The project cannot be built until build path errors are resolved
The project cannot be built until build path errors are resolved
If I attempt to run without making any changes, this is the error that is displayed in the console:
Exception in thread "main" java.lang.NoClassDefFoundError: Start
Caused by: java.lang.ClassNotFoundException: Start
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Please help me out, I'm not using Forge as I plan to be making changes to base class files.
Open up eclipse and right click on the project "Client", go to build path, configure build path, click on all of the errored files and press remove. Then download the latest LWJGL (http://lwjgl.org/) and extract it to some folder, and import all of the jars. Next, get the natives for all platforms and put them in a new file called LWJGL-Natives.jar and import that as well.
Also, PLEASE do not do a base edit mod! It's bad practice, and will make your mod get little to no use. Try to use either the forge tweak utilities or the official one by mojang: https://github.com/Mojang/LegacyLauncher
Plus, you most likely can do whatever you want to do without ASM or base edits, so please try those before doing base edits.
For project "Server", remove the dependency for the broken resource. It will continue working fine.
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.