MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
jh4747
Post subject: [Closed] Xfire and Hibernate problem  PostPosted: Mar 22, 2007 - 08:33 PM
Registered Member
Registered Member


Joined: Jul 12, 2005
Posts: 70

The 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.

Code:

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.

Code:
transaction = session.beginTransaction();


Code:
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



Code:
<?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

Code:
<?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

ps -- reposted -- originally put in the wrong folder
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Support-Brian
Post subject:   PostPosted: Mar 23, 2007 - 07:41 PM
Moderator
Moderator


Joined: Aug 21, 2004
Posts: 2515

Lee,

Can you check your server deploy folder to see if the Hibernate libraries are being deployed?
You need to check the settings under MyEclipse > J2EE Project > Web Project, check your Library Deployment Policy settings.

_________________
Brian
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
jh4747
Post subject:   PostPosted: Mar 23, 2007 - 08:30 PM
Registered Member
Registered Member


Joined: Jul 12, 2005
Posts: 70

Support-Brian wrote:
Can you check your server deploy folder to see if the Hibernate libraries are being deployed?
You need to check the settings under MyEclipse > J2EE Project > Web Project, check your Library Deployment Policy settings.


Thank you, thank you. I would have never figured that out. I did a check of the lib in my Tomcat/webapps/<myapp> directory and hibernate jar was not there (exploded deployment).

In my "Deployment" tab (that I never knew about), "use smart deployment" was chosen, I changed to "jar dependant" and redeployed my app -- and all is well.

Actually, it just allowed me to go on to the next bug - but I was able to handle that myself :)

A million thanks!

Lee
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits