-->
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: Two hibernate app within JbossAS giving QuerySyntaxException
PostPosted: Thu Nov 13, 2008 8:05 am 
Newbie

Joined: Thu Nov 13, 2008 7:23 am
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2.6

Mapping documents:

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

Full stack trace of any exception that occurs:
org.hibernate.hql.ast.QuerySyntaxException: TUploadedjobs is not mapped. [from TUploadedjobs jobs where jobs.TUploadedjobstatus.status = 'U' order by jobs.uploaddate desc ]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:145)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:86)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:262)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3041)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2930)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:216)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:156)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:103)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:473)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1060)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1010)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at <myclass1>.executeNamedParameterQuery(myclass1.java:119)
at <myclass2>(<myclass2>.java:48)
at <myclass2>(<myclass2>.java:99)
at <myclass3>(<myclass3>.java:68)
at java.lang.Thread.run(Thread.java:595)
Caused by: TUploadedjobs is not mapped.
... 22 more

Name and version of the database you are using: Postgresql 8.2

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Hi
I have a webservice and a jboss mbean service running on a JBoss AS (4.0.3sp1). They both have their own set of hibernate.cfg.xml and other mapping files.

The hibernate.cfg.xml files though, point to the same database and some of the mapping files point to the same tables (with same class names because the persistence classes are within a jar file which is shared by both the apps).

Sometimes I get the above mentioned exception. There is no problem in mapping. The exception does not occur when only the webservice is running or only the jboss mbean service is running. It only happens when both are deployed together.

Question
1. Why do I get this exception and what has it got to do with two apps being deployed at the same time?
2. Does hibernate share sessionfactories ?
3. Do session factory names make any difference in my case ?
4. When Jboss starts deploying the apps - does it make any diffrence to which app is deployed first ?
5. When Jboss builds a factory for one app and in the process maps all classes with mapping files - will it skip doing so for the same named classes in mapping files for the next app while builds its session factory ?
Does this have anything to do with Class Loading in JBoss+Hibernate ?
6. How does this change when Hibernate session factories are configured using JMX beans ?

I would really appreciate if someone explains whats happenning here and helps me get over this exception.

Thanks
Regards
Deb


Top
 Profile  
 
 Post subject: Re: Two hibernate app within JbossAS giving QuerySyntaxException
PostPosted: Tue Sep 08, 2009 10:30 am 
Newbie

Joined: Thu Nov 13, 2008 7:23 am
Posts: 6
No one replied to this question.
I still have the same query.
Is any one aware of reasons ?


Top
 Profile  
 
 Post subject: Re: Two hibernate app within JbossAS giving QuerySyntaxException
PostPosted: Tue Sep 08, 2009 10:47 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I'm guessing there's a classpath problem?

Do you have two different config files in two different jar files? I bet the mappings are different, and depending upon how the application is first hit, a different mapping file is loaded.

Look for multiple mapping files in your classpath.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Two hibernate app within JbossAS giving QuerySyntaxException
PostPosted: Wed Sep 09, 2009 2:36 am 
Newbie

Joined: Thu Nov 13, 2008 7:23 am
Posts: 6
Hi Cameron thanks for replying
The problem is like this

I have two services deployed on the same Jboss server. One is a jboss mbean service and one a web service.
Due to security reasons - though both of these applications access the same database -
their privilege on insert/update/access/view of tables and columns is different.

SO
Though they use the same database - I have different set of hbm.xml and cfg.xml files.
App1 (war file) has 5 hbm.xml files and one cfg.xml file (referencing those 5 files).
App1 (exploded sar) has 15 hbm.xml files and its own cfg.xml file (referencing those 15 files)
Both the cfg.xml files point to the same DS.

4 hbm.xml files point to the same table in both the apps. But the content (included columns + insert update rules etc)
of these hbm.xml files are different due to security.

The Table classes are in a jar file which is in the shared lib directory (server/default/lib).

The problem I get is when hibernate tries to fire a query against one of these common table referencing hbm.xml files from App2.

Now - can you tell me how Hibernate works in the situation ?
If I know exactly how Hibernate works then I am sure I will understand the problem.

So my question is
If there are multiple apps on a server with their own cfg.xml files and mapping files while the dao classes are shared - how does Hibernate work when the apps get deployed one by one? Does it create two completely separate workspace with two different session factories OR is there a possibility of it re using a mapping which has already been mapped from a previously deployed application if it finds that it is mapping to the same table ?
You wrote "I bet the mappings are different, and depending upon how the application is first hit, a different mapping file is loaded."
- can you explain this from my situation ?

What happens if these two different apps have same session factory name in their cfg.xml files. Would that mess it up ?

Looking forward to your help on this. Please reply
Thanks
Deb


Top
 Profile  
 
 Post subject: Re: Two hibernate app within JbossAS giving QuerySyntaxException
PostPosted: Fri Sep 11, 2009 2:24 am 
Newbie

Joined: Thu Nov 13, 2008 7:23 am
Posts: 6
Cameron can you please reply my last post on this tread .
Thanks
Deb


Top
 Profile  
 
 Post subject: Re: Two hibernate app within JbossAS giving QuerySyntaxException
PostPosted: Fri Sep 11, 2009 3:02 am 
Newbie

Joined: Sat Jul 23, 2005 1:57 am
Posts: 2
Quote:
What happens if these two different apps have same session factory name in their cfg.xml files. Would that mess it up ?

The answer is no it won't mess them up.
You need to check which mapping files applied to the sessionFactory, which boils down to how you build your sessionFactory.


Top
 Profile  
 
 Post subject: Re: Two hibernate app within JbossAS giving QuerySyntaxException
PostPosted: Fri Sep 11, 2009 7:13 am 
Newbie

Joined: Thu Nov 13, 2008 7:23 am
Posts: 6
Well - that what I thought too
But
Read
http://docs.jboss.org/jbossas/jboss4gui ... /ch13.html.
It says "If you are deploying multiple Hibernate applications in the server, make sure to choose a unique name. "

And can you explain what you mean by
"You need to check which mapping files applied to the sessionFactory"
As I said each app has its own set of configuration file and mapping files.
And each application builds it session factory from its own configuration file - or
(at least that is what I expect)


Top
 Profile  
 
 Post subject: Re: Two hibernate app within JbossAS giving QuerySyntaxException
PostPosted: Thu Sep 17, 2009 1:56 am 
Newbie

Joined: Thu Nov 13, 2008 7:23 am
Posts: 6
Can anyone comment please. I still do not have the answer.


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.