cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger" <mkien...@gmail.com>
Subject Re: Current thread has no bound DataContext (zk integration)
Date Mon, 25 Aug 2008 14:17:21 GMT
Mambo, you might also take a look at Steve's other thread on ZK and
thread-safety issues.

http://osdir.com/ml/java.cayenne.user/2007-05/msg00067.html

On 8/24/08, Steve Wells <websystemz@gmail.com> wrote:
> The way I seem (seem as I am yet to *fully* test this) to have solved that
>  is to use Spring to create the ObjectContext and then you inject that in to
>  whatever else you want.  This will not be Thread bound but Singleton, I
>  guess in Spring you could write (or copy) a Thread bound scope if required.
>  eg:
>   <bean id="myObjectContext" class="org.apache.cayenne.access.DataContext"
>   factory-method="createDataContext" scope="singleton">
>   <constructor-arg value="MyDomain"/>
>   </bean>
>  <!-- A data layer controller/convenience function layer -->
>  <bean id="dataServices" class="com.mypackage.dataservices.DataServices">
>   <property name="objectContext">
>   <ref local="myObjectContext"/>
>   </property>
>   </bean>
>  public class DataServices {
>   private ObjectContext objectContext;
>
>   public ObjectContext getObjectContext() {
>   return objectContext;
>   }
>
>   public void setObjectContext(ObjectContext objectContext) {
>   this.objectContext = objectContext;
>   }
>
>
>  HTH
>  Steve
>  2008/8/23 mambo <ikonicpatterns@gmail.com>
>
>
>  > I've been looking through the mailing list and I can't find a definite
>  > answer. I'm using ZK, I have added:
>  > <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>
>  >
>  > to my web.xml. When I try "DataContext context  =
>  > DataContext.getThreadDataContext();" I get an exception that says "Current
>  > thread has no bound DataContext". I'm figuring this is because ZK is multi
>  > threaded. I'm pretty new to Java so I'm not really comfortable trying to
>  > hack the cayanne source to get things to run. Is there a solution for this?
>  > If i created a new Datacontext with each Database request, how badly would
>  > that affect performance of my web app?
>  >
>

Mime
View raw message