2011-12-01 4 views
5

eclipse를 사용하여 Java의 Google App 엔진을 사용하여 이상한 컴파일 문제가 발생했습니다. 내 코드를 컴파일 GWT하려고 할 때 다음과 같이 오류 얻을 :자바에서 GWT 컴파일 문제 (Google App Engine)

Compiling module beer.SQLBeer 
    Validating newly compiled units 
     Ignored 1 unit with compilation errors in first pass. 
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors. 
    Finding entry point classes 
     [ERROR] Errors in 'file:/C:/Users/Mark/workspace/SQLBeer/src/beer/client/SQLBeer.java' 
     [ERROR] Line 12: The import com.google.appengine.api.rdbms cannot be resolved 
     [ERROR] Line 13: The import com.google.apphosting cannot be resolved 
     [ERROR] Line 14: The import com.google.cloud cannot be resolved 
     [ERROR] Line 18: ServersServlet cannot be resolved to a type 
     [ERROR] Line 22: The method doPost(HttpServletRequest, HttpServletResponse) of type SQLBeer must override or implement a supertype method 
     [ERROR] Line 26: Connection cannot be resolved to a type 
     [ERROR] Line 28: AppEngineDriver cannot be resolved to a type 
     [ERROR] Line 29: Connection cannot be resolved to a type 
     [ERROR] Unable to find type 'beer.client.SQLBeer' 
     [ERROR] Hint: Previous compiler errors may have made this type unavailable 
     [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly 
Exception in thread "UnitWriteThread" 

나는 그것이 수입을 해결할 수없는 이유를 잘 모르겠습니다을, 이것은 Google 앱 엔진에 내 코드를 배포에서 저를 방지한다. 이 오류

[ERROR] Line 22: The method doPost(HttpServletRequest, HttpServletResponse) of type SQLBeer must override or implement a supertype method 

내가 GWT와 이클립스에 대한 구글 앱 엔진을 사용하여 정말 새로운,하지만 메신저는 데이터베이스 내 팀에 액세스하려고에게 점점 내 수입 멋지게 그 같은 이유로 메신저를 재생하지 않기 때문에 느낌 Google Cloud SQL을 사용하여 생성되었습니다. 그리고 나는이 오류가 끝나면 끝나가는 것처럼 느낍니다.

프로젝트 코드

package beer.client; 


import java.io.IOException; 
import java.io.PrintWriter; 
import java.sql.DriverManager; 
import java.sql.SQLException; 

import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 

import com.google.appengine.api.rdbms.AppEngineDriver; 
import com.google.apphosting.utils.servlet.ServersServlet; 
import com.google.cloud.sql.jdbc.Connection; 


@SuppressWarnings("serial") 
public class SQLBeer extends ServersServlet { 


    @Override 
    public void doPost(HttpServletRequest req, HttpServletResponse resp) 
      throws IOException { 

     PrintWriter out = resp.getWriter(); 
     Connection c = null; 
     try { 
      DriverManager.registerDriver(new AppEngineDriver()); 
      c = (Connection) DriverManager 
        .getConnection("jdbc:google:rdbms://asu.edu:cst433team1:team1db/mysql"); 
      String fname = req.getParameter("fname"); 
      String content = req.getParameter("content"); 

      /** 
      * This code appears to do the web form fun 
      */ 
//   if (fname == "" || content == "") { 
//    out.println("<html><head></head><body>You are missing either a message or a name! Try again! Redirecting in 3 seconds...</body></html>"); 
//   } else { 
//    String statement = "INSERT INTO entries (guestName, content) VALUES(? , ?)"; 
//    PreparedStatement stmt = c.prepareStatement(statement); 
//    stmt.setString(1, fname); 
//    stmt.setString(2, content); 
//    int success = 2; 
//    success = stmt.executeUpdate(); 
//    if (success == 1) { 
//     out.println("<html><head></head><body>Success! Redirecting in 3 seconds...</body></html>"); 
//    } else if (success == 0) { 
//     out.println("<html><head></head><body>Failure! Please try again! Redirecting in 3 seconds...</body></html>"); 
//    } 
//   } 
     } catch (SQLException e) { 
      e.printStackTrace(); 
     } finally { 
      if (c != null) 
       try { 
        c.close(); 
       } catch (SQLException ignore) { 
       } 
     } 
     //resp.setHeader("Refresh", "3; url=/beer.jsp"); 
    } 

    /** 
    * @param args 
    */ 
    public static void main(String[] args) { 
     // TODO Auto-generated method stub 

    } 

} 

내가 이러한 오류를 해결하기 위해 무엇을 할 수 있는지에 대한 어떤 제안? 필자는 다른 수입을 시도했지만 모두 GWT 컴파일러에서 같은 문제를 일으키는 것으로 보입니다.

편집 : 나는이 HttpServlet을로 확장하고 현재 오류가

Compiling module beer.SQLBeer 
    Validating newly compiled units 
     Ignored 1 unit with compilation errors in first pass. 
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors. 
    Finding entry point classes 
     [ERROR] Errors in 'file:/C:/Users/Mark/workspace/SQLBeer/src/beer/client/SQLBeer.java' 
     [ERROR] Line 13: The import com.google.appengine.api.rdbms cannot be resolved 
     [ERROR] Line 14: The import com.google.cloud cannot be resolved 
     [ERROR] Line 26: Connection cannot be resolved to a type 
     [ERROR] Line 28: AppEngineDriver cannot be resolved to a type 
     [ERROR] Line 29: Connection cannot be resolved to a type 
     [ERROR] Unable to find type 'beer.client.SQLBeer' 
     [ERROR] Hint: Previous compiler errors may have made this type unavailable 
     [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly 
Exception in thread "UnitWriteThread" java.lang.RuntimeException: Unable to read from byte cache 

답변

5

먼저 조금 다른,이 클래스 경로의 문제가 아니라는 것을 확인 변경 -에 필요한 모든 병이없는 당신에게 의미가 lib 디렉토리와 클래스 경로에 있습니다.

이 코드가 실패하면 클라이언트 측 (패키지 이름에서 추측)이 아닌지 확인하십시오. 그러면 패키지가 javascript로 컴파일됩니다. 데이터베이스 연결 코드에서이 작업을 수행하지 않으려면 서버 측에서이 코드를 사용해야합니다.

Client side & Server side 코드를 참조하십시오.

+0

나는 본다! 나는 전체 시간에 서버 유형 코드를 작성하고 있었고 클라이언트 기반이라고 생각했습니다. 초보자 한테 말해 줄래요? :) 이제 JSP 및 질의를 통해 문제를 파악해야합니다 ... 감사합니다! – meriley

+1

문제 없습니다. 실험을 계속하고 계속 배우십시오. 막혔 으면 물어보십시오! 그게 전부 야! – gotomanners