GWT 2.6.0 - 未捕获的java.lang.ClassCastException

时间:2015-07-07 16:34:22

标签: javascript java debugging gwt

我在超级开发模式下使用GWT 2.6.0(适用于Linux的IntelliJ Idea 14 + Chrome 43.0.2357.130(64位))。

我在页面加载期间在Chrome控制台中有例外

Impl.java:99

com.google.gwt.core.client.impl.Impl public static native JavaScriptObject entry(JavaScriptObject jsFunction) /*-{ return function() { try { return @com.google.gwt.core.client.impl.Impl::entry0(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)(jsFunction, this, arguments); } catch (e) { // This catch block is here to ensure that the finally block in entry0 // will be executed correctly on IE6/7. We can't put a catch Throwable // in entry0 because this would always cause the unhandled exception to // be wrapped in a JavaScriptException type. throw e; } }; }-*/;

抛出e;
oldstar-0.js:87303
生成的oldstar-0.js中

function gwtOnLoad(errFn, modName, modBase, softPermutationId){ $moduleName = modName; $moduleBase = modBase; if (errFn) try { $entry(init_2)(); } catch (e) { errFn(modName); } else { $entry(init_2)(); } } $ entry(init_2)();

package com.google.gwt.lang;

final class ClassLiteralHolder {
}
init() in EntryMethodHolder.java

还有 init_2(),这是对package com.google.gwt.lang; /** * This class holds the boot strap entry method that the compiler generates. */ public class EntryMethodHolder { public static final void init() { // Filled in by the compiler to call entry methods. } } 的引用

<ul id="nav">
  <li>
    <label style="display: inline;">
      <a class="dkblue strong">Search</a>
    </label>
    <br>
    <a id="productnav1" href="javascript:void(0)" class="blck-dkblue">
      <span>Products</span></a>
    <div class="clear"></div>           
    <div id="productnav" class="menu" style="display: block;">
    <!--  open new section -->
      <div class="level_1">
        <section>
          <header>
            <h5>1</h5>
            <label><small><strong>Select</strong></small><br>Category</label>
          </header>
          <div class="clear"></div>
          <div class="pull-left">
            <ul class="sep nav-product">
              <li class="group">
                <a class="cat-name" href="#" style="cursor: default;">AC-DC</a>         
                <ul class="nav-product">
                  <div>
                    <ul class="sep nav-product">
                      <li>
                        <a href="#">Board Mount</a>         
                        <ul class="nav-product">
                          <!--  open new section -->
                          <div class="level_2">
                            <div class="level_3">
                              <section>
                                <div class="1stdiv"></div>
                                <h3 class="blue">Lorem ipsum</h3>
                              </section>
                            </div>
                            <section>
                              <header>
                              <h5>2</h5>
                                <label>
                                  <small>
                                    <strong>Select</strong>
                                  </small>
                                  <br>&nbsp;
                                  <a href="#" class="blue" style="cursor: default;">AC-DC</a>&nbsp;
                                  <a href="http://www.test.com/ac-dc/boardmount" class="blue">Board Mount</a>&nbsp;
                                </label>
                              </header>
                              <div class="clear"></div>
                              <div>
                                <ul class="sep nav-product">
                                  <li class="group">
                                    <a href="#" style="cursor: default;">Surf Corrected</a>
                                    <ul class="nav-product">
                                      <div>
                                        <ul class="sep nav-product">
                                          <li class="group">
                                            <a href="#" style="cursor: default;">Universal Input</a>
                                            <ul class="nav-product">
                                              <div>
                                              <ul class="sep nav-product">
                                                <li>
                                                  <a href="http://www.test.com/ac-dc/boardmount/VIA-PFM">VIA PFM</a>
                                                </li>

1 个答案:

答案 0 :(得分:0)

粘贴的代码是JS和Java之间的边界,并且极不可能抛出此异常(我敢说不可能)。

正如消息所示,它是一个未捕获的异常,它在代码中的其他地方被抛出,并且在它从Java泄漏到JS之前被这种连线捕获。

认为您的EntryPoint由EntryMethodHolder.init调用 - 这强烈暗示您的EntryPoint在您的应用尝试启动时抛出ClassCastException,但UncaughtExceptionHandler(如果您有一个.. 。)尚未设置处理此问题。

尝试查看onModuleLoad中的内容,或添加try / catch来确定其来源。