Re: #bean...scope=session no longer working?

Keats Kirsch <[email protected]>
Newsgroups gmane.comp.java.webmacro.user
Message-ID <[email protected]>
I spent a couple of hours setting up Tomcat 5.5.9 and cooking up some 
test cases and I can't reproduce your problem.

I put the following into a sandbox template, with no problem.  I'm using 
Win2K with Sun JRE 1.5.0_02.  I also tested with Tomcat 4.1 and 5.0 with 
JDK 1.4.2.

Your error indicates that your class wasn't instantiated.  You might try 
putting some logging into the constructor to see what's going on.  Also 
check your BeanDirective security settings.  Good luck.

Keats

Sample WMScript:

#bean $testbean = "com.xaltus.wm.Test" scope=session onNew
  #set $testbean.Num = 2
#end
#set $testbean.Num = $testbean.Num * 2
testbean.Num = $testbean.Num<br><br>
   
#bean $counts = "java.util.HashMap" scope=session onNew
  #set $counts.Hits = 0
#end
#set $counts.Hits = $counts.Hits + 1
Number of visits to this page in this session: $counts.Hits<br><br>
   


Rab Wallace wrote:

>I recently upgraded to Tomcat 5.5.9 and noticed all my
>pages with a #bean...scope=session no longer works
>(scope=page works fine), anyone else seen this?
>
>I tried a simple example:
>A simple bean 'com.myteststuff.Test' has a single long
>attribute 'value' and a getter & setter. In my
>template, I've got:
>
>#bean $test="com.myteststuff.Test" scope=session
>$test.setValue(123)
>
>results in the exception below. If I switch to
>scope=page, everything works fine. Earlier version of
>Tomcat also ok. Thanks for any advice.
>
>Rab Wallace
>
>ps. this problem exists on both the latest Webmacro
>(2.0rc1) and at least the previous version (2.0b1).
>
>
>org.webmacro.PropertyException$NoSuchMethodException:
>No public method setValue(123) on variable $test of
>class org.webmacro.engine.UndefinedMacro at
>jndi:/localhost/metridium_jboss/skins/kelpforest/kelpforest_DefaultMainPage.wm:229.1
>	at
>org.webmacro.engine.PropertyOperator.getProperty(PropertyOperatorCache.java:716)
>	at
>org.webmacro.engine.PropertyOperatorCache.getProperty(PropertyOperatorCache.java:163)
>	at org.webmacro.Context.internalGet(Context.java:383)
>	at org.webmacro.Context.getProperty(Context.java:443)
>	at
>org.webmacro.engine.PropertyVariable.getValue(PropertyVariable.java:52)
>	at
>org.webmacro.engine.Variable.write(Variable.java:211)
>	at org.webmacro.engine.Block.write(Block.java:133)
>	at
>org.webmacro.directive.IfDirective.write(IfDirective.java:210)
>	at org.webmacro.engine.Block.write(Block.java:184)
>	at
>org.webmacro.directive.ForeachDirective.write(ForeachDirective.java:177)
>	at org.webmacro.engine.Block.write(Block.java:145)
>	at
>org.webmacro.directive.IfDirective.write(IfDirective.java:210)
>	at org.webmacro.engine.Block.write(Block.java:199)
>	at
>org.webmacro.engine.WMTemplate.write(WMTemplate.java:324)
>	at
>org.webmacro.engine.WMTemplate.evaluateAsString(WMTemplate.java:253)
>	at
>com.metridia.metridium.servlets.MetridiumServlet.renderPageAlias(MetridiumServlet.java:743)
>	at
>com.metridia.metridium.servlets.MetridiumServlet.doGet(MetridiumServlet.java:598)
>	at
>javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
>	at
>javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>	at
>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>	at
>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>	at
>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>	at
>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
>	at
>org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
>	at
>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
>	at
>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>	at
>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
>	at
>org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>	at
>org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
>	at
>org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
>	at
>org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
>	at
>org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
>	at
>org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
>	at
>org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>	at java.lang.Thread.run(Unknown Source)
>  
>




-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.