Results 1 to 8 of 8

Thread: Hibernate - no par

  1. #1
    Join Date
    Mar 2007
    Location
    Poland
    Posts
    341

    Default Hibernate - no par

    Hi

    I am just trying to prepare a presentation for JUG about Spring DM server. I decided to do a case study of migrating existing application (war) to par. I am on a step to deploy every bundle manually (web, service api, service impl, dao api, domain, utils, dao impl) and having a problem with Hibernate.
    First of all it was a problem with
    Code:
    org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
    But i found workaround on
    http://jira.springframework.org/browse/SPR-5036
    Now i have a problems with executing queries I got:
    Code:
    org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from pl.foo.carDemo.domain.CarMake]
    	at org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:57)
    	at antlr.CharScanner.setTokenObjectClass(CharScanner.java:338)
    	at org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:31)
    	at antlr.CharScanner.<init>(CharScanner.java:49)
    	at antlr.CharScanner.<init>(CharScanner.java:58)
    	at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:56)
    	at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:53)
    	at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:50)
    	at org.hibernate.hql.ast.HqlLexer.<init>(HqlLexer.java:26)
    	at org.hibernate.hql.ast.HqlParser.getInstance(HqlParser.java:44)
    	at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:242)
    	at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
    	at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
    	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
    	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
    	at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
    	at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
    	at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
    	at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
    	at pl.foo.dao.hibernate.CarHibernateDAO.getMakeList(CarHibernateDAO.java:28)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    	at com.springsource.management.agent.monitoring.proxy.DefaultMonitoringInterceptor.monitorAndInvoke(DefaultMonitoringInterceptor.java:66)
    	at com.springsource.management.agent.monitoring.proxy.DefaultMonitoringInterceptor.invoke(DefaultMonitoringInterceptor.java:57)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:64)
    	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:78)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy76.invoke(Unknown Source)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at com.springsource.management.agent.monitoring.proxy.DefaultMonitoringInterceptor.monitorAndInvoke(DefaultMonitoringInterceptor.java:66)
    	at com.springsource.management.agent.monitoring.proxy.DefaultMonitoringInterceptor.invoke(DefaultMonitoringInterceptor.java:57)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:64)
    	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:78)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy15.invoke(Unknown Source)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy125.getMakeList(Unknown Source)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:64)
    	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:78)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy114.getMakeList(Unknown Source)
    I was forced to shorten stacktrace but hope all relevant info are provided

    I have downloaded (by Spring DM eclipse tools ) library "org.hibernate.ejb-library-3.3.2.GA.libd" and have it imported by both domain and hibernate-dao-impl bundles (as stated in programming guide)

    After some googling i have found that it can be mainly by antlr problems but i am too newbie to OSGI to check it out - i have tried to import antlr package , antlr bundle but with no success...

    Does anyone have any idea?

  2. #2
    Join Date
    Jan 2006
    Location
    Zürich, Switzerland
    Posts
    423

    Default

    Hi miluch,

    Quote Originally Posted by miluch View Post
    Code:
    org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from pl.foo.carDemo.domain.CarMake]
    Based on this stacktrace, I would assume that you simply need to import the Hibernate library in your domain bundle as well as in your DAO implementation bundle.

    Quote Originally Posted by miluch View Post
    I have downloaded (by Spring DM eclipse tools ) library "org.hibernate.ejb-library-3.3.2.GA.libd" and have it imported by both domain and hibernate-dao-impl bundles (as stated in programming guide)
    But... since you say you've already done this, my recommendation is to have a look at the Hibernate version of the Pet Clinic sample application, which you can find here.

    Note: the Pet Clinic sample uses Hibernate within a PAR and thus relies on the import-scope:=application attribute in the repository bundle's manifest to import the Hibernate bundle across the PAR. Thus the main difference between the sample application and your application -- which runs outside a PAR -- is that you'll need to explicitly import the Hibernate library or bundle in other bundles which need it (e.g., the domain bundle).

    Just out curiosity, did you restart the dm Server after you installed the Hibernate library and bundles?

    Hope this helps,

    Sam

  3. #3
    Join Date
    Mar 2007
    Location
    Poland
    Posts
    341

    Default

    PetClinic is what i am relying on.
    As you know it is a par and i just wanna to deploy all modules as seperate units.

    I tried to experiment a little bit
    - import hibernate bundle as shown in PetClinic example : com.springsource.org.hibernate;version="[3.2.6.ga,3.2.6.ga]"
    in both dao and domain bundle and then have it imported only in dao
    - have it imported with import-scope:=application directive
    - import library as stated in programming guide in both domain and dao and then only in dao...
    After each of the changes i restarted server.

    Still no success - hibernate as mapping tool works in all the scenarios - i can use load/get but unable to execute hql query.
    PetClinic with hibernate works on my server as a charm...

    I do not know what i can do more to diagnose problem ...

  4. #4
    Join Date
    Jan 2006
    Location
    Zürich, Switzerland
    Posts
    423

    Default

    Hi miluch,

    Quote Originally Posted by miluch View Post
    Still no success - hibernate as mapping tool works in all the scenarios - i can use load/get but unable to execute hql query.
    PetClinic with hibernate works on my server as a charm...

    I do not know what i can do more to diagnose problem ...
    Sounds like this might be a bug.

    Can you please create a JIRA issue and attach a small application which reproduces the exact problem you're encountering? That would help us better track down and solve the issue.

    Thanks in advance,

    Sam

  5. #5
    Join Date
    Mar 2007
    Location
    Poland
    Posts
    341

    Default

    Hi

    As you stated I have just created jira issue https://issuetracker.springsource.co...e/PLATFORM-182
    Thanks for your help.

  6. #6
    Join Date
    Jan 2006
    Location
    Zürich, Switzerland
    Posts
    423

    Default

    Thanks for creating the JIRA issue and especially for providing the sample application to reproduce it!

    We'll take a look at it.

    Regards,

    Sam

  7. #7
    Join Date
    Jan 2006
    Location
    Southampton, UK
    Posts
    117

    Default

    For anyone watching, the solution to this issue is detailed in this JIRA issue

    https://issuetracker.springsource.co...e/PLATFORM-182
    Ben Hale
    tc Server Team Core Developer
    http://www.springsource.com/products/tcserver

  8. #8
    Join Date
    Mar 2007
    Location
    Poland
    Posts
    341

    Default

    For everyone still interested in a topic:
    if you prefer to use annotations to configure your entities you must additionally import hibernate bundle/library(if you plan to use hibernate custom annotations) in Domain bundle as well - just as stated in programing guide.

    For hibernate xml configuration import hibernate bundle in DAO implementation is enough.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •