Hi all,
I have a Sping MVC webapp that access a database using Hibernate, using some beans and all work fine.
I also plugged in Spring Ws and published some services, but for one service I need to access one database using the same beans already defined for the Spring MVC.
One of these beans use the getHibernateTemplate().findByNamedQuery method, but when I try to call services exposed by this bean I get the exception
.
My web.xml is as follow:
The Hibernate beans are defined into the dataAccessContext.xml file:
and the hbm file is as follow:
When I call services from JUnit or from the MVC app using named query (say for example AttivitaUtente.byLogin) all works fine, but when I call same services from my Spring ws web service I get the exception.
Could someone help me?
Thanks in advance.
Riccardo.
I have a Sping MVC webapp that access a database using Hibernate, using some beans and all work fine.
I also plugged in Spring Ws and published some services, but for one service I need to access one database using the same beans already defined for the Spring MVC.
One of these beans use the getHibernateTemplate().findByNamedQuery method, but when I try to call services exposed by this bean I get the exception
Code:
org.hibernate.MappingException: Named query not known
My web.xml is as follow:
Code:
... <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/classes/config/dataAccessContext.xml /WEB-INF/classes/config/applicationContext.xml /WEB-INF/classes/config/deployerConfigContext.xml </param-value> </context-param> ... <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> ... <servlet> <servlet-name>anagrafeweb</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> ... <servlet> <servlet-name>anagrafe-web-ws</servlet-name> <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class> <init-param> <!-- Transform the location attributes in WSDLs --> <param-name>transformWsdlLocations</param-name> <param-value>true</param-value> </init-param> </servlet> ...
The Hibernate beans are defined into the dataAccessContext.xml file:
Code:
... <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSourcePMA"/> <property name="mappingResources"> <list> <value>it/esel/ge/dao/hibernate/maps/gruppidati.hbm.xml</value> <value>it/esel/ge/dao/hibernate/maps/insiemidati.hbm.xml</value> <value>it/esel/ge/dao/hibernate/maps/colonne.hbm.xml</value> <value>it/esel/ge/dao/hibernate/maps/gruppiutente.hbm.xml</value> <value>it/esel/ge/dao/hibernate/maps/profiloabilitazionegiornaliera.hbm.xml</value> <value>it/esel/ge/dao/hibernate/maps/profiloricercavisualizzazione.hbm.xml</value> <value>it/esel/ge/dao/hibernate/maps/profiloutilizzocolonne.hbm.xml</value> <value>it/esel/ge/dao/hibernate/maps/sottogruppiutente.hbm.xml</value> <value>it/esel/ge/dao/hibernate/maps/accountutenti.hbm.xml</value> <value>it/esel/ge/dao/hibernate/maps/logsdettagliovisualizzazione.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.generate_statistics">false</prop> <prop key="hibernate.bytecode.provider">cglib</prop> <prop key="hibernate.connection.release_mode">after_statement</prop> </props> </property> <property name="eventListeners"> <map> <entry key="merge"> <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/> </entry> </map> </property> </bean> ... <bean id="attivitaUtentiTarget" class="it.esel.ge.dao.hibernate.AttivitaUtentiService"> <property name="sessionFactory" ref="hibernateSessionFactory"/> </bean> <bean id="attivitaUtenti" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="hibernateTransactionManager"/> <property name="target" ref="attivitaUtentiTarget"/> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="store*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> ...
Code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- - Mapping file for the Hibernate implementation of the IAttivitaUtentiService interface. --> <hibernate-mapping auto-import="true" default-lazy="false"> <!-- ***************************************************************************** **************************** Hibernate mappings ***************************** ***************************************************************************** --> <class name="it.esel.ge.beans.ws.AttivitaUtentiResponse" table="pma_utenti" ... <!-- ***************************************************************************** ******************************** HQL QUERIES ******************************** ***************************************************************************** --> <query name="AttivitaUtente.byLogin"> <![CDATA[ ... ]]> </query> ... </hibernate-mapping>
Could someone help me?
Thanks in advance.
Riccardo.
Comment