2016-08-07 8 views
1

私はこの例外を取得しています - >SpringDaoMvcアプリケーションでExpectedOutputを取得できませんか?

org.apache.jasper.JasperExceptionが:JSPのクラスをコンパイルできません:

データベースに名前Xで街を探索しようとしているとき。以下は

誰もが私はこれを修正することができますどのように私を導くことはできますか?のStackTrace

SEVERE: Servlet.service() for servlet [MainServlet] in context with path [/SpringDaoMvc] threw exception [Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file 
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files 

Stacktrace:] with root cause 
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file 
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files 

Stacktrace: 
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102) 
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331) 
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457) 
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378) 
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) 
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) 
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) 
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471) 
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402) 
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329) 
at MainServlet.doGet(MainServlet.java:43) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) 
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) 
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) 
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579) 
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at java.lang.Thread.run(Thread.java:745) 

ですかBELOW

MYコード:

1)index.html 


<form action="MainServlet" method="get"> 
<input type="text" name="city"> 
<input type="submit" name="getDetails"> 
</form> 

2)MainServlet:

public class MainServlet extends HttpServlet 
{ 
ModelBean bobj; 
public MainServlet() 
{ 
    super(); 
    // TODO Auto-generated constructor stub 
} 
public void init() 
{ 
    //Activate SpringContainer 
    ApplicationContext bfact=new ClassPathXmlApplicationContext("ModelCfg.xml"); 

    //getSpringBean class Object from Container 
    bobj=(ModelBean)bfact.getBean("mb"); 
} 
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{ 
    //readFormData 
    String city=request.getParameter("city"); 
    //Call Bmethod 
    List l=bobj.searchStudents(city); 
    request.setAttribute("attr1",l); 
    //Forward the request to resultPage 
    RequestDispatcher rd=request.getRequestDispatcher("result.jsp"); 
    rd.forward(request,response); 
} 

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{ 
    doGet(request, response); 
} 
public void destroy() 
{ 
    bobj=null; 
} 

} 

3)ModelBean

public class ModelBean implements Model 
{ 
ModelDao mdao; 
public void setMdao(ModelDao mdao) 
{ 
    this.mdao = mdao; 
} 

public ModelDao getMdao() 
{ 
    return mdao; 
} 

@Override 
public List searchStudents(String city) 
{ 
    //blogic 
      if(city==null||city.equals("")) 
      { 
       city="Hyderabad"; 
      } 
       //use persistance Logic of Dao class. 
      List l=mdao.getDetails(city); 
      return l; 
} 


} 

4)ModelDao:

public class ModelDao 
{ 
JdbcTemplate jt; 

public JdbcTemplate getJt() 
{ 
    return jt; 
} 

public void setJt(JdbcTemplate jt) 
{ 
    this.jt = jt; 
} 
public List getDetails(String city) 
{ 
    List l=jt.queryForList("Select * from StudentSpringDao where saddress=?",new Object[]{city}); 
    return l; 

} 


} 

5)ModelCfg.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans 
xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:p="http://www.springframework.org/schema/p" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> 
    <bean id="bds" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/> 
    <property name="url" value="jdbc:mysql://localhost:3306/JalajSchema"/> 
    <property name="username" value="root"/> 
    <property name="password" value=""/> 
    <!-- <property name="MaxActive" value="15"/> 
    <property name="MaxIdle" value="5"/> 
    <property name="MaxWait" value="5000"/>--> 
    </bean> 
<bean id="template" class="org.springframework.jdbc.core.JdbcTemplate"> 
<property name="dataSource" ref="bds"/> 
</bean> 
<bean id="mydao" class="ModelDao"> 
<property name="jt" ref="template"/> 
</bean> 
<bean id="mb" class="ModelBean"> 
<property name="mdao" ref="mydao"/> 
</bean> 

6)はresult.jsp追加され

<%@page import="java.util.*" %> 
<% 
List l=(List)request.getAttribute("attr1"); 
%> 
<table> 
<tr> 
<th>Sno</th> 
<th>Sname</th> 
<th>Saddress</th> 
</tr> 
<% 
for(int i=0;i<l.size();i++) 
{ 
Map m=(Map)l.get(i); %> 
<tr> 
<td><%=m.get("sno") %></td> 
<td><%=m.get("sname") %></td> 
<td><%=m.get("saddress") %></td> 
</tr> 
<% 
} 
%> 

jarファイル:

commons-logging-1.2.jar 
mysql-connector-java-5.1.25-bin.jar 

spring-aop-3.2.0.RELEASE.jar 

spring-aspects-3.2.0.RELEASE.jar 

spring-beans-3.2.0.RELEASE.jar 

spring-context-3.2.0.RELEASE.jar 

spring-context-support-3.2.0.RELEASE.jar 

spring-core-3.2.0.RELEASE.jar 

spring-expression-3.2.0.RELEASE.jar 

spring-instrument-3.2.0.RELEASE.jar 

spring-instrument-tomcat-3.2.0.RELEASE.jar 

spring-jdbc-3.2.0.RELEASE.jar 

spring-jms-3.2.0.RELEASE.jar 

spring-orm-3.2.0.RELEASE.jar 

spring-oxm-3.2.0.RELEASE.jar 

spring-struts-3.2.0.RELEASE.jar 

spring-test-3.2.0.RELEASE.jar 

spring-tx-3.2.0.RELEASE.jar 

spring-web-3.2.0.RELEASE.jar 

spring-webmvc-3.2.0.RELEASE.jar 

spring-webmvc-portlet-3.2.0.RELEASE.jar 

答えて

0

おそらくアプリケーションサーバとの間の互換性の問題(Tomcatと思われる)とjdk。チェックthis post

関連する問題