You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Per Newgro <pe...@gmx.ch> on 2007/12/22 11:12:53 UTC

Two wicket applications in one spring context

Hi *

i try to adapt the phonebook example to my needs. What i try to achieve is to 
develop an admin part and an user part of my application. I would like to 
connect to my applications by two urls (localhost:8080 and 
localhost:8080/admin). So i think i have to develop two applications. They 
share much code. So i would like to develop them both in same maven project.

But. If i try it my way it seems to conflict with spring conditions. How could 
i solve this? Maybe i use the wrong example?

Thanks for your help
Per

web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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" version="2.4">

<display-name>accommodationOffice</display-name>

<!--  
  There are three means to configure Wickets configuration mode and they are
  tested in the order given. 
  1) A system property: -Dwicket.configuration
  2) servlet specific <init-param>
  3) context specific <context-param>
  The value might be either "development" (reloading when templates change)
  or "deployment". If no configuration is found, "development" is the default.
-->
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:applicationContext.xml</param-value>
</context-param>

<listener>
  
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<filter>
  <filter-name>wicket.accommodationOffice</filter-name>
  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
  <init-param>
    <param-name>applicationFactoryClassName</param-name>
    
<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
  </init-param>
  <init-param>
    <param-name>beanName</param-name>
    <param-value>officeApplication</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</filter>

<filter>
  <filter-name>wicket.accommodationOffice.admin</filter-name>
  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
  <init-param>
     <param-name>applicationFactoryClassName</param-name>
<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
  </init-param>
  <init-param>
    <param-name>beanName</param-name>
    <param-value>adminApplication</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</filter>
<filter-mapping>
  <filter-name>wicket.accommodationOffice</filter-name>
  <url-pattern>/officeApplication/*</url-pattern>
</filter-mapping>

<filter-mapping>
  <filter-name>wicket.accommodationOffice.admin</filter-name>
  <url-pattern>/adminApplication/*</url-pattern>
</filter-mapping>
</web-app>

Exception in jetty start
ERROR - log                        - Failed startup of context 
org.mortbay.jetty.webapp.WebAppContext@ece65{/,src/main/webapp}
java.lang.IllegalStateException: more then one bean of type 
[org.apache.wicket.protocol.http.WebApplication] found, must have only one
	at 
org.apache.wicket.spring.SpringWebApplicationFactory.createApplication(SpringWebApplicationFactory.java:112)
	at 
org.apache.wicket.spring.SpringWebApplicationFactory.createApplication(SpringWebApplicationFactory.java:86)
	at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:496)
	at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:99)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
	at 
org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:594)
	at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
	at 
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
	at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
	at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
	at org.mortbay.jetty.Server.doStart(Server.java:220)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
	at my.accommodationoffice.Start.main(Start.java:35)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Two wicket applications in one spring context

Posted by Maurice Marrink <ma...@gmail.com>.
As the other members suggested, use one app and have your security
handle the logic for deciding what to show.
There are currently 2 security frameworks (that i know of) for wicket
to choose from.
Take a look at this site to see which security framework suits your
needs better.
http://wicketstuff.org/confluence/display/STUFFWIKI/Security+Framework+Comparison.

Both can work with spring and can integrate with acegi if so desired.


Maurice


On Dec 22, 2007 11:49 AM, Peter Ertl <pe...@gmx.net> wrote:
> I wouldn't separate that but put admin and user into one application.
>
> - same code base (easy sharing)
> - no two web sessions that need to be linked
> - easy deployment
>
> you my 2ct
>
>
> Am 22.12.2007 um 11:12 schrieb Per Newgro:
>
>
> > Hi *
> >
> > i try to adapt the phonebook example to my needs. What i try to
> > achieve is to
> > develop an admin part and an user part of my application. I would
> > like to
> > connect to my applications by two urls (localhost:8080 and
> > localhost:8080/admin). So i think i have to develop two
> > applications. They
> > share much code. So i would like to develop them both in same maven
> > project.
> >
> > But. If i try it my way it seems to conflict with spring conditions.
> > How could
> > i solve this? Maybe i use the wrong example?
> >
> > Thanks for your help
> > Per
> >
> > web.xml
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <web-app 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" version="2.4">
> >
> > <display-name>accommodationOffice</display-name>
> >
> > <!--
> >  There are three means to configure Wickets configuration mode and
> > they are
> >  tested in the order given.
> >  1) A system property: -Dwicket.configuration
> >  2) servlet specific <init-param>
> >  3) context specific <context-param>
> >  The value might be either "development" (reloading when templates
> > change)
> >  or "deployment". If no configuration is found, "development" is the
> > default.
> > -->
> > <context-param>
> >  <param-name>contextConfigLocation</param-name>
> >  <param-value>classpath:applicationContext.xml</param-value>
> > </context-param>
> >
> > <listener>
> >
> > <listener-
> > class>org.springframework.web.context.ContextLoaderListener</
> > listener-class>
> > </listener>
> >
> > <filter>
> >  <filter-name>wicket.accommodationOffice</filter-name>
> >  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-
> > class>
> >  <init-param>
> >    <param-name>applicationFactoryClassName</param-name>
> >
> > <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</
> > param-value>
> >  </init-param>
> >  <init-param>
> >    <param-name>beanName</param-name>
> >    <param-value>officeApplication</param-value>
> >  </init-param>
> >  <load-on-startup>1</load-on-startup>
> > </filter>
> >
> > <filter>
> >  <filter-name>wicket.accommodationOffice.admin</filter-name>
> >  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-
> > class>
> >  <init-param>
> >     <param-name>applicationFactoryClassName</param-name>
> > <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</
> > param-value>
> >  </init-param>
> >  <init-param>
> >    <param-name>beanName</param-name>
> >    <param-value>adminApplication</param-value>
> >  </init-param>
> >  <load-on-startup>1</load-on-startup>
> > </filter>
> > <filter-mapping>
> >  <filter-name>wicket.accommodationOffice</filter-name>
> >  <url-pattern>/officeApplication/*</url-pattern>
> > </filter-mapping>
> >
> > <filter-mapping>
> >  <filter-name>wicket.accommodationOffice.admin</filter-name>
> >  <url-pattern>/adminApplication/*</url-pattern>
> > </filter-mapping>
> > </web-app>
> >
> > Exception in jetty start
> > ERROR - log                        - Failed startup of context
> > org.mortbay.jetty.webapp.WebAppContext@ece65{/,src/main/webapp}
> > java.lang.IllegalStateException: more then one bean of type
> > [org.apache.wicket.protocol.http.WebApplication] found, must have
> > only one
> >       at
> > org
> > .apache
> > .wicket
> > .spring
> > .SpringWebApplicationFactory
> > .createApplication(SpringWebApplicationFactory.java:112)
> >       at
> > org
> > .apache
> > .wicket
> > .spring
> > .SpringWebApplicationFactory
> > .createApplication(SpringWebApplicationFactory.java:86)
> >       at
> > org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:
> > 496)
> >       at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:
> > 99)
> >       at
> > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> > 40)
> >       at
> > org
> > .mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:
> > 594)
> >       at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
> >       at
> > org
> > .mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
> > 1218)
> >       at
> > org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
> > 500)
> >       at
> > org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
> >       at
> > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> > 40)
> >       at
> > org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
> > 117)
> >       at org.mortbay.jetty.Server.doStart(Server.java:220)
> >       at
> > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> > 40)
> >       at my.accommodationoffice.Start.main(Start.java:35)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Two wicket applications in one spring context

Posted by Peter Ertl <pe...@gmx.net>.
I wouldn't separate that but put admin and user into one application.

- same code base (easy sharing)
- no two web sessions that need to be linked
- easy deployment

you my 2ct


Am 22.12.2007 um 11:12 schrieb Per Newgro:

> Hi *
>
> i try to adapt the phonebook example to my needs. What i try to  
> achieve is to
> develop an admin part and an user part of my application. I would  
> like to
> connect to my applications by two urls (localhost:8080 and
> localhost:8080/admin). So i think i have to develop two  
> applications. They
> share much code. So i would like to develop them both in same maven  
> project.
>
> But. If i try it my way it seems to conflict with spring conditions.  
> How could
> i solve this? Maybe i use the wrong example?
>
> Thanks for your help
> Per
>
> web.xml
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <web-app 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" version="2.4">
>
> <display-name>accommodationOffice</display-name>
>
> <!--
>  There are three means to configure Wickets configuration mode and  
> they are
>  tested in the order given.
>  1) A system property: -Dwicket.configuration
>  2) servlet specific <init-param>
>  3) context specific <context-param>
>  The value might be either "development" (reloading when templates  
> change)
>  or "deployment". If no configuration is found, "development" is the  
> default.
> -->
> <context-param>
>  <param-name>contextConfigLocation</param-name>
>  <param-value>classpath:applicationContext.xml</param-value>
> </context-param>
>
> <listener>
>
> <listener- 
> class>org.springframework.web.context.ContextLoaderListener</ 
> listener-class>
> </listener>
>
> <filter>
>  <filter-name>wicket.accommodationOffice</filter-name>
>  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter- 
> class>
>  <init-param>
>    <param-name>applicationFactoryClassName</param-name>
>
> <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</ 
> param-value>
>  </init-param>
>  <init-param>
>    <param-name>beanName</param-name>
>    <param-value>officeApplication</param-value>
>  </init-param>
>  <load-on-startup>1</load-on-startup>
> </filter>
>
> <filter>
>  <filter-name>wicket.accommodationOffice.admin</filter-name>
>  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter- 
> class>
>  <init-param>
>     <param-name>applicationFactoryClassName</param-name>
> <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</ 
> param-value>
>  </init-param>
>  <init-param>
>    <param-name>beanName</param-name>
>    <param-value>adminApplication</param-value>
>  </init-param>
>  <load-on-startup>1</load-on-startup>
> </filter>
> <filter-mapping>
>  <filter-name>wicket.accommodationOffice</filter-name>
>  <url-pattern>/officeApplication/*</url-pattern>
> </filter-mapping>
>
> <filter-mapping>
>  <filter-name>wicket.accommodationOffice.admin</filter-name>
>  <url-pattern>/adminApplication/*</url-pattern>
> </filter-mapping>
> </web-app>
>
> Exception in jetty start
> ERROR - log                        - Failed startup of context
> org.mortbay.jetty.webapp.WebAppContext@ece65{/,src/main/webapp}
> java.lang.IllegalStateException: more then one bean of type
> [org.apache.wicket.protocol.http.WebApplication] found, must have  
> only one
> 	at
> org 
> .apache 
> .wicket 
> .spring 
> .SpringWebApplicationFactory 
> .createApplication(SpringWebApplicationFactory.java:112)
> 	at
> org 
> .apache 
> .wicket 
> .spring 
> .SpringWebApplicationFactory 
> .createApplication(SpringWebApplicationFactory.java:86)
> 	at  
> org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java: 
> 496)
> 	at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java: 
> 99)
> 	at  
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java: 
> 40)
> 	at
> org 
> .mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java: 
> 594)
> 	at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
> 	at
> org 
> .mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java: 
> 1218)
> 	at  
> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java: 
> 500)
> 	at  
> org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
> 	at  
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java: 
> 40)
> 	at  
> org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java: 
> 117)
> 	at org.mortbay.jetty.Server.doStart(Server.java:220)
> 	at  
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java: 
> 40)
> 	at my.accommodationoffice.Start.main(Start.java:35)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Two wicket applications in one spring context

Posted by Per Newgro <pe...@gmx.ch>.
Hey Martijn and Sergey

Good point. So there could be 3 different user types (user of site, known user 
and admin). So i could avoid the second app.

Thanks
Per



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Two wicket applications in one spring context

Posted by Sergey Podatelev <br...@gmail.com>.
On Dec 22, 2007 4:59 PM, Martijn Dashorst <ma...@gmail.com>
wrote:

> Why two applications?
> Martijn


I guess, what Martin wanted to say is you shouldn't separate administrators
and users in this way. This is like creating two different bodies of the car
for driver and for passengers.

Instead, you should control what components or actions are allowed to be
displayed or performed by particular user.

-- 
sp

Re: Two wicket applications in one spring context

Posted by Martijn Dashorst <ma...@gmail.com>.
Why two applications?
Martijn

On Dec 22, 2007 11:12 AM, Per Newgro <pe...@gmx.ch> wrote:

> Hi *
>
> i try to adapt the phonebook example to my needs. What i try to achieve is
> to
> develop an admin part and an user part of my application. I would like to
> connect to my applications by two urls (localhost:8080 and
> localhost:8080/admin). So i think i have to develop two applications. They
> share much code. So i would like to develop them both in same maven
> project.
>
> But. If i try it my way it seems to conflict with spring conditions. How
> could
> i solve this? Maybe i use the wrong example?
>
> Thanks for your help
> Per
>
> web.xml
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <web-app 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" version="2.4">
>
> <display-name>accommodationOffice</display-name>
>
> <!--
>  There are three means to configure Wickets configuration mode and they
> are
>  tested in the order given.
>  1) A system property: -Dwicket.configuration
>  2) servlet specific <init-param>
>  3) context specific <context-param>
>  The value might be either "development" (reloading when templates change)
>  or "deployment". If no configuration is found, "development" is the
> default.
> -->
> <context-param>
>  <param-name>contextConfigLocation</param-name>
>  <param-value>classpath:applicationContext.xml</param-value>
> </context-param>
>
> <listener>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener
> </listener-class>
> </listener>
>
> <filter>
>  <filter-name>wicket.accommodationOffice</filter-name>
>  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
>  <init-param>
>    <param-name>applicationFactoryClassName</param-name>
>
> <param-value>org.apache.wicket.spring.SpringWebApplicationFactory
> </param-value>
>  </init-param>
>  <init-param>
>    <param-name>beanName</param-name>
>    <param-value>officeApplication</param-value>
>  </init-param>
>  <load-on-startup>1</load-on-startup>
> </filter>
>
> <filter>
>  <filter-name>wicket.accommodationOffice.admin</filter-name>
>  <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
>  <init-param>
>     <param-name>applicationFactoryClassName</param-name>
> <param-value>org.apache.wicket.spring.SpringWebApplicationFactory
> </param-value>
>  </init-param>
>  <init-param>
>    <param-name>beanName</param-name>
>    <param-value>adminApplication</param-value>
>  </init-param>
>  <load-on-startup>1</load-on-startup>
> </filter>
> <filter-mapping>
>  <filter-name>wicket.accommodationOffice</filter-name>
>  <url-pattern>/officeApplication/*</url-pattern>
> </filter-mapping>
>
> <filter-mapping>
>  <filter-name>wicket.accommodationOffice.admin</filter-name>
>  <url-pattern>/adminApplication/*</url-pattern>
> </filter-mapping>
> </web-app>
>
> Exception in jetty start
> ERROR - log                        - Failed startup of context
> org.mortbay.jetty.webapp.WebAppContext@ece65{/,src/main/webapp}
> java.lang.IllegalStateException: more then one bean of type
> [org.apache.wicket.protocol.http.WebApplication] found, must have only one
>        at
> org.apache.wicket.spring.SpringWebApplicationFactory.createApplication(
> SpringWebApplicationFactory.java:112)
>        at
> org.apache.wicket.spring.SpringWebApplicationFactory.createApplication(
> SpringWebApplicationFactory.java:86)
>        at org.apache.wicket.protocol.http.WicketFilter.init(
> WicketFilter.java:496)
>        at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java
> :99)
>        at org.mortbay.component.AbstractLifeCycle.start(
> AbstractLifeCycle.java:40)
>        at
> org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java
> :594)
>        at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
>        at
> org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java
> :1218)
>        at org.mortbay.jetty.handler.ContextHandler.doStart(
> ContextHandler.java:500)
>        at org.mortbay.jetty.webapp.WebAppContext.doStart(
> WebAppContext.java:448)
>        at org.mortbay.component.AbstractLifeCycle.start(
> AbstractLifeCycle.java:40)
>        at org.mortbay.jetty.handler.HandlerWrapper.doStart(
> HandlerWrapper.java:117)
>        at org.mortbay.jetty.Server.doStart(Server.java:220)
>        at org.mortbay.component.AbstractLifeCycle.start(
> AbstractLifeCycle.java:40)
>        at my.accommodationoffice.Start.main(Start.java:35)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-rc2 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-rc1/