2011-12-01 7 views
5

मुझे जावा में Google ऐप इंजन का उपयोग करके अजीब संकलन समस्या है। मैं अपने कोड संकलित करें GWT करने का प्रयास करते मैं एक त्रुटि है कि इस प्रकार है मिलती है:जावा में जीडब्ल्यूटी संकलन मुद्दे (Google ऐप इंजन)

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 अनुप्रयोग इंजन पर मेरे कोड की तैनाती से मुझे रोक रहा है। मुझे लगता है क्योंकि यह अपनी इसी कारण im त्रुटि

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

मैं वास्तव में GWT और ग्रहण के लिए Google अनुप्रयोग इंजन का उपयोग कर के लिए नया हूँ, लेकिन im एक डेटाबेस अपनी टीम का उपयोग करने की कोशिश कर रही मेरी आयात के साथ अच्छी तरह नहीं चल रहा है Google क्लाउड एसक्यूएल का उपयोग करके बनाया गया। और मुझे लगता है कि मैं करीब आ रहा हूं, अगर मैं इन त्रुटियों को खत्म कर सकता हूं।

परियोजना कोड

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 

    } 

} 

क्या मैं इन त्रुटियों को ठीक करने के लिए कर सकता है पर कोई सुझाव? मैंने विभिन्न आयातों की कोशिश की लेकिन वे सभी जीडब्ल्यूटी कंपाइलर में एक ही मुद्दे का कारण बनते हैं।

संपादित करें: मैं 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

सबसे पहले है, जाँच करें कि यह एक classpath मुद्दा नहीं है बदल गया है - आप अर्थ में सभी आवश्यक जार की जरूरत नहीं है lib निर्देशिका और क्लासपाथ पर।

यदि यह विफल हो जाता है, तो सुनिश्चित करें कि यह कोड क्लाइंट साइड (आपके पैकेज नाम से अनुमान लगाने) नहीं है, जो जावास्क्रिप्ट में संकलित हो जाएगा। आप डेटाबेस कनेक्शन कोड के लिए ऐसा नहीं करना चाहते हैं, इसलिए आपको सर्वर कोड पर इस कोड का उपयोग करना चाहिए।

Client side & Server side कोड पर प्रलेखन देखें।

+0

मुझे लगता है! मैं पूरे समय सर्वर प्रकार कोड बना रहा था और मैंने सोचा कि यह क्लाइंट आधारित था। क्या आप एक नौसिखिया बता सकते हैं? :) अब मुझे सिर्फ जेएसपी और प्रश्नों के साथ अपने मुद्दों को समझना है ... धन्यवाद! – meriley

+1

कोई समस्या नहीं है। प्रयोग करते रहें और सीखते रहें। जब आप अटक जाते हैं, तो बस पूछें! एसओ के रास्ते की बात है! – gotomanners

संबंधित मुद्दे