我无法发现错误

时间:2014-02-13 07:50:55

标签: java spring-mvc

您好我已经做了一个if查询,这个问题转到了服务器。但是,服务器只接受2个数字和一个十进制数字(99.9),但我必须计数到100,服务器总是给我一个错误。 你知道我怎么能抓住这个错误,所以我的软件无论如何都要计到100.它一定不能输出到服务器。该程序应该只运行。他不会让它再次停在99并继续倒计时所以当他来到99然后是100时。

public static void main(String [] args)      {

    boolean positive = true;
    int counter = 0;


    while (true) 
    {

        if (counter >= 99)
        {
            positive = false;
        }
        if (counter <=-99)
        {
            positive = true;
        }

        if (positive == true)
        {   
            counter ++;
        }
        else 
        {   
            counter --;     
        }

那是我的“软件”,例外是:

Exception = Response was of unexpected text/html ContentType.  Incoming portion of HTML stream: <html><head><title>Apache Tomcat/7.0.47 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
</pre></p><p><b>root cause</b> <pre>java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException
    org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.&lt;init&gt;(SQLErrorCodeSQLExceptionTranslator.java:86)
    org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.&lt;init&gt;(SQLErrorCodeSQLExceptionTranslator.java:102)
    org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)
    org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605)
    org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:849)
    org.springframework.jdbc.core.simple.AbstractJdbcInsert.executeInsertAndReturnKeyHolderInternal(AbstractJdbcInsert.java:436)
    org.springframework.jdbc.core.simple.AbstractJdbcInsert.executeInsertAndReturnKeyInternal(AbstractJdbcInsert.java:417)
    org.springframework.jdbc.core.simple.AbstractJdbcInsert.doExecuteAndReturnKey(AbstractJdbcInsert.java:371)
    org.springframework.jdbc.core.simple.SimpleJdbcInsert.executeAndReturnKey(SimpleJdbcInsert.java:122)
    de.fraunhofer.iao.sharedefleet.energiemanagement.backend.ChargePointLogDAO.insertChargePointRequest(ChargePointLogDAO.java:65)
    de.fraunhofer.iao.sharedefleet.energiemanagement.facade.PlugAndChargeFacade.handleHeartbeatRequest(PlugAndChargeFacade.java:55)
    de.fraunhofer.iao.sharedefleet.energiemanagement.facade.PlugAndChargeFacade.requestChargingState(PlugAndChargeFacade.java:142)
    de.fraunhofer.iao.sharedefleet.energiemanagement.services.EVSEHeartbeatEndpoint.requestChargingState(EVSEHeartbeatEndpoint.java:34)
    sun.reflect.GeneratedMethodAccessor143.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.springframework.ws.server.endpoint.MethodEndpoint.invoke(MethodEndpoint.java:134)
    org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter.invokeInternal(DefaultMethodEndpointAdapter.java:240)
    org.springframework.ws.server.endpoint.adapter.AbstractMethodEndpointAdapter.invoke(AbstractMethodEndpointAdapter.java:53)
    org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:233)
    org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:173)
    org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
    org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:59)
    org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:239)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
</pre></p><p><b>root cause</b> <pre>java.lang.ClassNotFoundException: org.springframework.dao.QueryTimeoutException.

所以我希望你能帮助我。

多数民众赞成

public class Main {





 public static void main(String[] args) 
 {

    boolean positive = true;
    int counter = 0;


    while (true) 
    {

        if (counter >= 99)
        {
            positive = false;
        }
        if (counter <=-99)
        {
            positive = true;
        }

        if (positive == true)
        {   
            counter ++;
        }
        else 
        {   
            counter --;     
        }









        CloudCommunicator ccc = new CloudCommunicator("sh1");
        EnergyManagerJob emj = ccc.SendRequest (true  , true, 1 , 100 , "Nori2");



        System.out.println("\nmax Current: "  + emj.allowedMaximumCurrent);
        System.out.println("charging status: " +emj.chargingPending);
        System.out.println("power: " +emj.powerOn);




        try 
        {
            Thread.sleep(10000);
        } catch(InterruptedException ex) {
            Thread.currentThread().interrupt();
        }   




    }   // end of while


 }// end of main

3 个答案:

答案 0 :(得分:0)

对于您发布的错误,您需要find and add the spring-tx library到您的类路径。您可以将其添加到/WEB-INF/lib

但是,我不知道您发布的例外情况以及您发布的代码是如何相互关联的。

答案 1 :(得分:0)

服务器可能缺少依赖项:spring-tx

您可以在此处下载jar或将其添加到项目依赖项中:http://mvnrepository.com/artifact/org.springframework/spring-tx

答案 2 :(得分:0)

Sotirios Delimanolis是对的,请同时避免使用 while(true),因为它是一个无限循环,你可以举例如 while(positive),这会增加计数器直到达到99.