aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes ClassCastException: org.apache.struts.action.ActionServlet cannot be cast to javax.servlet.Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "ClassCastException: org.apache.struts.action.ActionServlet cannot be cast to javax.servlet.Servlet" Watch "ClassCastException: org.apache.struts.action.ActionServlet cannot be cast to javax.servlet.Servlet" New topic
Author

ClassCastException: org.apache.struts.action.ActionServlet cannot be cast to javax.servlet.Servlet

naresh kumar k
Ranch Hand

Joined: May 25, 2011
Posts: 30
hi
I am trying implement struts program using jboss server and eclipse ide
while starting the server i am getting following error stack

16:16:59,500 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/CSWeb]] Servlet /CSWeb threw load() exception: java.lang.ClassCastException: org.apache.struts.action.ActionServlet cannot be cast to javax.servlet.Servlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1162) [:6.0.0.Final]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1108) [:6.0.0.Final]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3628) [:6.0.0.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3851) [:6.0.0.Final]
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:294) [:6.0.0.Final]
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:146) [:6.0.0.Final]
at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:477) [:6.0.0.Final]
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118) [:6.0.0.Final]
at org.jboss.web.deployers.WebModule.start(WebModule.java:95) [:6.0.0.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [:1.6.0]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [:1.6.0]
at java.lang.reflect.Method.invoke(Unknown Source) [:1.6.0]
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) [:6.0.0.GA]
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:271) [:6.0.0.GA]
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:670) [:6.0.0.GA]
at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206) [:2.2.0.GA]
at $Proxy41.start(Unknown Source) at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:53) [:2.2.0.GA]
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:41) [:2.2.0.GA]
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:301) [:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:894) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:641) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:182) [:2.2.0.GA]
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:58) [:2.2.0.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) [:2.2.0.GA]
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1571) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1603) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.0.GA]
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.0.GA]
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.0.GA]
at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.0.0.Final]
at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.2.2]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA]
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]
at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2]
at org.jboss.profileservice.AbstractProfileService.activateProfile(AbstractProfileService.java:154) [:0.2.2]
at org.jboss.system.tools.ProfileServiceToolsFacade.addURI(ProfileServiceToolsFacade.java:233) [:6.0.0.Final]
at org.jboss.system.tools.LegacyDeploymentScannerAdapter.addURL(LegacyDeploymentScannerAdapter.java:140) [:6.0.0.Final]
at org.jboss.system.tools.DeploymentScanner.addURL(DeploymentScanner.java:91) [:6.0.0.Final]
at org.jboss.system.tools.DeploymentScanner.addURL(DeploymentScanner.java:83) [:6.0.0.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [:1.6.0]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [:1.6.0]
at java.lang.reflect.Method.invoke(Unknown Source) [:1.6.0]
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) [:6.0.0.GA]
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:271) [:6.0.0.GA]
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:670) [:6.0.0.GA]
at org.jboss.system.server.jmx.MBeanServerWrapper.invoke(MBeanServerWrapper.java:138) [:6.0.0.Final (Build SVNTag:JBoss_6.0.0.Final date: 20101228)]
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(Unknown Source) [:1.6.0]
at javax.management.remote.rmi.RMIConnectionImpl.access$200(Unknown Source) [:1.6.0]
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(Unknown Source) [:1.6.0]
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(Unknown Source) [:1.6.0]
at javax.management.remote.rmi.RMIConnectionImpl.invoke(Unknown Source) [:1.6.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [:1.6.0]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [:1.6.0]
at java.lang.reflect.Method.invoke(Unknown Source) [:1.6.0]
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) [:1.6.0]
at sun.rmi.transport.Transport$1.run(Unknown Source) [:1.6.0]
at java.security.AccessController.doPrivileged(Native Method) [:1.6.0]
at sun.rmi.transport.Transport.serviceCall(Unknown Source) [:1.6.0]
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) [:1.6.0]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source) [:1.6.0]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) [:1.6.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [:1.6.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [:1.6.0]
at java.lang.Thread.run(Unknown Source) [:1.6.0]

thanks in advance.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

I suspect that your WAR file includes the servlet API JAR file in WEB-INF/lib. If so, remove it.


JBoss In Action
naresh kumar k
Ranch Hand

Joined: May 25, 2011
Posts: 30
Peter Johnson wrote:I suspect that your WAR file includes the servlet API JAR file in WEB-INF/lib. If so, remove it.

hi peter ,
thanks for your reply
I am using j2ee.jar file but when i am removing it ide showing error so can you tell me what are jar file required to be added or removed
here are the list jar files i am using
==> antlr-2.7.2.jar
commons-beanutils-1.7.0.jar
commons-chain-1.1.jar
commons-digester-1.8.jar
commons-fileupload-1.1.1.jar
commons-io-1.1.jar
commons-logging-1.0.4.jar
commons-validator-1.3.1.jar
j2ee.jar
oro-2.0.8.jar
standard-1.0.2.jar
struts-core-1.3.8.jar
struts-el-1.3.8.jar
struts-extras-1.3.8.jar
struts-faces-1.3.8.jar
struts-mailreader-dao-1.3.8.jar
struts-scripting-1.3.8.jar
struts-taglib-1.3.8.jar
struts-tiles-1.3.8.jar

thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41852
    
  63
The build-time classpath used by the IDE has nothing to do with the runtime classpath used by the server; you would do well to keep those separate.

I'm surprised JBoss would get confused over this, though - Tomcat knows not load javax.servlet classes that are part of individual web apps.


Ping & DNS - my free Android networking tools app
naresh kumar k
Ranch Hand

Joined: May 25, 2011
Posts: 30
hi
Here I found out how the exception is coming but can't resolve it
First i don't have common-digester.jar in my project this time i am having error like
exception: java.lang.NoClassDefFoundError: org/apache/commons/digester/RuleSet
...............................

and next i placed common-digester.jar then i am the above error which i actually posted
i.e ClassCastException: org.apache.struts.action.ActionServlet cannot be cast to javax.servlet.Servlet
........................................
please help on this .

regards
naresh kumar
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

Your question has become an Eclipse question. What you need to know is how to include a JAR file in your Eclipse build path so that Eclipse can compile your code, but how to prevent Eclipse from packaging that JAR within your web application when you need to deploy it to the application server. Personally, I rarely use Eclipse to build or package my applications (I use Ant or Maven), so I can't tell you how to accomplish this (without first doing some research on this topic myself). Perhaps someone on the Eclipse forum will know. I'll cross-link you post to that forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ClassCastException: org.apache.struts.action.ActionServlet cannot be cast to javax.servlet.Servlet