Originally posted by Stan James:
Just for completeness ... you can hack the classpath with unsupported calls to protected methods. Does that sound like hunting for a gas leak with a match? The custom classloader sounds safer.
Originally posted by Maulin Vasavada:
Hi Bob,
I didn't understand the following,
use the same datasource.xml file but the implementation is different for each one of them.
To me it looks like, you have TWO datasource files having different "content". XML DTD may be same for the files but the content is different. Is that what you have? If that is the case then I wouldn't put it as "Two EARs use the same file..." OR I didn't understand when you said "different implementations of the same file". How one can have "implementations" of the file??
Now, saying that, one way would be to just put those files in respective packages directory and getResourceAsStream() things would work for you to get the correct file as it would look for in the package first...
Please correct me if I am wrong.
Regards
Maulin
Originally posted by Ernest Friedman-Hill:
You can't "set the classpath" in general, because there's no one single class path. Every ClassLoader has its own idea of how to load classes and where to find them. In an app server there are generally many class loaders in operation.
What you can do is create your own ClassLoader which knows where you want to find classes, and use it to loaded the classes of interest. The class java.net.URLClassLoader is a standard class loader that lets you hand it a class path to use -- you may be able to simply use that.
Anybody just starting out with classloaders would do well to study the papers of the great sage Ted Neward.
You need to be careful, though, because you don't want to confuse the appserver. Furthermore, the appserver may prohibit this via Java's security mechanisms.
Originally posted by N Naga:
Hi
I am using following code to test our LoginAction (Struts Frame work)
public void testSuccessfulLogin() {
setConfigFile("edrs", "/WEB-INF/struts-config.xml");
setRequestPathInfo("/edrs", "/loginAction.do");
String pathInfo = "/loginAction";
logger.debug(
"Entering+servletunit.struts.CactusStrutsTestCase.setRequestPathInfo() : pathInfo = "
+ pathInfo);
logger.debug("START --Setting Request Parameters");
addRequestParameter("username", "xyz");
addRequestParameter("password", "xyz");
addRequestParameter("action","logon");
logger.debug("END --Setting Request Parameters");
actionPerform();
logger.debug("AfterAction Perform --Setting Request Parameters");
verifyForward("success");
verifyForwardPath("/WEB-INF/jsp/welcome.jsp");
LoginForm loginForm=(LoginForm)getActionForm();
logger.debug("USerName :::::"+loginForm.getUsername());
logger.debug("Compare user id");
verifyNoActionErrors();
}
It's giving me the following error
null
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:389)
at weblogic.servlet.internal.WebAppServletContext.setAttribute(WebAppServletContext.java:669)
at org.apache.cactus.server.AbstractServletContextWrapper.dispatch115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:129)
at org.apache.cactus.server.AbstractServletContextWrapper.around115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.AbstractServletContextWrapper.setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:127)
at org.apache.cactus.server.AbstractServletContextWrapper.dispatch115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:129)
at org.apache.cactus.server.AbstractServletContextWrapper.around115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1151)
at org.apache.cactus.server.AbstractServletContextWrapper.setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:127)
at servletunit.struts.CactusStrutsTestCase.tearDown(CactusStrutsTestCase.java:129)
at org.apache.cactus.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:156)
at org.apache.cactus.server.AbstractWebTestController.dispatch133_handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:130)
at org.apache.cactus.server.AbstractWebTestController.around133_handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:101)
at org.apache.cactus.server.ServletTestRedirector.dispatch160_doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:125)
at org.apache.cactus.server.ServletTestRedirector.around160_doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:109)
at org.apache.cactus.server.ServletTestRedirector.dispatch159_doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:96)
at org.apache.cactus.server.ServletTestRedirector.around159_doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:92)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Am I missing any thing. I am new to cactus. I want to test out struts action class such as forward path, actionForm, ActionMapping.
Can any one help me. I am missing something.
Originally posted by Lasse Koskela:
Have you tried renaming the class to TestFbbEJB? (I'm not sure what's the mechanism Cactus uses to identify test cases so this is just me guessing)