Reputation: 268
initially my jsp page is showed in proper way when i click on submit button it is showing class not found exception for sql library but then i add mysql library it is not showng jsp page and giving exception
org.apache.jasper.JasperException: The Struts dispatcher cannot be found. This is
usually caused by using Struts tags without the associated filter. Struts tags are
only usable when the request has passed through its servlet filter, which initializes
the Struts dispatcher needed for this tag. - [unknown location]
root cause
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.
Please help me to resolve this
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
version="2.5">
<display-name>Struts2Example17</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
this error is also coming
SEVERE: log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
SEVERE: log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: WebModule[/Struts2Example17]PWC1270: Exception starting filter struts2
errortrace
SEVERE: log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
SEVERE: log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: WebModule[/Struts2Example17]PWC1270: Exception starting filter struts2
java.lang.InstantiationException
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:124)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4685)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5377)
at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2000)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
at org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:126)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: Unable to load configuration. - bean - jar:file:/D:/strts2/Struts2Example17/build/web/WEB-INF/lib/struts2-dojo-plugin-2.1.8-sources.jar!/struts-plugin.xml:29:119
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:264)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:120)
... 47 more
Caused by: Unable to load bean: type:org.apache.struts2.views.TagLibrary class:org.apache.struts2.dojo.views.DojoTagLibrary - bean - jar:file:/D:/strts2/Struts2Example17/build/web/WEB-INF/lib/struts2-dojo-plugin-2.1.8-sources.jar!/struts-plugin.xml:29:119
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:222)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:165)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
... 53 more
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.dojo.views.DojoTagLibrary
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1519)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1369)
at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:193)
... 56 more
JSp file
<%--
Document : statusdonationjsp
Created on : Dec 20, 2011, 10:34:09 PM
Author : bhavishya
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Pending Donation </title>
</head>
<body>
Search String
<s:form action="FindPendingDonation">
<s:textfield name="detail" label="Name" />
<s:select name="amounttype" list="{'Cash','Cheque'}" label="Paymet type" id="type" onchange="displayBlock()" />
<s:select name="status" list="{'Paid','Unpaid'}" label="Status(Cash)" />
<s:textfield name="amount" label="Amount" />
<s:textfield name="responsibleparty" label="Bank Name/Responsible party" id="cash" />
<s:textfield name="chequeno" lable ="Cheque NO" id="chequeno"/>
<s:submit />
</s:form>
</body>
</html>
Upvotes: 2
Views: 54039
Reputation: 1
Try changing your URL pattern from <url-pattern>/*</url-pattern>
to <url-pattern>*.do</url-pattern>
.
Upvotes: 0
Reputation: 19
I was facing the same issue. I have the multiple configuration files in my project(other files are included in the default struts.xml file). The included file names in default struts.xml must match with the < package name > of individual included xmls and should not be same for all the included files. Giving the correct in each included xmls resolved the issue. This link can be useful - http://www.codejava.net/frameworks/struts/splitting-modularizing-struts2-configuration-file
Upvotes: 1
Reputation: 1
I'm also facing the same problem, also try changing jar file as mention in above comment, but not solve the issue.
finally, i found typing mistake in my struts.xml file, for action
tag in package
tag. for type
attribute of action
tag i have given success or error.
Actually, there must be name
attribute instead of type
. for type
used for redirect page.
also in package
tag there namespace
attribute and i wrongly type nameSpace,
for this reasons i'm facing "The Struts dispatcher cannot be found".
but after i correcting my mistakes it's running well no issue...so just check your struts.xml file.
Upvotes: 0
Reputation: 248
Make sure the importing jars have the same struts2 version. I got this error because of
Struts2-Core-2.3.15.3.jar
and
struts2-dojo-plugin-2.3.20
I was able to resolve this by using version 2.3.15.3 for both jars.
Upvotes: 2
Reputation: 1
Please check your project structure, i.e web.xml is under WEB-INF folder, all view is under webcontent folder
Upvotes: 0
Reputation: 361
I think your problem was your web.xml file .
Just Change Your old filter tag to new one with one modification
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
So, it should work for this solution. However if it's not work, better way is just copy struts-blank.war file from this link struts.war. According to your version here i mean 2.x versions, download 2.x one rar file and extract it & in that copy struts-balnk.war and import to your ide
for eg:eclipse
in that directory structure under web content copy your jsp file 100% it will work.
Upvotes: 2
Reputation: 1841
This Exception may be due to 1)In Web.xml filter not defined or 2)The server doesn't look up the web.xml for Filter Dispatcher. Just clean the project, clean the server and restart the server. It will work.
Upvotes: 1
Reputation: 23587
As per the discussion problem seems to be due to directly accessing the JSP page and not letting the Struts2 Dispatcher to init the request processing cycle and create needed value stack and other parameters.
Best way in Struts or MVC2 based architecture is to go by Action even if your action is not doing any work for you.
Struts2 provides out of the box functionality for this, if we are not providing any action class in the configuration file Struts2 will create an Action class for us on the fly and will return SUCCESS as result.so we need to do following in our struts.xml file
<action name="myaction">
<result>/statusdonationjsp.jsp</result>
</action>
Updated
As per the new stack-trace seems that dojo plugin in missing from the class path.Please include struts2-dojo-plugin jar in your class path
Upvotes: 2