Any Substitute Of Cactus? How To Use Cactus?

Cactus has retired for some reason, however, I haven't found any competing substitute that could finish the same mission better. Inforseeable future, I would choose Cactus anyway for server-side in-container unit testing anyway.

How to configure Cactus? Below are several noteworthy key points:

1. Place the cactus.properties file under the WEB-INF/classes. Content Example:

cactus.contextURL = http://localhost.derek.com:9080/context

cactus.servletRedirectorName = ServletRedirector

cactus.enableLogging=false

2. Copy all the jars of Cactus 1.8 and commons-codec.jar to WEB-INF/lib.

3. Edit web.xml as <Struts Kick Start> told you. You can also reference Cactus's <20 minutes tutorial>.

4. Write testing code and run it just like junit. Pretty easy. An alternative to run Cactus's test cases is through direct HTTP request(URL). I prefer the former way personally.

 

Frequent Error You May Run Across:

1. NoClassDefFoundError

java.lang.NoClassDefFoundError:org/apache/cactus/server/ServletTestRedirector

Solution: you should copy your jars to not only WEB-INF/lib, but also somewhere of container's installation folder. For example, in my case, 'D:\Program Files\IBM\WebSphere\AppServer\lib\ext' for WebSphere, and 'D:\Program Files\Tomcat 7.0\lib' for Tomcat 7.

 

2. ChainedRuntimeException

org.apache.cactus.util.ChainedRuntimeException: Cannot read cactus configuration file

Solution: Place the cactus.properties file under the WEB-INF/classes.  If you clean and rebuild projects, you should check whether it exists now.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值