this is why sharing jars across web applications is generally a bad
idea unless the jars are specifically designed to be shared. you are
going to run into the same problem with any jar that stores a cache in
a static variable, because all of a sudden this cache is shared across
multiple applications, some of which might have classes with the same
name even though they are actually different.

i would recommend including wicket-spring jars in your war.

-igor

On Mon, Mar 2, 2009 at 12:25 PM, Alex Parvulescu
<alex.parvule...@gmail.com> wrote:
> I had no luck with this on the users mail list ( us...@wicket.apache.org )
> maybe here its a better fit for this email
>
>
> Hello,
>
> I have a problem with the wicket - spring integration in wicket 1.4 rc2 , i
> think its similar to https://issues.apache.org/jira/browse/WICKET-1848
>
> The use case is like this :
>
> I have 2 simple applications running in a jetty server.
>
> To keep things simple , i added the spring and wicket libs to the common
> classpath (so the following libs: cglib-nodep-2.1_3.jar,
> commons-logging-1.1.jar , log4j-1.2.13.jar , slf4j-api-1.5.0.jar ,
> slf4j-log4j12-1.5.0.jar , spring-2.5.6.jar , wicket-1.4-rc2.jar ,
> wicket-ioc-1.4-rc2.jar , wicket-spring-1.4-rc2.jar  go into
> $JETTY_HOME/lib/ext/extra-libs )
> That helps me keep the size of the wars lower.
>
> I think the problem is that by using this common classpath , the wicket
> applications share -some- context.More to the point , I don't think that
> LazyInitProxyFactory is thread safe , or maybe application safe. It appears
> that bean ids from one application are visible in another application thats
> deployed on the same server.
>
> As an example : I can define a bean with the id 'simpleService' in the first
> application. But when I try to define another bean in the second application
> with the same id - still 'simpleService' but a different interface- I get
> the following error:
>
> GET, protocol = HTTP/1.1, requestURL = http://localhost:8080/, contentType =
> null, contentLength = -1, contextPath = , pathInfo = null, requestURI = /,
> servletPath = /, pathTranslated = null]
> 2009-02-24 15:08:04,803 ERROR org.apache.wicket.RequestCycle - Can't
> instantiate page using constructor public com.asf.test2.web.Index()
> org.apache.wicket.WicketRuntimeException: Can't instantiate page using
> constructor public com.asf.test2.web.Index()
>    at
> org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:172)
>    at
> org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:58)
>    at
> org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:299)
>    at
> org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:321)
>    at
> org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
>    at
> org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
>    at
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1192)
>    at org.apache.wicket.RequestCycle.step(RequestCycle.java:1271)
>    at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
>    at org.apache.wicket.RequestCycle.request(RequestCycle.java:501)
>    at
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:455)
>    at
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288)
>    at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
>    at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361)
>    at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>    at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>    at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
>    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
>    at
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:199)
>    at
> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>    at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>    at org.mortbay.jetty.Server.handle(Server.java:324)
>    at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>    at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:538)
>    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>    at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
>    at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)
> Caused by: java.lang.reflect.InvocationTargetException
>    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>    at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>    at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>    at
> org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:153)
>    ... 28 more
> Caused by: java.lang.RuntimeException: error while injecting object [[Page
> class = com.asf.test2.web.Index, id = 0, version = 0]] of type
> [com.asf.test2.web.Index]
>    at org.apache.wicket.injection.Injector.inject(Injector.java:118)
>    at
> org.apache.wicket.injection.ConfigurableInjector.inject(ConfigurableInjector.java:39)
>    at
> org.apache.wicket.injection.ComponentInjector.onInstantiation(ComponentInjector.java:52)
>    at
> org.apache.wicket.Application.notifyComponentInstantiationListeners(Application.java:1027)
>    at org.apache.wicket.Component.<init>(Component.java:911)
>    at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:113)
>    at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:105)
>    at org.apache.wicket.Page.<init>(Page.java:236)
>    at org.apache.wicket.markup.html.WebPage.<init>(WebPage.java:185)
>    at com.asf.test2.web.Index.<init>(Index.java:20)
>    ... 33 more
> Caused by: java.lang.IllegalArgumentException
>    at
> sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
>    at java.lang.reflect.Field.set(Field.java:656)
>    at org.apache.wicket.injection.Injector.inject(Injector.java:112)
>    ... 42 more
>
>
> Another example is that if its indeed the same bean injected - lets say it
> comes from a jar in the classpath - i get the same object in both
> applications , even though the two don't have anything in common , except
> for the bean id ( just for the example's sake, thats what toString() shows:
> 'org.apache.wicket.proxy.lazyinitproxyfactory$jdkhand...@1469658' ).
>
> I don't know if its a bug or not , to me this all looks a bit buggy. I have
> a testcase if anyones interested in taking a look at this.
>
> Also , a very important aspect is that this does  not happen when i pack
> everyhting in one big war - but the size difference is pretty big - i'm
> going from 300KB to 5MB on each war.
>
> Thanks,
> Alex
>

Reply via email to