javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at Client_TestPortal.main(Client_TestPortal.java:54)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac
tory
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more
That exception says that initializing of the InitialContext has failed for your Client_TestPortal application. The resaon is that it has been unable to load the class org.jnp.interfaces.NamingContextFactory which (I presume) the default Java Naming provider for your platform.
It appears that your apps classpath is missing a required JAR file. According to this findjar query it could be one of the following:
[LOCAL] jbossall-client.jar
[LOCAL] jbossjmx-ant.jar
[MAVEN2] jnpserver-3.2.3.jar
[MAVEN2] jbossall-client-3.2.1.jar
[MAVEN2] jbossall-client-3.2.3.jar
[MAVEN2] jbossjmx-ant-3.2.3.jar
[MAVEN2] jnp-client-3.2.1.jar
[MAVEN2] jnp-client-4.0.2.jar
... or something like that. Which (if any) of the above JARs is most appropriate is hard to say.
You have not provided enough information like the environment you are using, The app server etc.
Any way it lloks like JNDI related JAR is not on the classpath. If it is in place and still not working, then you may have missed to put the correct context information, so pass the JNDI information to the constuctor of InitialContext.
I had the same problem but I found how to fix it. All you have to do is add the jbossall-client.jar library to the clients project, and done!!! You can find the file inside the client folder.
e.g jboss-6.1.0.Final_GPT\client
I was using Jboss 6.1.0
You can also get help from this link
https://community.oracle.com/thread/1157701?start=0
Hope it helps.
Related
I am struggling for a couple hours with one problem regarding the initial setup of Hibernate for Eclipse. More precisely I am getting this error and i looked up anywhere for a solution. If anyone could help me with this one i would kindly appreciate it!
Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.hibernate.test.Main.main(Main.java:16)
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
You're getting the error because the hibernate libraries are not available to Tomcat. In your picture, below the hibernate library set there is an empty set called 'Web App Libraries' - this is the set your hibernate libraries need to be in.
Right click your project -> Build Path -> Configure Build Path, and remove the hibernate set from the build path. Now import the jars into the WEB-INF/lib folder. Refresh your project and now you should see them listed in the 'Web App Libraries' set (i appreciate this is somewhat annoying that you have to import them into your code base - someone else might know a better way to do this that doesn't involve copying the jars in)
there is problem your maven dependency. if you are using hibernate annotations, you should add hibernate-annotations jar
If you are using maven , then there is some diffrence in versions of hibernate jars ,
Please clean all jars from maven directory and then again let maven download the jars .
I hope this solves your problem .
Using Eclipse, I am modifying a Java project we have been using for years. a specific class method is typically executed by sending a message through IBM WebSphere MQ. However, I now have a need to develop some new functionality and I need to be able to test it out side the MQ world.
I am able to successfully debug the application in Eclipse, but if I attempt to execute the jar file from a command prompt I receive the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: XMLBuilder/Node
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: XMLBuilder.Node
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)
... 6 more
My build is done using an ant script. This does not include a Class-Path attribute when creating the manifest.
The XMLBuilder.jar file is included in the target jar. Running jar -tf file.jar shows
META-INF/)
META-INF/MANIFEST.MF)
... Omitted for Brevity ...
XMLBuilder.jar
What might I be missing?
Thank you
Is there proper guideline on how to deploy Swing application with JWS?
Here is what I have been trying
Created Swing application with Netbeans. And trying to deploy ready application with Java web start.
Project Property -> Application -> Web start, Enabled Web start, fixed all necessary fields.
By using Tomcat or WAMP server, I was able to run jnlp file, it downloads necessary libraries and right after launch I get following error:
java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
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 com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
But json.simple jar file is in classpath and application is running normal locally (without JWS).
Why despite having library in classpath, I get NoClassDefFoundError error?
jnlp file seem to have it listed <jar href="lib/json-simple-1.1.1.jar"/>.
Surfed around net but couldn't find a fix for the issue. Anyone had similar issues, please help! And Please ask for clarification before marking this question as duplicate, thanks!
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.
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.