<?xml version="1.0" encoding="UTF-8"?>
<chapter id="sid-32473113">
   <title>Troubleshooting &amp; FAQ</title>
   <para>This section explains the cause of and solution to some common problems that people encounter when building applications with Errai.</para>
   <para>Of course, when lots of people trip over the same problem, it's probably because there is a deficiency in the framework! A FAQ list like this is just a band-aid solution. If you have suggestions for permanent fixes to these problems, please get in touch with us: file an issue in our issue tracker, chat with us on IRC, or post a suggestion on our forum.</para>
   <para>But for now, on to the FAQ:</para>
   <section id="sid-32473113_Troubleshooting%26FAQ-WhydoesitseemthatErraican%27tseemyclassatcompiletime%3F">
      <title>Why does it seem that Errai can't see my class at compile time?</title>
      <para>Possible symptoms:</para>
      <itemizedlist>
         <listitem>
            <para>
            uncaught exception: java.lang.RuntimeException: No proxy provider found for type:
            <emphasis role="italics">my.fully.qualified.ServiceName</emphasis>
            </para>
         </listitem>
      </itemizedlist>
      <para>
        <emphasis role="strong">Answer:</emphasis>
        Make sure the
        <xref linkend="sid-5931354"/>
        file is actually making it into your runtime classpath.
      </para>
      <para>One common cause of this problem is a &lt;resources&gt; section in pom.xml that includes src/main/java (to expose .java sources to the GWT compiler) that does not also include src/main/resources as a resource path. You must include both explicitly:</para>
      <informalexample>
         <programlisting language="xml">
&lt;resources&gt;
  &lt;resource&gt;
    &lt;directory&gt;src/main/java&lt;/directory&gt;
  &lt;/resource&gt;
  &lt;resource&gt;
    &lt;directory&gt;src/main/resources&lt;/directory&gt;
  &lt;/resource&gt;
&lt;/resources&gt;
</programlisting>
      </informalexample>
   </section>
   <section id="sid-32473113_Troubleshooting%26FAQ-WhyamIgetting%22java.lang.ClassFormatError%3AIllegalmethodname%22%3Cinit%3E%24%22inclassorg%2Fxyz%2Fpackage%2FMyClass%22%3F">
      <title>Why am I getting "java.lang.ClassFormatError: Illegal method name "&lt;init&gt;$" in class org/xyz/package/MyClass"?</title>
      <para>
        <emphasis role="strong">Answer:</emphasis>
        This error message means that your project has a (direct or indirect) subclass of JavaScriptObject that lacks a protected no-args constructor. All subtypes of JavaScriptObject (also known as
        <emphasis role="italics">overlay types</emphasis>
        ) must declare a protected no-args constructor, but the error message could be much clearer. There is an issue filed in the GWT project's bug tracker for improving the error message:
        <ulink url="http://code.google.com/p/google-web-toolkit/issues/detail?id=3383">GWT issue 3383</ulink>
        .
      </para>
   </section>
   <section id="sid-32473113_Troubleshooting%26FAQ-I%27mgetting%22java.lang.RuntimeException%3ATherearenoproxyprovidersregisteredyet.%22inmy@PostConstructmethod%21">
      <title>I'm getting "java.lang.RuntimeException: There are no proxy providers registered yet." in my @PostConstruct method!</title>
      <para>
        <emphasis role="strong">Answer:</emphasis>
        You can't invoke RPC methods via
        <code>Caller&lt;?&gt;</code>
        or by other means until after the Errai Bus has finished its initial handshake. Try changing your
        <code>@PostConstruct</code>
        annotation to
        <code>@AfterInitialization</code>
        . This will cause your method to be invoked later—after the bus handshake has completed.
      </para>
      <para>
        If this doesn't help, it is also possible that the proxies were never generated in the first place. Check in
        <code>.errai/RpcProxyLoaderImpl.java</code>
        to see if proxy code exists for the
        <code>@Remote</code>
        and/or
        <code>@Path</code>
        interface in question. If not, your
        <code>@Remote</code>
        interfaces were not present on the GWT compiler's classpath when your application module was compiled. Double-check your GWT compilation classpath: all
        <code>@Remote</code>
        interfaces must be visible to (in or inherited by) the GWT module that contains the
        <code>Caller&lt;?&gt;</code>
        types. Pay special attention that your
        <code>@Remote</code>
        and
        <code>@Path</code>
        interfaces are not in a package excluded from the GWT module (by default, every subpackage other than
        <code>client</code>
        and
        <code>shared</code>
        is invisible to the GWT compiler).
      </para>
   </section>
</chapter>
