Win a copy of Spring Boot in Practice this week in the Spring forum!

jignesh tandel

Greenhorn
+ Follow
since Feb 16, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jignesh tandel

Spring MVC

I have spring 3.1 MVC application which is deployed on tomcat 6.
during restart the server, it throw following error.
------------------------
INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
Mar 13, 2012 2:48:32 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet springapp as unavailable
Mar 13, 2012 2:48:32 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@18020cc
org.springframework.web.servlet.DispatcherServlet
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1083)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Mar 13, 2012 2:48:32 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /Spring-12 threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1083)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)

---------------

it IE, if application hit http://localhost:8080/Spring-12/hello.htm. then it show following error
---------
The requested resource (Servlet springapp is not available) is not available.


--------------------------------------------------------------------------------

but, http://localhost:8080/Spring-12/hello.jsp display the content.

Can you help me to resolve the error that getting while restart the server.?

10 years ago
Hi Jeanne

I tried with mention code. but there is still nullPointerexception during initalize the dispatcher. then i follow the other approach mention in below link.
http://www.javaranch.com/journal/2003/12/UnitTestingDatabaseCode.html

I successed with initail testing with loginDAO. now i would like to test addleaverecord() from DAO. so, do i need to mock the request ? or hard code the values in bean and passed that bean to addleaveracor() method,
if need to mock the request then how ? if i need to hard code the values then it is burden on developers to right code with testcase also?

which approach is feasible?

Can you please provide any example to test struts 2 with Junit ?

i asked more question :-)
10 years ago
HI, Thanks for reply..

here is the actual stack trace.

java.lang.NullPointerException
at com.opensymphony.xwork2.util.ClassLoaderUtil.getResource(ClassLoaderUtil.java:86)
at com.opensymphony.xwork2.util.location.LocationUtils.getLocation(LocationUtils.java:288)
at com.opensymphony.xwork2.util.location.LocationUtils.getLocation(LocationUtils.java:202)
at com.opensymphony.xwork2.XWorkException.<init>(XWorkException.java:93)
at com.opensymphony.xwork2.XWorkException.<init>(XWorkException.java:76)
at com.opensymphony.xwork2.config.ConfigurationException.<init>(ConfigurationException.java:64)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:135)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
at com.junit.testing.BaseStrutsTestCase.setUp(BaseStrutsTestCase.java:84)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

--------------------------------------
Alternate, I used "StrutsTestCase". I extends it in"TestLoginAction"
there i show compilation error at
ActionProxy proxy = getActionProxy("/Login.action");

Please post your valuable commet in both the case
10 years ago
Junit testing for Struts2

Hi i am using Junit 4 to test struts2 action class.

I have BaseStrutsTest.java . my TestLoginAction.java extends BasdeStrutsTest.java
------------------------------------

----------------------
TestLoginAction.java
-----------




I tun "TestLoginAction.java" in Eclipse.. using "Run As " -- > "Junit .." it throws the "NullPoniterException" as dispatcher.init() method in "BaseStrutsTest.java"

Can you please hlep me for it ASAP?

Rgd,
Jignesh
10 years ago