cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Zeigler <robert.zeig...@roxanemy.com>
Subject Re: Wicket and Cayenne
Date Thu, 02 Dec 2010 19:47:26 GMT
filter ordering is important here. 
Wicket is implemented as a servlet filter, right?
So you need the cayenne filter applied before the wicket filter so it has a chance to bind
the context before wicket does its thing.
Filters are applied in the order that their <filter-mappings> are listed.  So move the
<filter-mapping> for the cayenne servlet above the <filter-mapping> for the wicket.lockbox
filter.

Robert

On Dec 2, 2010, at 12/21:39 PM , Mark Fischer wrote:

> I am stuck again.  I can get my wicket page to load but the first thing I
> see is:
> 
> WicketMessage: Can't instantiate page using constructor public .......
> 
> 
> Stacktrace
> 
> Root cause:
> 
> java.lang.IllegalStateException: Current thread has no bound ObjectContext.
>     at org.apache.cayenne.BaseContext.getThreadObjectContext(BaseContext.java:73)
> 
> .......
> 
> 
> My web.xml looks like this:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> <display-name>lockbox</display-name>
> 	 <filter-mapping>
>  <filter-name>wicket.lockbox</filter-name>
>  <url-pattern>/*</url-pattern>
> </filter-mapping>
> 
> <filter-mapping>
>        <filter-name>CayenneFilter</filter-name>
>        <servlet-name>ClickServlet</servlet-name>
>    </filter-mapping>
> 
> <filter>
>  <filter-name>wicket.lockbox</filter-name>
>  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
>  <init-param>
>   <param-name>applicationClassName</param-name>
>   <param-value>***.*****.****.WicketApplication</param-value>
>  </init-param>
> </filter>
> 
> <filter>
>        <filter-name>CayenneFilter</filter-name>
>        <filter-class>org.apache.cayenne.conf.WebApplicationContextFilter</filter-class>
>    </filter>
> </web-app>
> 
> my java code looks like:
> 
> import org.apache.cayenne.ObjectContext;
> import org.apache.cayenne.access.DataContext;
> import org.apache.cayenne.query.SelectQuery;
> import java.util.*;
> import org.apache.wicket.request.mapper.parameter.PageParameters;
> import org.apache.wicket.markup.html.WebPage;
> import ***.******.lockbox.persistent.*;
> 
> 
> 
> /**
> * Home page
> * @param <ObjectContext>
> */
> public class HomePage<BaseContext> extends WebPage {
> 
> 	private static final long serialVersionUID = 1L;
> 
> 	// TODO Add any page properties or variables here
> 
>    /**
> 	 * Constructor that is invoked when page is invoked without a session.
> 	 *
> 	 * @param parameters
> 	 *            Page parameters
> 	 */
>    public HomePage(final PageParameters parameters) {
>    	
>    	//DataContext context = DataContext.createDataContext();
>    	//DataContext context = (DataContext)BaseContext.getThreadObjectContext();
>    	//ObjectContext context = DataContext.getThreadObjectContext();    	
>    	//ObjectContext oc = BaseContext.getThreadObjectContext();
> 
> ObjectContext context = DataContext.getThreadObjectContext();
> 
> 
> SelectQuery select1 = new SelectQuery(Credentials.class);
> List CredentialsList = context.performQuery(select1);
> 
> // Add the simplest type of label
> //add(new Label("message", "If you see this message wicket is properly
> configured and running"));
> 
> add(new Label("message", CredentialsList.toString()));
> 
> // TODO Add your page's components here
> }
> }


Mime
View raw message