NoSuchMethodError: org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

NoSuchMethodError: org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;

okello
Hi,

I'm using Hibernate Spatial with Spring. I have the following spatial query:

@SuppressWarnings("unchecked")
        @Override
        public List<Admin> getAffectedAdmins(String wktFilter) {
                WKTReader fromText = new WKTReader();
                Geometry filter = null;
               
                try {
                        filter = fromText.read(wktFilter);
                        System.out.println("Filter = " + filter);
                } catch (ParseException e) {
                        e.printStackTrace();
                }
               
                hibernateTemplate = new HibernateTemplate(sessionFactory);
                List<Admin> admins = new ArrayList<Admin>();
                admins =  (List<Admin>) hibernateTemplate.findByCriteria(
                        DetachedCriteria.forClass(Admin.class)
                        .add(SpatialRestrictions.eq("geom", filter)));
               
                return admins;
        }

The application compiles and installs successfully. I'm using Tomcat
for my tests. However, when I call the above method, the following
exception is thrown:

org.springframework.web.util.NestedServletException: Handler
processing failed; nested exception is java.lang.NoSuchMethodError:
org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:972)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

java.lang.NoSuchMethodError:
org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;
        org.hibernate.spatial.criterion.SpatialRelateExpression.toSqlString(SpatialRelateExpression.java:93)
        org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:380)
        org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:113)
        org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
        org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
        org.hibernate.impl.SessionImpl.list(SessionImpl.java:1697)
        org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
        org.springframework.orm.hibernate3.HibernateTemplate$36.doInHibernate(HibernateTemplate.java:1056)
        org.springframework.orm.hibernate3.HibernateTemplate$36.doInHibernate(HibernateTemplate.java:1)
        org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
        org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
        org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1046)
        org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1039)
        com.populationexplorer.dao.impl.PEDAOImpl.getAffectedAdmins(PEDAOImpl.java:43)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        java.lang.reflect.Method.invoke(Method.java:597)
        org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
        org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
        org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        $Proxy16.getAffectedAdmins(Unknown Source)
        com.populationexplorer.controller.PEWSController.getCapabilities(PEWSController.java:28)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        java.lang.reflect.Method.invoke(Method.java:597)
        org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
        org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
        org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
        org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
        org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
        org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Thanks in advance.

Kind Regards,
Okello Nelson.
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: NoSuchMethodError: org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;

Samuel Gendler
I don't have a good answer for you since idont use criteria queries but I do spatial queries via Hql without such problems. Have you tried that?

Sent from my iPhone

On Aug 27, 2012, at 12:40 AM, Okello Nelson <[hidden email]> wrote:

> Hi,
>
> I'm using Hibernate Spatial with Spring. I have the following spatial query:
>
> @SuppressWarnings("unchecked")
>    @Override
>    public List<Admin> getAffectedAdmins(String wktFilter) {
>        WKTReader fromText = new WKTReader();
>        Geometry filter = null;
>        
>        try {
>            filter = fromText.read(wktFilter);
>            System.out.println("Filter = " + filter);
>        } catch (ParseException e) {
>            e.printStackTrace();
>        }
>        
>        hibernateTemplate = new HibernateTemplate(sessionFactory);
>        List<Admin> admins = new ArrayList<Admin>();
>        admins =  (List<Admin>) hibernateTemplate.findByCriteria(
>                DetachedCriteria.forClass(Admin.class)
>                .add(SpatialRestrictions.eq("geom", filter)));
>        
>        return admins;
>    }
>
> The application compiles and installs successfully. I'm using Tomcat
> for my tests. However, when I call the above method, the following
> exception is thrown:
>
> org.springframework.web.util.NestedServletException: Handler
> processing failed; nested exception is java.lang.NoSuchMethodError:
> org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;
>    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:972)
>    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
>    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
>    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
>    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
>    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>
> root cause
>
> java.lang.NoSuchMethodError:
> org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;
>    org.hibernate.spatial.criterion.SpatialRelateExpression.toSqlString(SpatialRelateExpression.java:93)
>    org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:380)
>    org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:113)
>    org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
>    org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
>    org.hibernate.impl.SessionImpl.list(SessionImpl.java:1697)
>    org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
>    org.springframework.orm.hibernate3.HibernateTemplate$36.doInHibernate(HibernateTemplate.java:1056)
>    org.springframework.orm.hibernate3.HibernateTemplate$36.doInHibernate(HibernateTemplate.java:1)
>    org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
>    org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
>    org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1046)
>    org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1039)
>    com.populationexplorer.dao.impl.PEDAOImpl.getAffectedAdmins(PEDAOImpl.java:43)
>    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>    java.lang.reflect.Method.invoke(Method.java:597)
>    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
>    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
>    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
>    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
>    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>    $Proxy16.getAffectedAdmins(Unknown Source)
>    com.populationexplorer.controller.PEWSController.getCapabilities(PEWSController.java:28)
>    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>    java.lang.reflect.Method.invoke(Method.java:597)
>    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
>    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
>    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
>    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
>    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
>    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
>    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
>    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
>    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
>    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
>    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
>    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>
> Thanks in advance.
>
> Kind Regards,
> Okello Nelson.
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: NoSuchMethodError: org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;

okello
Hi Sam,

I sorted this out. I had dependency conflicts; a mixture of hibernate3
and hibernate4 dependencies. Updated my pom, and spring config file.
Everything now works.

Kind Regards,
Okello Nelson.

On Mon, Aug 27, 2012 at 7:31 PM, Sam Gendler <[hidden email]> wrote:

> I don't have a good answer for you since idont use criteria queries but I do spatial queries via Hql without such problems. Have you tried that?
>
> Sent from my iPhone
>
> On Aug 27, 2012, at 12:40 AM, Okello Nelson <[hidden email]> wrote:
>
>> Hi,
>>
>> I'm using Hibernate Spatial with Spring. I have the following spatial query:
>>
>> @SuppressWarnings("unchecked")
>>    @Override
>>    public List<Admin> getAffectedAdmins(String wktFilter) {
>>        WKTReader fromText = new WKTReader();
>>        Geometry filter = null;
>>
>>        try {
>>            filter = fromText.read(wktFilter);
>>            System.out.println("Filter = " + filter);
>>        } catch (ParseException e) {
>>            e.printStackTrace();
>>        }
>>
>>        hibernateTemplate = new HibernateTemplate(sessionFactory);
>>        List<Admin> admins = new ArrayList<Admin>();
>>        admins =  (List<Admin>) hibernateTemplate.findByCriteria(
>>                DetachedCriteria.forClass(Admin.class)
>>                .add(SpatialRestrictions.eq("geom", filter)));
>>
>>        return admins;
>>    }
>>
>> The application compiles and installs successfully. I'm using Tomcat
>> for my tests. However, when I call the above method, the following
>> exception is thrown:
>>
>> org.springframework.web.util.NestedServletException: Handler
>> processing failed; nested exception is java.lang.NoSuchMethodError:
>> org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;
>>    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:972)
>>    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
>>    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
>>    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
>>    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
>>    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>>
>> root cause
>>
>> java.lang.NoSuchMethodError:
>> org.hibernate.criterion.CriteriaQuery.getFactory()Lorg/hibernate/engine/spi/SessionFactoryImplementor;
>>    org.hibernate.spatial.criterion.SpatialRelateExpression.toSqlString(SpatialRelateExpression.java:93)
>>    org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:380)
>>    org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:113)
>>    org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
>>    org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
>>    org.hibernate.impl.SessionImpl.list(SessionImpl.java:1697)
>>    org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
>>    org.springframework.orm.hibernate3.HibernateTemplate$36.doInHibernate(HibernateTemplate.java:1056)
>>    org.springframework.orm.hibernate3.HibernateTemplate$36.doInHibernate(HibernateTemplate.java:1)
>>    org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
>>    org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
>>    org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1046)
>>    org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:1039)
>>    com.populationexplorer.dao.impl.PEDAOImpl.getAffectedAdmins(PEDAOImpl.java:43)
>>    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>    java.lang.reflect.Method.invoke(Method.java:597)
>>    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
>>    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
>>    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
>>    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
>>    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>>    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>>    $Proxy16.getAffectedAdmins(Unknown Source)
>>    com.populationexplorer.controller.PEWSController.getCapabilities(PEWSController.java:28)
>>    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>    java.lang.reflect.Method.invoke(Method.java:597)
>>    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
>>    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
>>    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
>>    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
>>    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
>>    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
>>    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
>>    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
>>    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
>>    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
>>    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
>>    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>>
>> Thanks in advance.
>>
>> Kind Regards,
>> Okello Nelson.
>> _______________________________________________
>> hibernatespatial-users mailing list
>> [hidden email]
>> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users



--
Kind Regards,
Okello Nelson
+254 722 137 826
[hidden email]
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users