2011-12-01 23 views
5

Tôi gặp sự cố biên dịch lạ khi sử dụng công cụ Google App trong java bằng nhật thực. Khi tôi cố gắng GWT Biên dịch mã của tôi tôi nhận được một lỗi đó là như sau:Các vấn đề biên dịch GWT trong Java (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" 

Tôi không chắc chắn lý do tại sao nó không thể giải quyết hàng nhập khẩu, và điều này được ngăn chặn tôi từ việc triển khai mã của tôi vào công cụ ứng dụng của Google. Tôi cảm thấy bởi vì nó không được chơi độc đáo với hàng nhập khẩu của tôi của nó cùng một lý do im nhận được lỗi

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

Tôi thực sự mới để sử dụng GWT và App Engine của Google cho Eclipse, nhưng im cố gắng để truy cập vào một cơ sở dữ liệu đội của tôi được tạo bằng Google Cloud SQL. Và tôi cảm thấy như im đang đến gần, nếu tôi có thể vượt qua những lỗi này.

Bộ luật Dự án

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 

    } 

} 

bất cứ đề nghị về những gì tôi có thể làm gì để sửa chữa các lỗi này? Ive đã thử nhập khẩu khác nhau nhưng tất cả dường như dẫn đến các vấn đề tương tự trong trình biên dịch GWT.

EDIT: Tôi đã thay đổi mở rộng đến HttpServlet và bây giờ là lỗi là một chút khác nhau

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 

Trả lời

5

Thứ nhất, kiểm tra rằng đây không phải là một vấn đề classpath - có nghĩa là bạn không có tất cả các yêu cầu trong lọ thư mục lib và trên classpath.

Nếu không thành công, hãy đảm bảo rằng mã này không phải là phía Máy khách (đoán từ tên gói của bạn), sẽ được biên dịch thành javascript. Bạn không muốn điều này xảy ra cho mã kết nối cơ sở dữ liệu, do đó bạn nên sử dụng mã này ở phía máy chủ.

Xem Tài liệu trên Client side & Server side mã.

+0

Tôi hiểu! Tôi đã tạo mã loại máy chủ toàn bộ thời gian và tôi nghĩ rằng đó là khách hàng dựa. Bạn có thể nói cho im một người mới? :) Bây giờ tôi chỉ cần tìm ra các vấn đề của tôi với các truy vấn và truy vấn của JSP ... Cảm ơn! – meriley

+1

Không sao cả. Tiếp tục thử nghiệm và tiếp tục học tập. Khi bạn bị kẹt, chỉ cần hỏi! Đó là cách của SO! – gotomanners

Các vấn đề liên quan