-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: MappingException
PostPosted: Wed Aug 03, 2005 12:52 pm 
Newbie

Joined: Mon Jul 25, 2005 12:58 pm
Posts: 5
Hi. I've been trying to simply crete a user and store data into MySQL.
I've been getting the mapping exception but I'm not sure where to look to fix this problem since my JUnit test runs fine and adds data to MySQL. I'm also using Jetspeed.

Any tips or suggestions would be very appreciate it.

Hibernate version: 3.0

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.adsmack.framework.domain">

<class name="User" table = "user">
<id name="userId" column = "userId" type="integer">
<generator class="native"/>
</id>
<property name="userName"/>
<property name="displayName"/>
<property name="pwd1"/>
<property name="pwd2"/>
<property name="email"/>
<property name="firstName"/>
<property name="lastName"/>
<property name="birthDate"/>
<property name="address"/>
<property name="city1"/>
<property name="city2"/>
<property name="province"/>
<property name="country"/>
<property name="post"/>
<property name="sex"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

User theUser = new User(userName, displayName, pwd1, pwd2, email, firstName, lastName, birthDate, address, city1, city2, province, country, post, sex);
Session s = factory.openSession();
Transaction tx = s.beginTransaction();
s.save(theUser);
tx.commit();
s.close();
return theUser;

Full stack trace of any exception that occurs:

org.hibernate.MappingException: Unknown entity: com.adsmack.framework.domain.User
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1086)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:83)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
at com.adsmack.framework.persistence.hibernateDAO.HibernateUserDAO.createUser(HibernateUserDAO.java:51)
at com.adsmack.framework.business.helpers.UserHelper.createUser(UserHelper.java:31)
at com.adsmack.framework.presentation.user.registration.RegistrationPortlet.processAction(RegistrationPortlet.java:215)
at org.apache.jetspeed.factory.JetspeedPortletInstance.processAction(JetspeedPortletInstance.java:90)
at org.apache.jetspeed.container.JetspeedContainerServlet.doGet(JetspeedContainerServlet.java:215)
at org.apache.jetspeed.container.JetspeedContainerServlet.doPost(JetspeedContainerServlet.java:289)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
at org.apache.jetspeed.container.invoker.ServletPortletInvoker.invoke(ServletPortletInvoker.java:212)
at org.apache.jetspeed.container.invoker.ServletPortletInvoker.action(ServletPortletInvoker.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:284)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:163)
at $Proxy9.action(Unknown Source)
at org.apache.pluto.PortletContainerImpl.processPortletAction(PortletContainerImpl.java:150)
at org.apache.jetspeed.container.JetspeedPortletContainerWrapper.processPortletAction(JetspeedPortletContainerWrapper.java:100)
at org.apache.jetspeed.pipeline.valve.impl.ActionValveImpl.invoke(ActionValveImpl.java:75)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invokeNext(JetspeedPipeline.java:203)
at org.apache.jetspeed.container.ContainerValve.invoke(ContainerValve.java:76)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invokeNext(JetspeedPipeline.java:203)
at org.apache.jetspeed.profiler.impl.ProfilerValveImpl.invoke(ProfilerValveImpl.java:134)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invokeNext(JetspeedPipeline.java:203)
at org.apache.jetspeed.security.impl.LoginValidationValveImpl.invoke(LoginValidationValveImpl.java:109)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invokeNext(JetspeedPipeline.java:203)
at org.apache.jetspeed.security.impl.PasswordCredentialValveImpl.invoke(PasswordCredentialValveImpl.java:131)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invokeNext(JetspeedPipeline.java:203)
at org.apache.jetspeed.security.impl.AbstractSecurityValve$1.run(AbstractSecurityValve.java:117)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Unknown Source)
at org.apache.jetspeed.security.impl.AbstractSecurityValve.invoke(AbstractSecurityValve.java:111)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invokeNext(JetspeedPipeline.java:203)
at org.apache.jetspeed.container.url.impl.PortalURLValveImpl.invoke(PortalURLValveImpl.java:55)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invokeNext(JetspeedPipeline.java:203)
at org.apache.jetspeed.capabilities.impl.CapabilityValveImpl.invoke(CapabilityValveImpl.java:127)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invokeNext(JetspeedPipeline.java:203)
at org.apache.jetspeed.localization.impl.LocalizationValveImpl.invoke(LocalizationValveImpl.java:124)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invokeNext(JetspeedPipeline.java:203)
at org.apache.jetspeed.pipeline.JetspeedPipeline.invoke(JetspeedPipeline.java:185)
at org.apache.jetspeed.engine.AbstractEngine.service(AbstractEngine.java:264)
at org.apache.jetspeed.engine.JetspeedServlet.doGet(JetspeedServlet.java:225)
at org.apache.jetspeed.engine.JetspeedServlet.doPost(JetspeedServlet.java:252)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)


Name and version of the database I am using:
MySQL 4.1.12


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 1:03 pm 
Regular
Regular

Joined: Thu May 26, 2005 2:08 pm
Posts: 99
Odds are decent that your mapping file isn't on your classpath. Open up your WAR/EAR file and make sure that User.hbm.xml is where you expect it to be.


Top
 Profile  
 
 Post subject: MappingException
PostPosted: Wed Aug 03, 2005 2:27 pm 
Newbie

Joined: Mon Jul 25, 2005 12:58 pm
Posts: 5
Thanks for your reply. User.hbm.xml is in my classpath.
I forgot to mention that I'm using portlet. I was able to add data using hibernate when I ran my test class. So I think the problem might exist with my portlet. I get the error on s.save(theUser) line. Any replies would be very appreciate it.


Top
 Profile  
 
 Post subject: Re: MappingException
PostPosted: Wed Aug 03, 2005 2:40 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
bob54724 wrote:
Thanks for your reply. User.hbm.xml is in my classpath.
I forgot to mention that I'm using portlet. I was able to add data using hibernate when I ran my test class. So I think the problem might exist with my portlet. I get the error on s.save(theUser) line. Any replies would be very appreciate it.


Can you query users from within the Portlet ?

If not, make sure that you have the mapping element -
Code:
<mapping resource="com/adsmack/framework/domain/User.hbm.xml"/>

in your hibernate.cfg.xml file.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject: Re: MappingException
PostPosted: Wed Aug 03, 2005 3:05 pm 
Newbie

Joined: Mon Jul 25, 2005 12:58 pm
Posts: 5
Data cannot be inserted into the table at this point. User.xml is in my configuration file. I also gave credits to those who replied to me. It seems like it's missing something but I just don't know what...
Thanks for any tips in advance.


Top
 Profile  
 
 Post subject: Re: MappingException
PostPosted: Wed Aug 03, 2005 3:11 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
bob54724 wrote:
Data cannot be inserted into the table at this point. User.xml is in my configuration file. I also gave credits to those who replied to me. It seems like it's missing something but I just don't know what...
Thanks for any tips in advance.


Everything I see looks correct.

Can you enter data manually, and then try and query it ?

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject: Re: MappingException
PostPosted: Wed Aug 03, 2005 3:19 pm 
Newbie

Joined: Mon Jul 25, 2005 12:58 pm
Posts: 5
[quote="pksiv]
Can you enter data manually, and then try and query it ?[/quote]

Thanks for your quick reply. Yes, my JUnit class runs fine and inserts data into the table. So I'm guessing this isn't really a mapping issue?? But I'm new to Hibernate so I could be wrong.


Top
 Profile  
 
 Post subject: Re: MappingException
PostPosted: Wed Aug 03, 2005 3:37 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
bob54724 wrote:
[quote="pksiv]
Can you enter data manually, and then try and query it ?


Thanks for your quick reply. Yes, my JUnit class runs fine and inserts data into the table. So I'm guessing this isn't really a mapping issue?? But I'm new to Hibernate so I could be wrong.[/quote]

I would look at how your SessionFactory is being configured - in the Portlet code - and make sure it's finding and loading the classes/mappings.

Also, if you have data in the database you are using, can you just try and code a simple query against it and see if it retrieves the rows correcly ?

It won't (always) throw an exception on a query, it just won't return any results.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.