facebook

Hoping to help all users with a tutorial conversion

  1. MyEclipse Archived
  2.  > 
  3. Examples On-Demand
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #291620 Reply

    Douglas M Hurst
    Participant

    I think I’ve really narrowed this down. What I’ve tried to do is rework the “MyEclipse Hibernate and Spring Tutorial” from a Java Project into a Web Project running under GlassFish. It’s sort of a cross between that tutorial and the “Java EE 5 MyBlog Application Demo”

    So, instead of a “main”, I have a .JSP with a backing backing bean doing much the same functionality as the “main.” I was hoping to offer this as a tutorial piece for web/hibernate/spring. Here’s what happens

    I call a method in the backing bean with a commandButton in the main JSP. Right now, all I’m trying to do is the following:

    public String doPost() {
    BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(“applicationContext.xml”));
    PersistenceLayer persistenceLayer = (PersistenceLayer) beanFactory.getBean(“persistenceLayer”);
    return “success”;
    }

    It’s throwing up on the PersistenceLayer line with the following error…

    javax.servlet.ServletException: #{mainBean.doPost}: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘persistenceLayer’ defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean ‘UserDAO’ while setting bean property ‘userDAO’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘UserDAO’ defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean ‘hibernateSession’ while setting bean property ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘hibernateSession’ defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
    .

    My applicationContext.xml is almost identical to that of the tutorial…

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <beans
    xmlns=”http://www.springframework.org/schema/beans&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd”&gt;

    <bean id=”hibernateSession” class=”org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean”>
    <property name=”configLocation” value=”classpath:hibernate.cfg.xml”></property>
    </bean>
    <bean id=”persistenceLayer” class=”com.lmco.hibernatespring.PersistenceLayer” abstract=”false” scope=”singleton” lazy-init=”default” autowire=”default”
    dependency-check=”default”>
    <property name=”userDAO”>
    <ref bean=”UserDAO” />
    </property>
    </bean>
    <bean id=”UserDAO” class=”com.lmco.hibernatespring.UserDAO”>
    <property name=”sessionFactory”>
    <ref bean=”hibernateSession” />
    </property>
    </bean>
    </beans>

    The PersistenceLayer.java is exactly the same as in the tutorial…

    package com.lmco.hibernatespring;

    public class PersistenceLayer {
    private UserDAO userDAO;

    public UserDAO getUserDAO() {
    return userDAO;
    }

    public void setUserDAO(UserDAO userDAO) {
    this.userDAO = userDAO;
    }

    public void addUser(User user) {
    userDAO.save(user);
    }

    public User findUserById(Integer id) {
    return userDAO.findById(id);
    }

    public void updateUser(User user) {
    userDAO.merge(user);
    }

    public void deleteUser(User user) {
    userDAO.delete(user);
    }
    }

    I really want this to work so there can be a web version of that tutorial, but I can’t understand why it doesn’t like the PersistenceLayer.

    If I can get help getting this thing to work, I think it will really help other user have a nice starting point for a web/jsf/spring/hibernate project.

    #291629 Reply

    Loyal Water
    Member

    Moving to MyEclipse IDE >> Examples on-Demand

    #291765 Reply

    nmatrix9
    Member

    @douglasmhurst wrote:

    I think I’ve really narrowed this down. What I’ve tried to do is rework the “MyEclipse Hibernate and Spring Tutorial” from a Java Project into a Web Project running under GlassFish. It’s sort of a cross between that tutorial and the “Java EE 5 MyBlog Application Demo”

    So, instead of a “main”, I have a .JSP with a backing backing bean doing much the same functionality as the “main.” I was hoping to offer this as a tutorial piece for web/hibernate/spring. Here’s what happens

    I call a method in the backing bean with a commandButton in the main JSP. Right now, all I’m trying to do is the following:

    public String doPost() {
    BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(“applicationContext.xml”));
    PersistenceLayer persistenceLayer = (PersistenceLayer) beanFactory.getBean(“persistenceLayer”);
    return “success”;
    }

    It’s throwing up on the PersistenceLayer line with the following error…

    javax.servlet.ServletException: #{mainBean.doPost}: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘persistenceLayer’ defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean ‘UserDAO’ while setting bean property ‘userDAO’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘UserDAO’ defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean ‘hibernateSession’ while setting bean property ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘hibernateSession’ defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
    .

    My applicationContext.xml is almost identical to that of the tutorial…

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <beans
    xmlns=”http://www.springframework.org/schema/beans&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd”&gt;

    <bean id=”hibernateSession” class=”org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean”>
    <property name=”configLocation” value=”classpath:hibernate.cfg.xml”></property>
    </bean>
    <bean id=”persistenceLayer” class=”com.lmco.hibernatespring.PersistenceLayer” abstract=”false” scope=”singleton” lazy-init=”default” autowire=”default”
    dependency-check=”default”>
    <property name=”userDAO”>
    <ref bean=”UserDAO” />
    </property>
    </bean>
    <bean id=”UserDAO” class=”com.lmco.hibernatespring.UserDAO”>
    <property name=”sessionFactory”>
    <ref bean=”hibernateSession” />
    </property>
    </bean>
    </beans>

    The PersistenceLayer.java is exactly the same as in the tutorial…

    package com.lmco.hibernatespring;

    public class PersistenceLayer {
    private UserDAO userDAO;

    public UserDAO getUserDAO() {
    return userDAO;
    }

    public void setUserDAO(UserDAO userDAO) {
    this.userDAO = userDAO;
    }

    public void addUser(User user) {
    userDAO.save(user);
    }

    public User findUserById(Integer id) {
    return userDAO.findById(id);
    }

    public void updateUser(User user) {
    userDAO.merge(user);
    }

    public void deleteUser(User user) {
    userDAO.delete(user);
    }
    }

    I really want this to work so there can be a web version of that tutorial, but I can’t understand why it doesn’t like the PersistenceLayer.

    If I can get help getting this thing to work, I think it will really help other user have a nice starting point for a web/jsf/spring/hibernate project.

    Hello douglasmhurst ,

    I’m also in the midst of converting the MyBlogJSFJPAExample application to use hibernate and spring based persistence layer. If you make any progress on your end please keep us informed.

    Thanks,
    nmatrix9

    #291814 Reply

    Douglas M Hurst
    Participant

    I submitted my hybrid project to support@genuitec.com

    #291883 Reply

    Loyal Water
    Member

    Update: The Hybrid project has already been sent to the dev team for reviewing.

    #297106 Reply

    pasanjay
    Member

    Any update on this issue?

    #297111 Reply

    Loyal Water
    Member

    pasanjay,
    The example submitted to use has not been made available in the EOD repository yet.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Hoping to help all users with a tutorial conversion

You must be logged in to post in the forum log in