cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrus Adamchik (Closed) (JIRA)" <>
Subject [jira] [Closed] (CAY-1673) Running ROP and CayenneFilter on same project
Date Sun, 04 Mar 2012 19:43:00 GMT


Andrus Adamchik closed CAY-1673.

    Resolution: Fixed

After some analysis and consideration I decided against "fixing" the issue, and rather added
a startup check for an existing configuration that throws an exception:

if (WebUtil.getCayenneRuntime(context) != null) {
            throw new ServletException(
                    "CayenneRuntime is already configured in the servlet environment");

The reasons behind it are the following:

1. I'd like to preserve immutability of the CayenneRuntime and Injector configurations. This
makes them predictable and avoids synchronization or lazy init.

2. CayenneFilter (and to a lesser extent - ROPHessianServlet) is a "sample" of how Cayenne
might be bootsrapped in a web app, and but by no means the only or the preferred way. We've
always recognized that different webapps have different mechanisms to configure their "services",
such as Spring, etc. CayenneFilter was designed as a template that can be followed with whatever
configuration approach is used. It is simplistic by design and is not intended to be integrated
(rather it is intended to be *copied*) into advanced configuration solutions. 

> Running ROP and CayenneFilter on same project
> ---------------------------------------------
>                 Key: CAY-1673
>                 URL:
>             Project: Cayenne
>          Issue Type: Bug
>          Components: ROP
>    Affects Versions: 3.1M3
>         Environment: Tomcat 7.0.14
>            Reporter: Jozef DropĨo
>            Assignee: Andrus Adamchik
>   Original Estimate: 20m
>  Remaining Estimate: 20m
> mapping for CayenneFilter is "/*" and I have ROPHessianServlet mounted on "/hessian".
The problem is when I start the project webpages run perfectly, but after first call on ROPHessianServlet,
I've got this error:
> org.apache.cayenne.ConfigurationException: [v.3.1M3 Sep 12 2011 19:59:45] DI container
has no binding for key <BindingKey: org.apache.cayenne.configuration.web.RequestHandler>
> 	at org.apache.cayenne.di.spi.DefaultInjector.getProvider(
> 	at org.apache.cayenne.di.spi.DefaultInjector.getProvider(
> 	at org.apache.cayenne.di.spi.DefaultInjector.getInstance(
> 	at org.apache.cayenne.configuration.web.CayenneFilter.doFilter(
> I find out that this error is caused because in init method of ROPHessianServlet is no
merging between existing ServerContext and new ServerContext created by servlet.
> I also fixed this bug by modifing the code like this:
> ....
>         CayenneRuntime currentRuntime = WebUtil.getCayenneRuntime(servletContext);
>         ArrayList<Module> modules = new ArrayList<Module>();
>         if (currentRuntime != null) {
>             modules.addAll(Arrays.asList(currentRuntime.getModules()));
>         }
>         modules.add(new ROPServerModule(
>                 eventBridgeParameters));
>         ServerRuntime runtime = new ServerRuntime(configurationLocation, modules.toArray(new
> ....

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message