You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Landry Soules <ca...@gmail.com> on 2007/11/11 20:07:17 UTC
Spring light integration
Hello,
I'm currently working on a web project developped with Wicket and
Cayenne. Everything worked fine but we are now planing to use Spring too.
I've seen the examples on the wiki, but i found it quite complex , since
i don't want to go the DAO way.
Indeed, the only Spring/Cayenne interaction i need is for retrieving
DataContext.
I wrote this in applicationContext.xml:
<bean id="dataContext" class="org.apache.cayenne.access.DataContext"
factory-method="getThreadDataContext" />
<bean id="customPanel" class="eu.kwark.base.CustomPanel">
<property name="context" ref="dataContext" />
</bean>
But when i start my webapp, i get a "java.lang.IllegalStateException:
Current thread has no bound DataContext"
Is there a way to go while keeping it simple and avoiding DAOs ?
Thanks for your help.
Landry
Re: Spring light integration
Posted by Malcolm Edgar <ma...@gmail.com>.
That is all you should need to do.
regards Malcolm Edgar
On Nov 14, 2007 11:52 PM, Landry Soules <ca...@gmail.com> wrote:
> Thanks Malcolm.
>
> I already set my web.xml this way :
>
> <filter>
> <filter-name>CayenneFilter</filter-name>
> <filter-class>
> org.apache.cayenne.conf.WebApplicationContextFilter
> </filter-class>
> </filter>
> <filter-mapping>
> <filter-name>CayenneFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> Is there something else to declare ?
>
> Thanks for your help.
>
> Landry
>
>
>
> Malcolm Edgar a écrit :
> > Hi Landry,
> >
> > You will need to setup a DataContext servlet filter in your web
> application
> > to bind a DataContext to the request thread.
> >
> > regards Malcolm Edgar
> >
> > On Nov 12, 2007 6:07 AM, Landry Soules <ca...@gmail.com> wrote:
> >
> >
> >> Hello,
> >>
> >> I'm currently working on a web project developped with Wicket and
> >> Cayenne. Everything worked fine but we are now planing to use Spring
> too.
> >> I've seen the examples on the wiki, but i found it quite complex ,
> since
> >> i don't want to go the DAO way.
> >> Indeed, the only Spring/Cayenne interaction i need is for retrieving
> >> DataContext.
> >> I wrote this in applicationContext.xml:
> >>
> >> <bean id="dataContext" class="org.apache.cayenne.access.DataContext"
> >> factory-method="getThreadDataContext" />
> >> <bean id="customPanel" class="eu.kwark.base.CustomPanel">
> >> <property name="context" ref="dataContext" />
> >> </bean>
> >>
> >> But when i start my webapp, i get a "java.lang.IllegalStateException:
> >> Current thread has no bound DataContext"
> >>
> >> Is there a way to go while keeping it simple and avoiding DAOs ?
> >>
> >> Thanks for your help.
> >>
> >>
> >> Landry
> >>
> >>
> >
> >
>
>
Re: Spring light integration
Posted by Landry Soules <ca...@gmail.com>.
Thanks Malcolm.
I already set my web.xml this way :
<filter>
<filter-name>CayenneFilter</filter-name>
<filter-class>
org.apache.cayenne.conf.WebApplicationContextFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>CayenneFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Is there something else to declare ?
Thanks for your help.
Landry
Malcolm Edgar a écrit :
> Hi Landry,
>
> You will need to setup a DataContext servlet filter in your web application
> to bind a DataContext to the request thread.
>
> regards Malcolm Edgar
>
> On Nov 12, 2007 6:07 AM, Landry Soules <ca...@gmail.com> wrote:
>
>
>> Hello,
>>
>> I'm currently working on a web project developped with Wicket and
>> Cayenne. Everything worked fine but we are now planing to use Spring too.
>> I've seen the examples on the wiki, but i found it quite complex , since
>> i don't want to go the DAO way.
>> Indeed, the only Spring/Cayenne interaction i need is for retrieving
>> DataContext.
>> I wrote this in applicationContext.xml:
>>
>> <bean id="dataContext" class="org.apache.cayenne.access.DataContext"
>> factory-method="getThreadDataContext" />
>> <bean id="customPanel" class="eu.kwark.base.CustomPanel">
>> <property name="context" ref="dataContext" />
>> </bean>
>>
>> But when i start my webapp, i get a "java.lang.IllegalStateException:
>> Current thread has no bound DataContext"
>>
>> Is there a way to go while keeping it simple and avoiding DAOs ?
>>
>> Thanks for your help.
>>
>>
>> Landry
>>
>>
>
>
Re: Spring light integration
Posted by Malcolm Edgar <ma...@gmail.com>.
Hi Landry,
You will need to setup a DataContext servlet filter in your web application
to bind a DataContext to the request thread.
regards Malcolm Edgar
On Nov 12, 2007 6:07 AM, Landry Soules <ca...@gmail.com> wrote:
> Hello,
>
> I'm currently working on a web project developped with Wicket and
> Cayenne. Everything worked fine but we are now planing to use Spring too.
> I've seen the examples on the wiki, but i found it quite complex , since
> i don't want to go the DAO way.
> Indeed, the only Spring/Cayenne interaction i need is for retrieving
> DataContext.
> I wrote this in applicationContext.xml:
>
> <bean id="dataContext" class="org.apache.cayenne.access.DataContext"
> factory-method="getThreadDataContext" />
> <bean id="customPanel" class="eu.kwark.base.CustomPanel">
> <property name="context" ref="dataContext" />
> </bean>
>
> But when i start my webapp, i get a "java.lang.IllegalStateException:
> Current thread has no bound DataContext"
>
> Is there a way to go while keeping it simple and avoiding DAOs ?
>
> Thanks for your help.
>
>
> Landry
>