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
douglasmhurst
Post subject: Hoping to help all users with a tutorial conversion  PostPosted: Dec 04, 2008 - 03:06 PM
Registered Member
Registered Member


Joined: Sep 30, 2006
Posts: 274

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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<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.
 
 View user's profile Send private message  
Reply with quote Back to top
support-nipun
Post subject: RE: Hoping to help all users with a tutorial conversion  PostPosted: Dec 04, 2008 - 05:33 PM
Registered Member
Registered Member


Joined: Apr 18, 2007
Posts: 8012

Moving to MyEclipse IDE >> Examples on-Demand

_________________
Nipun
MyEclipse Support
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
nmatrix9
Post subject: Re: Hoping to help all users with a tutorial conversion  PostPosted: Dec 09, 2008 - 12:38 AM
Registered Member
Registered Member


Joined: Nov 05, 2007
Posts: 45

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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<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
 
 View user's profile Send private message  
Reply with quote Back to top
douglasmhurst
Post subject: RE: Re: Hoping to help all users with a tutorial conversion  PostPosted: Dec 09, 2008 - 10:18 PM
Registered Member
Registered Member


Joined: Sep 30, 2006
Posts: 274

I submitted my hybrid project to support@myeclipseide.com
 
 View user's profile Send private message  
Reply with quote Back to top
support-nipun
Post subject: RE: Re: Hoping to help all users with a tutorial conversion  PostPosted: Dec 10, 2008 - 07:12 PM
Registered Member
Registered Member


Joined: Apr 18, 2007
Posts: 8012

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

_________________
Nipun
MyEclipse Support
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
pasanjay
Post subject: RE: Re: Hoping to help all users with a tutorial conversion  PostPosted: Apr 01, 2009 - 04:02 PM



Joined: Mar 19, 2009
Posts: 2

Any update on this issue?
 
 View user's profile Send private message  
Reply with quote Back to top
support-nipun
Post subject: RE: Re: Hoping to help all users with a tutorial conversion  PostPosted: Apr 01, 2009 - 05:38 PM
Registered Member
Registered Member


Joined: Apr 18, 2007
Posts: 8012

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

_________________
Nipun
MyEclipse Support
 
 View user's profile Send private message Send e-mail  
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