Re: OSUser and Hibernate: couple of questions

"Ilja" <[email protected]>
Newsgroups gmane.comp.java.open-symphony.devel
Message-ID <[email protected]>
Thanks!

I tried setting up a test with your directions, but I'm getting the
following error:

java.lang.NullPointerException
	at com.opensymphony.module.propertyset.hibernate.HibernatePropertySetDAOImpl.setImpl(HibernatePropertySetDAOImpl.java:42)
	at com.opensymphony.module.propertyset.hibernate.HibernatePropertySet.setImpl(HibernatePropertySet.java:156)
	at com.opensymphony.module.propertyset.AbstractPropertySet.set(AbstractPropertySet.java:565)
	at com.opensymphony.module.propertyset.AbstractPropertySet.setString(AbstractPropertySet.java:363)
	at com.opensymphony.user.User.setEmail(User.java:61)
	at org.mathesis.test.OSUserTest.doGet(OSUserTest.java:37)

This is my code:

/*
 * Created on 29-sep-2003
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.mathesis.test;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.user.User;
import com.opensymphony.user.UserManager;

/**
 * @author ilja
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class OSUserTest extends HttpServlet
{
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
	{
		UserManager um = UserManager.getInstance();
		PrintWriter out = response.getWriter();
		
		try
		{
			User u = um.getUser("ilja");
			u.setEmail("[email protected]");
			u.setPassword("arnomarie");
			
			PropertySet userProperties = u.getPropertySet();
			
			userProperties.setString("first-name", "Ilja");
			userProperties.setString("last-name", "My-lastname");
		}
		catch (Exception e)
		{	
			e.printStackTrace(out);
		}
	}
}

The error occurs on the line u.setEmail("[email protected]");
The user does exist, I tested it with out.println(u.getUsername());

This is the original cause of the error in HibernatePropertySetDAOImpl:

    public void setImpl(PropertySetItem item) {
        Session session = null;

        try {
---->            session = this.sessionFactory.openSession();


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.