Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Object Pooling Problem - minSize?

  1. #1
    Join Date
    May 2006
    Posts
    15

    Default Object Pooling Problem - minSize?

    Hi

    I am testing Object Pooling using the Commons framework from Apache (Spring 1.2.8)

    The applicationContext.xml looks like this (see bold below):

    <beans>
    <bean id="pooledBean" class="com.winterthur.test.web.spring.TestPooledBe an" singleton="false">

    </bean>

    <bean id="poolTargetSource" class="org.framework.aop.target.CommonsPoolTargetS ource">
    <property name="targetBeanName" value="pooledBean"/>
    <property name="minSize" value="2"/>
    <property name="maxSize" value="10"/>
    </bean>

    <bean id="pool" class="org.springframework.aop.framewokr.ProxyFact oryBean">
    <property name="targetSource" ref="poolTargetSource"/>
    </bean>

    </beans>


    When I start my web application inside of Ecplise I am getting the following exception - though I don't see any settings for minimum size:

    [7/17/06 9:00:44:281 CDT] 00000019 DefaultListab I Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [EIServiceBean,poolTargetSource,EIServiceProxy,EIOb jectPool,eiObjectFactory]; root of BeanFactory hierarchy}
    [7/17/06 9:00:44:296 CDT] 00000019 ContextLoader E Context initialization failed
    [7/17/06 9:00:44:359 CDT] 00000019 ContextLoader E TRAS0014I: The following exception was logged org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'poolTargetSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'minSize' of bean class [org.springframework.aop.target.CommonsPoolTargetSo urce]: Bean property 'minSize' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'minSize' of bean class [org.springframework.aop.target.CommonsPoolTargetSo urce]: Bean property 'minSize' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:670)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:572)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:737)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:764)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:753)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1057)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:857)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:378)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:283)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:313)
    at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:139)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:252)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:190)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
    at com.ibm.ws.webcontainer.webapp.WebApp.notifyServle tContextCreated(WebApp.java:1355)
    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(W ebApp.java:371)
    at com.ibm.ws.webcontainer.webapp.WebGroup.addWebAppl ication(WebGroup.java:114)
    at com.ibm.ws.webcontainer.VirtualHost.addWebApplicat ion(VirtualHost.java:127)
    at com.ibm.ws.webcontainer.WebContainer.addWebApp(Web Container.java:776)
    at com.ibm.ws.webcontainer.WebContainer.addWebApplica tion(WebContainer.java:729)
    at com.ibm.ws.runtime.component.WebContainerImpl.inst all(WebContainerImpl.java:140)
    at com.ibm.ws.runtime.component.WebContainerImpl.star t(WebContainerImpl.java:360)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.st art(ApplicationMgrImpl.java:1019)
    at com.ibm.ws.runtime.component.DeployedApplicationIm pl.fireDeployedObjectStart(DeployedApplicationImpl .java:1028)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.st art(DeployedModuleImpl.java:538)
    at com.ibm.ws.runtime.component.DeployedApplicationIm pl.start(DeployedApplicationImpl.java:724)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.st artApplication(ApplicationMgrImpl.java:683)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl$Ap pInitializer.run(ApplicationMgrImpl.java:1678)
    at com.ibm.ws.runtime.component.ComponentImpl$_Asynch Initializer.run(ComponentImpl.java:304)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava:1332)
    .

  2. #2
    Join Date
    May 2006
    Posts
    15

    Default One more thing

    Hi

    In my servlet the code I use to access the bean is:

    ApplicationContext ac = new XmlWebApplicationContext();

    int count = 10;
    Vector holder = new Vector();
    for (int i=0; i < count; i++){
    PooledInterface tpb = (TestPooledBean)ac.getBean("pooledBean");
    holder.add(tpb);
    }

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    On the class 'org.framework.aop.target.CommonsPoolTargetSource' there is no property with the name minSize. Remove that line and you should be good to go.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4
    Join Date
    May 2006
    Posts
    15

    Default Still problems

    Hi

    I initially didn't have that line in the applicationContext.xml and had problems, so I tried adding that line. I have since removed it and am still having the same problem.

    Thanks.

    David

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    Is it really the same problem? because when I look at the stacktrace

    Code:
    [7/17/06 9:00:44:359 CDT] 00000019 ContextLoader E TRAS0014I: The following exception was logged org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'poolTargetSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'minSize' of bean class [org.springframework.aop.target.CommonsPoolTargetSo urce]: Bean property 'minSize' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'minSize' of bean class [org.springframework.aop.target.CommonsPoolTargetSo urce]: Bean property 'minSize' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    The only thing I can conclude is that you are trying to set a property (minSize) which doesn't have a setter (there is no setter for minSize in that class).

    Could it be that you have an old context.xml file hanging around somewhere? Which gets loaded before the correct one? Try a full/cleanrebuild of your project (or remove the applicationContext.xml from your build directory), this might get rid of any old files hanging around.

    Could you post, the stacktrace and config without the minsize property?.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  6. #6
    Join Date
    Dec 2005
    Posts
    269

    Default

    well, according to the JavaDoc, the CommonsPoolTargetSource class has a property minIdle (not minSize!). I would be very surprised, if instead of NotWritablePropertyException you saw something else

    BTW, what kind of problems you had *before*?

  7. #7
    Join Date
    May 2006
    Posts
    15

    Default Still having a problem

    Hi

    I have now addressed the comments above and am getting the following errors:

    7/17/06 10:56:26:421 CDT] 00000014 ApplicationMg A WSVR0221I: Application started: SpringWebTestEAR
    [7/17/06 10:56:26:359 CDT] 00000014 SystemErr R org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'pool' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigExcepti on: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
    org.springframework.aop.framework.AopConfigExcepti on: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
    at org.springframework.aop.framework.DefaultAopProxyF actory.createAopProxy(DefaultAopProxyFactory.java: 72)
    at org.springframework.aop.framework.AdvisedSupport.c reateAopProxy(AdvisedSupport.java:487)
    at org.springframework.aop.framework.ProxyFactoryBean .getSingletonInstance(ProxyFactoryBean.java:285)
    at org.springframework.aop.framework.ProxyFactoryBean .setBeanFactory(ProxyFactoryBean.java:239)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:391)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:277)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:313)
    at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:139)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:252)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:190)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)


    Any ideas?

    David

  8. #8
    Join Date
    Dec 2005
    Posts
    269

    Default

    you are missing the ciglib library in your classpath.

    you can find one within the spring distribution: cglib-2.1.3-no-dep.jar.

    you will also need a copuple of other jars:

    antrl.jar
    log4j.jar
    etc.

    all of them can be found in the dist.

  9. #9
    Join Date
    May 2006
    Posts
    15

    Default Next issue

    First off thank you so much for your help. I have the issues resolved you mentioned including adding the jars. The web app starts ok, but when I call the servlet which should be able to access the pool of objects I am getting:

    [7/17/06 11:05:30:921 CDT] 00000031 WebApp E SRVE0026E: [Servlet Error]-[com.winterthur.test.web.spring.SpringTestServlet]: java.lang.IllegalStateException: BeanFactory not initialized - call 'refresh' before accessing beans via the context: org.springframework.web.context.support.XmlWebAppl icationContext: display name [Root WebApplicationContext]; startup date [Wed Dec 31 18:00:00 CST 1969]; root of context hierarchy; config locations []
    at org.springframework.context.support.AbstractRefres hableApplicationContext.getBeanFactory(AbstractRef reshableApplicationContext.java:103)
    at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:537)
    at com.winterthur.test.web.spring.SpringTestServlet.d oPost(SpringTestServlet.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.ser vice(ServletWrapper.java:1212)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.han dleRequest(ServletWrapper.java:629)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrappe r.handleRequest(CacheServletWrapper.java:80)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest (WebContainer.java:1657)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.read y(WCChannelLink.java:77)

    Ideas?


    Thanx.

    David

  10. #10
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    Code:
    ApplicationContext ac = new XmlWebApplicationContext();
    
    int count = 10;
    Vector holder = new Vector();
    for (int i=0; i < count; i++){
    PooledInterface tpb = (TestPooledBean)ac.getBean("pooledBean");
    holder.add(tpb);
    }
    IN the code above I see that you construct a applicationcontext but you do not initialize it. So before getting beans call refresh().

    However I think a beter way to load/init the applicationcontext is bij using the ContextLoaderListener or Servlet. Then from your servlet access the ApplicationContext by getting it from the servletcontext.

    Code:
    ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •