ClassNotFoundException In a Bukkit java Plugin - java

I'm trying to revive a plugin and im geting thir error:
[03:01:18 ERROR]: Could not load 'plugins\Reporter.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.ClassNotFoundException: me.f
levasgr.rainbow.Reporter
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
ava:184) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
java:308) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
.java:231) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.ja
va:255) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:23
3) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [c
raftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14
) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.jav
a:126) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
:424) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
Caused by: java.lang.ClassNotFoundException: me.flevasgr.rainbow.Reporter
at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_25]
at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_25]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_
25]
at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.7.0_25]
at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader
.java:80) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
java:53) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]
at java.lang.Class.forName0(Native Method) ~[?:1.7.0_25]
at java.lang.Class.forName(Unknown Source) ~[?:1.7.0_25]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
ava:173) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
... 9 more
I've done everything right! The plugin.yml the external jar and the export but still doesnt work. Any idea why?

As the error states,
java.lang.ClassNotFoundException: me.f
levasgr.rainbow.Reporter
it cannot find the main class of your plugin. Perhaps one of your package names is capitalized, or your main class is lowercase. Bukkit's plugin loader is case sensitive when it comes to loading the main class.

There are different reasons for a java.lang.ClassNotFoundException in bukkit, the most common reason is that the plugin.yml doesn't point to the correct location.
If you have the following class:
package me.flevasgr.rainbow.reporter;
//...
public class Reporter {
Then you should copy the full package, place a dot and then place the name of the class, like this:
main: me.flevasgr.rainbow.reporter.Reporter
This makes sure bukkit will find your class on the correct location.

Related

Eclipse. ClassNotFoundException but I do know that class exists

I added myLibrary.jar in project BuildPath and try to call static method from myLibrary.jar myClass but have exception:
Caused by: java.lang.NoClassDefFoundError: application/Application
at rcp.handlers.RunGenerationHandler.execute(RunGenerationHandler.java:29)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
... 38 more
Caused by: java.lang.ClassNotFoundException: application.Application cannot be found by rcp_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 46 more
I'm sure that class exists in Library.
I try to rebuild myLibrary.jar and add in project again but problem still stays.
Below is the code where I try to call static method from my class:
import application.Application;
...
if (generationString != null){
Application.main(generationString);
}
Application - class in myLibrary.jar
ldl = myLibrary
UPDATE
I'm really such a slowpoke=(
In RCP applications libraries attaching in MANIFEST.MF
Example:Bundle-ClassPath: .,/directory/myLibrary.jar
If your Library is also a RCP-Plugin you have to add it in the dependencies of your plugin.xml in your project.
In the Library plugin.xml you have to export the package where the class is in.

java.lang.ClassNotFoundException: org.bouncycastle.asn1.ASN1Encodable

I am using IText 4.2.0 and bcprov-jdk15-1.43.jar and bctsp-jdk15-1.43.jar for signing pdf. I added these jars by add external jars button in Eclipse. When I execute it gives me following error.
ExceptionConverter: java.lang.Exception: Failed to get TSA response from tsaURL
at com.lowagie.text.pdf.TSAClientBouncyCastle.getTimeStampToken(TSAClientBouncyCastle.java:185)
at com.lowagie.text.pdf.TSAClientBouncyCastle.getTimeStampToken(TSAClientBouncyCastle.java:136)
at com.lowagie.text.pdf.PdfPKCS7.getEncodedPKCS7(PdfPKCS7.java:1236)
at pack1.PDFSigningWithHSM.PDFSigningWithHSM.main(PDFSigningWithHSM.java:489)
Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1Encodable
at com.lowagie.text.pdf.TSAClientBouncyCastle.getTimeStampToken(TSAClientBouncyCastle.java:146)
... 3 more
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.ASN1Encodable
at java.net.URLClassLoader$1.run(Unknown Source)
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 java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
But I see Class ASN1Encodable in the jar file bcprov-jdk15-1.43.jar. I dont understand what is the problem.
That exception means that the classloader cannot find that class at runtime. We don't have enough information to determine why it is the case ... but it is definitely the cause of your problems.
Check that the offending JAR file is actually on your application's effective runtime classpath.

Unable to configure second level cache in hibernate 4.x

I am using hibernate 4.3 and MySQL 5.0.I am trying to configure a second level cache in my example as follows.
My hibernate.cfg.xml
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
My Entity class
#Entity
#Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
#Cacheable
public class Employee { ...}
I am getting following Exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/service/jndi/JndiNameException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.jboss.logging.Logger$1.run(Logger.java:2252)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2227)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
at org.hibernate.cache.ehcache.AbstractEhcacheRegionFactory.<clinit>(AbstractEhcacheRegionFactory.java:77)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:242)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:125)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:87)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:46)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:83)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:223)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:197)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:295)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2442)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2438)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1855)
at com.example.hibernate.Hibernate4Main.main(Hibernate4Main.java:33)
Caused by: java.lang.ClassNotFoundException: org.hibernate.service.jndi.JndiNameException
at java.net.URLClassLoader$1.run(Unknown Source)
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)
... 22 more
What is missing in my configuration? I know second level cache configuration in hibernate 4.x is different for 3.x. I have searched that but not getting working answer for me.
Thanks for help.
Propbable reasons why you are getting java.lang.NoClassDefFoundError
1) Class is not available in Java Classpath.
2) You might be running your program using jar command and class was not defined in manifest file's ClassPath attribute.
3) Any start-up script is overriding Classpath environment variable.
4) Because NoClassDefFoundError is a sub class of java.lang.LinkageError it can also come if one of it dependency like native library may not available.
4) Check for java.lang.ExceptionInInitializerError in your log file. NoClassDefFoundError due to failure of static initialization is quite common.
5) If you are working in J2EE environment than visibility of Class among multiple Classloaders can also cause java.lang.NoClassDefFoundError.

In Java: Could not find the main class

When I wrote a standalone client and tried to execute it,
it's giving me the following errors:
Running in Windows:
Exception in thread "main" java.lang.NoClassDefFoundError: TestClient
Caused by: java.lang.ClassNotFoundException: TestClient
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: TestClient. Program will exit.
This is in Linux
Exception in thread "main" java.lang.NoClassDefFoundError: TestClient (wrong name: com/tata/bayer/service/TestClient)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
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)
Could not find the main class: TestClient. Program will exit.
Now i am getting
C:\Softwares\apache-tomcat-6.0.33\webapps\tkweb-ws-12.0\WEB-INF\classes\com>java com.tata.bayer.service.TestClient
Exception in thread "main" java.lang.NoClassDefFoundError: com/tata/bayer/service/TestClient
Caused by: java.lang.ClassNotFoundException: com.tata.bayer.service.TestClient
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: com.tata.bayer.service.TestClient Program will exit.
It looks like you should be running
java com.tata.bayer.service.TestClient
from a directory containing "com", with an appropriate directory hierarchy eventually leading to TestClient.class.
You haven't shown whether you're compiling this code yourself or whether it's been given to you. If you are compiling it yourself, you should usually organize the source code so that it reflects the package structure too. So you might run:
javac com/tata/bayer/service/*.java
java com.tata.bayer.service.TestClient
Or maybe:
# Keep source and class files separate...
javac -d bin com/tata/bayer/service/*.java
java -classpath bin com.tata.bayer.service.TestClient
If that doesn't help, please provide more details.
Looks like you want to use com/tata/bayer/service/TestClient and not TestClient. Try using the full path.

ruby class to java class using jruby

i found the following ruby app in git:
https://github.com/chrislo/sourceclassifier
and it is exactly what i need for the final part of my school project.
It would be great if i could use it in a my java project.
i used jRuby and managed to compile the class i need ( sourceclassifier.rb ) to a Java .class file, and added it to the build path of my eclipse app.
how can i now use it inside my app?
using sourceclassifier s = new sourceclassifier() throws me the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: sourceclassifier/lib/sourceclassifier
at StackOverFlowReader.main(StackOverFlowReader.java:208)
Caused by: java.lang.ClassNotFoundException: sourceclassifier.lib.sourceclassifier
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)
... 1 more`
and help will be appreciated,
Boris.

Categories