GWT 无法加载模块

发布于 2024-12-20 05:27:07 字数 7850 浏览 1 评论 0原文

我是 Google 应用引擎的新手,正在开发一个项目。我刚刚创建了一个应用程序,当我尝试运行它时,它显示错误:

[ERROR] [ukstudentfeedback] 无法从用户代理“Mozilla/5.0(Macintosh;Intel Mac OS X 10_7_2)加载模块“ukstudentfeedback” AppleWebKit/535.2(KHTML,如 Gecko)Chrome/15.0.874.121 Safari/535.2' at localhost:51937。

下面是我的代码的快照:

package com.ukstudentfeedback.client;

import java.io.UnsupportedEncodingException;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;

public class Ukstudentfeedback implements EntryPoint{


    // ...
    public void onModuleLoad()
    {
        java.lang.System.out.println("I finally worked!");
        final Button sendButton;
        final TextBox toField, fromField, subjectField, messageField;

        sendButton = new Button("Send");
        toField = new TextBox();
        fromField = new TextBox();
        subjectField = new TextBox();
        messageField = new TextBox();

        sendButton.addStyleName("sendButton");

        toField.setText("Testing");
     // Add the nameField and sendButton to the RootPanel
     // Use RootPanel.get() to get the entire body element
        RootPanel.get("sendButton").add(sendButton);
        RootPanel.get("To").add(toField);
        RootPanel.get("From").add(fromField);
        RootPanel.get("Subject").add(subjectField);
        RootPanel.get("Message").add(messageField);

        // Focus the cursor on the to field when the app loads
                toField.setFocus(true);
                toField.selectAll();

                sendButton.setEnabled(true);


    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler, KeyUpHandler {
                /**
                 * Fired when the user clicks on the sendButton.
                 */
                public void onClick(ClickEvent event) {
                    java.lang.System.out.println("I have been clisked");
                    sendMessage();
                }

                @Override
                public void onKeyUp(KeyUpEvent event) {
                    // TODO Auto-generated method stub

                }



            public void sendMessage()
            {
                Properties props = new Properties();
                Session session = Session.getDefaultInstance(props, null);
                /*
                 * Get all the user's inputs
                 */
                String to = toField.getText();
                String from = fromField.getText();
                String subject = subjectField.getText();
                String message = messageField.getText();

                try 
                {
                    Message msg = new MimeMessage(session);
                    msg.setFrom(new InternetAddress(from, "Admin"));
                    msg.addRecipient(Message.RecipientType.TO,
                                     new InternetAddress(to, "Mr. User"));
                    msg.setSubject(subject);
                    msg.setText(message);
                    Transport.send(msg);

                } 
                catch (AddressException e) 
                {
                    // ...
                } catch (MessagingException e) 
                {
                    // ...
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }

    }
    // Add a handler to send the name to the server
            MyHandler handler = new MyHandler();
            sendButton.addClickHandler(handler);
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='ukstudentfeedback'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>

  <!-- Inherit the default GWT style sheet.  You can change       -->
  <!-- the theme of your GWT application by uncommenting          -->
  <!-- any one of the following lines.                            -->
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>
  <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

  <!-- Other module inherits                                      -->
  <inherits name='com.ukstudentfeedback.Ukstudentfeedback'/>
  <!-- Specify the app entry point class.                         -->
  <entry-point class='com.ukstudentfeedback.client.Ukstudentfeedback'/>

  <!-- Specify the paths for translatable code                    -->
  <source path='client'/>
  <source path='shared'/>

</module>

错误:

[DEBUG] [ukstudentfeedback] - Validating newly compiled units
[TRACE] [ukstudentfeedback] - Finding entry point classes
    [ERROR] [ukstudentfeedback] - Errors in 'file:/Users/umajosiah/Programming/Java/eclipse/workspace/ukstudentfeedback/src/com/ukstudentfeedback/client/Ukstudentfeedback.java'
        [ERROR] [ukstudentfeedback] - Line 8: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 9: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 10: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 11: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 12: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 13: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 14: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 80: Session cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 80: Session cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 91: Message cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 91: MimeMessage cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 92: InternetAddress cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 93: Message cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 94: InternetAddress cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 97: Transport cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 100: AddressException cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 103: MessagingException cannot be resolved to a type
    [ERROR] [ukstudentfeedback] - Unable to find type 'com.ukstudentfeedback.client.Ukstudentfeedback'
        [ERROR] [ukstudentfeedback] - Hint: Previous compiler errors may have made this type unavailable
        [ERROR] [ukstudentfeedback] - 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
[ERROR] [ukstudentfeedback] - Failed to load module 'ukstudentfeedback' from user agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2' at localhost:51937

I am new to Google app engine, and I'm working on a project. I just created an application and when I try to run it, it shows the error:

[ERROR] [ukstudentfeedback] Failed to load module 'ukstudentfeedback' from user agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2' at localhost:51937.

Below is a snap shot of my code:

package com.ukstudentfeedback.client;

import java.io.UnsupportedEncodingException;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;

public class Ukstudentfeedback implements EntryPoint{


    // ...
    public void onModuleLoad()
    {
        java.lang.System.out.println("I finally worked!");
        final Button sendButton;
        final TextBox toField, fromField, subjectField, messageField;

        sendButton = new Button("Send");
        toField = new TextBox();
        fromField = new TextBox();
        subjectField = new TextBox();
        messageField = new TextBox();

        sendButton.addStyleName("sendButton");

        toField.setText("Testing");
     // Add the nameField and sendButton to the RootPanel
     // Use RootPanel.get() to get the entire body element
        RootPanel.get("sendButton").add(sendButton);
        RootPanel.get("To").add(toField);
        RootPanel.get("From").add(fromField);
        RootPanel.get("Subject").add(subjectField);
        RootPanel.get("Message").add(messageField);

        // Focus the cursor on the to field when the app loads
                toField.setFocus(true);
                toField.selectAll();

                sendButton.setEnabled(true);


    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler, KeyUpHandler {
                /**
                 * Fired when the user clicks on the sendButton.
                 */
                public void onClick(ClickEvent event) {
                    java.lang.System.out.println("I have been clisked");
                    sendMessage();
                }

                @Override
                public void onKeyUp(KeyUpEvent event) {
                    // TODO Auto-generated method stub

                }



            public void sendMessage()
            {
                Properties props = new Properties();
                Session session = Session.getDefaultInstance(props, null);
                /*
                 * Get all the user's inputs
                 */
                String to = toField.getText();
                String from = fromField.getText();
                String subject = subjectField.getText();
                String message = messageField.getText();

                try 
                {
                    Message msg = new MimeMessage(session);
                    msg.setFrom(new InternetAddress(from, "Admin"));
                    msg.addRecipient(Message.RecipientType.TO,
                                     new InternetAddress(to, "Mr. User"));
                    msg.setSubject(subject);
                    msg.setText(message);
                    Transport.send(msg);

                } 
                catch (AddressException e) 
                {
                    // ...
                } catch (MessagingException e) 
                {
                    // ...
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }

    }
    // Add a handler to send the name to the server
            MyHandler handler = new MyHandler();
            sendButton.addClickHandler(handler);
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='ukstudentfeedback'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>

  <!-- Inherit the default GWT style sheet.  You can change       -->
  <!-- the theme of your GWT application by uncommenting          -->
  <!-- any one of the following lines.                            -->
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>
  <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

  <!-- Other module inherits                                      -->
  <inherits name='com.ukstudentfeedback.Ukstudentfeedback'/>
  <!-- Specify the app entry point class.                         -->
  <entry-point class='com.ukstudentfeedback.client.Ukstudentfeedback'/>

  <!-- Specify the paths for translatable code                    -->
  <source path='client'/>
  <source path='shared'/>

</module>

Errors:

[DEBUG] [ukstudentfeedback] - Validating newly compiled units
[TRACE] [ukstudentfeedback] - Finding entry point classes
    [ERROR] [ukstudentfeedback] - Errors in 'file:/Users/umajosiah/Programming/Java/eclipse/workspace/ukstudentfeedback/src/com/ukstudentfeedback/client/Ukstudentfeedback.java'
        [ERROR] [ukstudentfeedback] - Line 8: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 9: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 10: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 11: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 12: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 13: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 14: The import javax.mail cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 80: Session cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 80: Session cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 91: Message cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 91: MimeMessage cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 92: InternetAddress cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 93: Message cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 94: InternetAddress cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 97: Transport cannot be resolved
        [ERROR] [ukstudentfeedback] - Line 100: AddressException cannot be resolved to a type
        [ERROR] [ukstudentfeedback] - Line 103: MessagingException cannot be resolved to a type
    [ERROR] [ukstudentfeedback] - Unable to find type 'com.ukstudentfeedback.client.Ukstudentfeedback'
        [ERROR] [ukstudentfeedback] - Hint: Previous compiler errors may have made this type unavailable
        [ERROR] [ukstudentfeedback] - 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
[ERROR] [ukstudentfeedback] - Failed to load module 'ukstudentfeedback' from user agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2' at localhost:51937

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橘香 2024-12-27 05:27:07

问题是您试图在客户端上使用未实现的 java 类。邮件发送需要从服务器进行,​​并且服务器永远无法从 javax.mail 类传回任何内容。

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

这些都不是可序列化的,也都不能转换为 Javascript,因为它们都不是由 GWT 实现的。请此处此处

The problem is that you're trying to use unimplemented java classes on the client. The mailing needs to happen from the server, and the server can never pass back anything from the javax.mail classes.

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

None of this is serializable, and none of it can be turned to Javascript, because none of it is implemented by GWT. Read more about this here and here.

九公里浅绿 2024-12-27 05:27:07

您只能使用 GWT 模拟的类。未模拟包 javax.mail。
您必须在服务器上执行此操作。

    [ERROR] [ukstudentfeedback] - Line 8: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 9: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 10: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 11: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 12: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 13: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 14: The import javax.mail cannot be resolved

请参阅以下链接:

http://code.google.com/webtoolkit/doc/最新/RefJreEmulation.html

You can use only the classes that are emulated by GWT. Package javax.mail is not emulated.
You have to do this on the server.

    [ERROR] [ukstudentfeedback] - Line 8: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 9: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 10: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 11: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 12: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 13: The import javax.mail cannot be resolved
    [ERROR] [ukstudentfeedback] - Line 14: The import javax.mail cannot be resolved

Pls see link below:

http://code.google.com/webtoolkit/doc/latest/RefJreEmulation.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文