Re: OSUser and Hibernate: couple of questions

Konstantin Priblouda <[email protected]>
Newsgroups gmane.comp.java.open-symphony.devel
Message-ID <[email protected]>
--- Ilja <[email protected]> wrote:
> 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();

Well, did you set correct profile provider? like this:
---%<------------
<opensymphony-user>
        <provider
class="com.opensymphony.module.user.provider.hibernate.HibernateCredentialsProvider">
			<property name="create.tables">false</property>
			<property
name="hibernate.show_sql">false</property>
			<property
name="hibernate.connection.datasource">java:DefaultDS</property>
			<property
name="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</property>
			<property
name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
		</provider>
        <provider
class="com.opensymphony.module.user.provider.hibernate.HibernateProfileProvider">
			<property name="create.tables">false</property>
			<property
name="hibernate.show_sql">false</property>
			<property
name="hibernate.connection.datasource">java:DefaultDS</property>
			<property
name="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</property>
			<property
name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
		</provider>
        <provider
class="com.opensymphony.module.user.provider.hibernate.HibernateAccessProvider">
			<property name="create.tables">false</property>
			<property
name="hibernate.show_sql">false</property>
			<property
name="hibernate.connection.datasource">java:DefaultDS</property>
			<property
name="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</property>
			<property
name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
		</provider>
</opensymphony-user>
--%<--------------

regards,

=====
----[ Konstantin Pribluda ( ko5tik ) ]----------------
Zu Verstärkung meines Teams suche ich ab Sofort einen
Softwareentwickler[In] für die Festanstellung. 
Arbeitsort: Mainz 
Skills:  Programieren, Kentnisse in OpenSource-Bereich
----[ http://www.pribluda.de ]------------------------

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com


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