【问题标题】:Vaadin - My JavaScript library is not loaded although I used the JavaScript annotationVaadin - 尽管我使用了 JavaScript 注释,但我的 JavaScript 库没有加载
【发布时间】:2014-09-16 18:35:39
【问题描述】:

晚上好,

起初,对于这可能是初学者的错误,我真的很抱歉。我已经使用 Vaadin 6 工作了几个月,最近又回到了 Vaadin 7(所以我仍在努力解决所有问题)。

附上你发现我的问题实际上是什么的一个非常小的例子。我尝试为 Vaadin 使用非常流行的 ReCaptcha 插件,并且我正在按照说明做所有事情(至少我认为我会这样做)。但是在启动时我遇到了一个异常,它说:

java.lang.NoClassDefFoundError: net/tanesha/recaptcha/ReCaptchaImpl
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    ...
Caused by: java.lang.ClassNotFoundException: net.tanesha.recaptcha.ReCaptchaImpl
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)
    ... 45 more

我的最小源代码(让我再次指出所附的最小示例)是:

import com.vaadin.annotations.JavaScript;
import com.vaadin.annotations.Theme;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.wcs.wcslib.vaadin.widget.recaptcha.ReCaptcha;
import com.wcs.wcslib.vaadin.widget.recaptcha.shared.ReCaptchaOptions;

@SuppressWarnings("serial")
@Theme("test")
@JavaScript("http://www.google.com/recaptcha/api/js/recaptcha_ajax.js")
public class TestUI extends UI {

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        Button button = new Button("Click Me");
        button.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                layout.addComponent(new Label("Thank you for clicking"));
            }
        });
        layout.addComponent(button);

        ReCaptcha captcha = new ReCaptcha(
                "6Lfv5OoSAAAAAPEbWhNB0ERopfQpRxr8_5yncOmg",
                "6Lfv5OoSAAAAAHa4zmExf6w2ja3vm-8ABKgyepq-",
                new ReCaptchaOptions() {
                    {
                        theme = "white";
                    }
                });
        layout.addComponent(captcha);
    }

}

我感觉 JavaScript 库没有加载,我不明白为什么会这样。如果我检查网站的源代码,我也找不到库。如果是这种情况(或者如果我做错了什么),如果你们中的某个人能给我答案来纠正这个问题,我会非常高兴。

非常感谢您的回答。如果您需要更多详细信息,我很乐意提供(让我再次指出随附的示例项目 :-) 请随意查看)

附件:

最小的项目 (https://dl.dropboxusercontent.com/u/40355908/Test.rar)

【问题讨论】:

    标签: java javascript annotations vaadin


    【解决方案1】:

    插件需要另一个库才能工作:net.tanesha.recaptcha4j:recaptcha4j:0.0.7

    https://github.com/wbstr/vaadin-recaptcha/blob/master/vaadin-recaptcha/pom.xml

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-08
      • 1970-01-01
      相关资源
      最近更新 更多