Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

ClassNotFoundException (Dependencies?)

Hi,

I'm trying to run the Hello World Example with a Hibernate data source. I'm also trying to use the Maven Plugin, as I had trouble with dependencies in the beginning. The wiki page about the plugin leaves me a bit puzzled. I'm used to have a pom.xml file, but couldn't find that. Do I have to write my own? The installation process for the plugin has finished successfully, 'openspaces' and 'gigaspaces' directories are in my local maven repository. When I try to run the processing unit, it fails with a ClassNotFoundException.

This is the command line: ./puInstance.sh ~/workspaces/3.3-ee/helloworld/pu/helloworld

This is the error message:

org.openspaces.pu.container.CannotCreateContainerException: Failed to started container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL : Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [ http://org.springframework.orm.hibern... ]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError at org.openspaces.pu.container.standalone.StandaloneProcessingUnitContainerProvider.createContainer(StandaloneProcessingUnitContainerProvider.java:325) at org.openspaces.pu.container.standalone.StandaloneProcessingUnitContainer.createContainer(StandaloneProcessingUnitContainer.java:155) at org.openspaces.pu.container.standalone.StandaloneProcessingUnitContainer.main(StandaloneProcessingUnitContainer.java:119) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL : Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [ http://org.springframework.orm.hibern... ]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:881) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:837) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) at org.openspaces.pu.container.standalone.StandaloneContainerRunnable.run(StandaloneContainerRunnable.java:128) at java.lang.Thread.run(Thread.java:595) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [ http://org.springframework.orm.hibern... ]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:111) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:875) ... 15 more Caused by: java.lang.NoClassDefFoundError at org.springframework.orm.hibernate3.LocalSessionFactoryBean.class$(LocalSessionFactoryBean.java:174) at org.springframework.orm.hibernate3.LocalSessionFactoryBean. (LocalSessionFactoryBean.java:174) 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:494) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:96) ... 17 more Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) ... 24 more

Attached is the pu.xml. There are no jar files in the lib directory, as Maven should take care of dependencies. h4. Attachments

[pom.xml|/upfiles/13759717826678146.xml]

[build.xml|/upfiles/13759717827590647.xml]

[pu.xml|/upfiles/13759717822470647.xml]

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2459]{quote}

asked 2008-07-16 05:51:38 -0500

elektronaut gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

5 Answers

Sort by ยป oldest newest most voted
0

I guess I found it. In the original build.xml from the Hello World example, there are these lines:

<mkdir dir="${pulocation}/lib"/> <copy todir="${pulocation}/lib"> <fileset dir="${basedir}/lib"/> </copy>

But as I'm using Maven, ${basedir}/lib is empty! OK, no wonder classes are not found if the libraries don't get into helloworld.jar. So how do I have to use the Maven plugin so that the libs end in the jar file? I attached the modified build.xml (now using Ant Tasks for Maven). If I run the target 'print-classpath', a lot of jars are listed, but important ones are still missing, e.g. hibernate. So apparently my pom.xml is not correct yet (besides the fact that the libs have to get into helloworld.jar). h4. Attachments

[build.xml|/upfiles/1375971783921883.xml]

answered 2008-07-16 16:39:09 -0500

elektronaut gravatar image
edit flag offensive delete link more
0

OK, by reading the wiki page for the plugin more thoroughly, I noticed that I misunderstood things. If I stop using Ant, what do I have to change in order to start this with Maven? For example, what would I have to insert for the module parameter in 'mvn compile os:run'?

answered 2008-07-16 16:51:59 -0500

elektronaut gravatar image
edit flag offensive delete link more
0

The thing is, I don't want to try out the mirror solution yet, at the moment I want to try http://www.gigaspaces.com/wiki/displa...

According to that page, all that is necessary is a certain pu.xml. I tried to have a correct one, also by comparing to another one posted in the forum. I was assuming that this should turn the helloworld example into an application that can write and read to the database. Other people also seem to be a bit puzzled about this, look at this thread: /[/question/5982/external-datasource/?answer=5983#post-id-5983]

I'm still getting the ClassNotFoundException. I don't know what's going on. The new pom.xml is attached.

(Edited because of incorrect suspicion concerning a wrong path setting.) h4. Attachments

[pom.xml|/upfiles/1375971782331009.xml]

answered 2008-07-16 12:39:48 -0500

elektronaut gravatar image
edit flag offensive delete link more
0

Shay, it's not important for me to use the Hello World Example, I just want to try out the Hibernate data source solution. As far as I understood the available Maven plugin templates, this is not included?

answered 2008-07-16 17:14:45 -0500

elektronaut gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2008-07-16 05:51:38 -0500

Seen: 157 times

Last updated: Jul 16 '08