- This topic has 1 reply, 2 voices, and was last updated 17 years, 8 months ago by Scott Anderson.
-
AuthorPosts
-
Lee HarringtonMemberThe Java gods must be angry at me. Seems I can’t get anything to work without coming here for help these days.
I’m onto the next step of my project — getting my web service to interract with the database. I’ve added hibernate capabilities (something I’ve done successfully before)….and a working webservice now goes kaput.
public class RubyFTM_SDRSImpl implements IRubyFTM_SDRS { public String example(String message) { RubyFtmStg data = new RubyFtmStg(); data.setSource("test"); Session session = null; Transaction transaction = null; // try { session = HibernateSessionFactory.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); // RubyFtmStgDAO dao = new RubyFtmStgDAO(); // dao.save(data); // transaction.commit(); // } catch (Exception e) { // String errMsg = e.toString(); // if (transaction != null) { // try { // transaction.rollback(); // System.out.println("transaction rolled back due to error: " + errMsg); // } catch (Exception e2) {} // System.out.println("error rolling back transaction"); // } // } finally { // if (session != null) { // try { session.close(); } catch (Exception e) {} // } // } return message; } }
Here’s the method. You can see I’ve commented out most of the code. When all was commented out — no problem. When this line is uncommented — I get an error.
transaction = session.beginTransaction();
SEVERE: Error initializing XFireServlet. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.xfire.spring.ServiceBean' defined in class path resource [META-INF/xfire/services.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/Session java.lang.NoClassDefFoundError: org/hibernate/Session at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at org.springframework.util.ClassUtils.forName(ClassUtils.java:108) at org.springframework.beans.propertyeditors.ClassEditor.setAsText(ClassEditor.java:63) at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:771) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:584) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:469) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:626) at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:653) at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:642) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1023) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:824) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320) at org.codehaus.xfire.spring.XFireConfigLoader.getXFireApplicationContext(XFireConfigLoader.java:107) at org.codehaus.xfire.spring.XFireConfigLoader.loadContext(XFireConfigLoader.java:41) at org.codehaus.xfire.transport.http.XFireConfigurableServlet.loadConfig(XFireConfigurableServlet.java:86) at org.codehaus.xfire.transport.http.XFireConfigurableServlet.createXFire(XFireConfigurableServlet.java:54) at org.codehaus.xfire.transport.http.XFireServlet.init(XFireServlet.java:45) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:887) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3948) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4271) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:850) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:316) at org.apache.catalina.core.StandardHost.install(StandardHost.java:859) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:723) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:473) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1002) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:393) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133) at org.apache.catalina.core.StandardHost.start(StandardHost.java:816) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2343) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398)
I get the error when Tomcat 5 (java 5) is started. I do have the hibernate classes in my project. Here’s the services.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://xfire.codehaus.org/config/1.0"> <service> <name>RubyFTM_SDRS</name> <serviceClass>com.add.sdrs.IRubyFTM_SDRS</serviceClass> <implementationClass> com.add.sdrs.RubyFTM_SDRSImpl </implementationClass> <style>wrapped</style> <use>literal</use> <scope>application</scope> </service></beans>
hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration> <session-factory> <property name="connection.username">sdrs_stg</property> <property name="connection.url"> jdbc:oracle:thin:sdrs_stg/netric2d@cht022h.sldc.sbc.com:1521:netric2d </property> <property name="dialect"> org.hibernate.dialect.Oracle9Dialect </property> <property name="myeclipse.connection.profile"> SDRS_STG </property> <property name="connection.password">stg4sdrs</property> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </property> <mapping resource="com/add/sdrs/RubyFtmStg.hbm.xml" /> </session-factory> </hibernate-configuration>
I’m stuck again.
Lee
Scott AndersonParticipantLee,
Can you verify that the hibernate libraries, specifically the jar containing org.hibernate.Session, is being deployed to
the WEB-INF/lib directory in your web project’s deployment directory under Tomcat? You can get to it easily with the
Browse button from the Manage Deployments dialog. -
AuthorPosts