RequestFactory error

750 views
Skip to first unread message

Pavel Byles

unread,
May 17, 2011, 10:36:46 PM5/17/11
to Google-Web-Toolkit
For some reason I'm getting this error while trying to set up my code to use RequestFactory:

No source code is available for type com.google.web.bindery.requestfactory.shared.Request<T>; did you forget to inherit a required module?
No source code is available for type com.google.web.bindery.requestfactory.shared.RequestFactory; did you forget to inherit a required module?


My project.gwt.xml file contains the following inherits element:

<inherits name='com.google.gwt.requestfactory.RequestFactory' />


I also have my web.xml set up correctly too.

Does anyone have any idea why I get this error?

--
Pavel Byles

Juan Pablo Gardella

unread,
May 17, 2011, 10:51:13 PM5/17/11
to google-we...@googlegroups.com

See javadoc:

RequestFactory has moved to com.google.web.bindery.requestfactory. This package will be removed in a future version of GWT.


Check if the module is in the new package

2011/5/17 Pavel Byles <pavel...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Hilco Wijbenga

unread,
May 17, 2011, 10:53:29 PM5/17/11
to google-we...@googlegroups.com

Yes, com.google.gwt.requestfactory is deprecated. Use
com.google.web.bindery.requestfactory.RequestFactory. This has been
mentioned once or twice... ;-)

Pavel Byles

unread,
May 17, 2011, 11:23:12 PM5/17/11
to google-we...@googlegroups.com
Hmm.. I saw this but didn't realised it applied to the *.gwt.xml!
Thanks for the help!!
--
-Pav

Pavel Byles

unread,
Sep 11, 2011, 2:41:01 AM9/11/11
to google-we...@googlegroups.com
I'm now getting:
Caused by: java.lang.NoClassDefFoundError: org/json/JSONException
Caused by: java.lang.ClassNotFoundException: null

at this line:
requestFactory.employeeRequest().getName().fire(new Receiver<String>() {
  @Override public void onSuccess(String response) {
  nameField.setText(response);
}});

I've included the requestfactory-server.jar, validation-api-1.0.0.GA.jar and hibernate-validator-4.1.0.jar.
My *.gwt.xml file contains:
<inherits name='com.google.web.bindery.requestfactory.RequestFactory' />

I'm using GWT2.4


I've been trying to figure this out for days and I can't see what's wrong.
--
Pav

Y2i

unread,
Sep 11, 2011, 3:26:22 AM9/11/11
to google-we...@googlegroups.com
Sometimes ClassNotFound occurs when there are 2 conflicting classes.  Check this out, may be it's related to your problem: requestfactory-server.jar has a copy of org/json/JSONException, and you may have another copy sitting somewhere (just a guess)

Pavel Byles

unread,
Sep 11, 2011, 10:56:35 PM9/11/11
to google-we...@googlegroups.com
Thanks for your help, however I'm still getting the same error.

On Sun, Sep 11, 2011 at 2:26 AM, Y2i <yur...@gmail.com> wrote:
Sometimes ClassNotFound occurs when there are 2 conflicting classes.  Check this out, may be it's related to your problem: requestfactory-server.jar has a copy of org/json/JSONException, and you may have another copy sitting somewhere (just a guess)

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
--
Pav

Y2i

unread,
Sep 11, 2011, 11:43:02 PM9/11/11
to google-we...@googlegroups.com
Do you have org/json/JSONException anywhere in your class path?  May be your are using unbundled version of requestfactory-server.jar? 

Pavel Byles

unread,
Sep 12, 2011, 1:00:34 AM9/12/11
to google-we...@googlegroups.com
Yes, I downloaded the maven version of requestfactory-server and I've copied the org.json jar to my war/lib dir.

On Sun, Sep 11, 2011 at 10:43 PM, Y2i <yur...@gmail.com> wrote:
Do you have org/json/JSONException anywhere in your class path?  May be your are using unbundled version of requestfactory-server.jar? 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
--
Pav

Y2i

unread,
Sep 12, 2011, 1:26:38 AM9/12/11
to google-we...@googlegroups.com
Does java.lang.NoClassDefFoundError: org/json/JSONException happen during compilation or run-time?

Alexander Orlov

unread,
Sep 12, 2011, 3:34:10 AM9/12/11
to google-we...@googlegroups.com
Try to include gwt-servlet-deps.jar in compile scope, although you don't need it at all... This is the minimal configuration for RF.

Pavel Byles

unread,
Sep 12, 2011, 11:42:44 AM9/12/11
to google-we...@googlegroups.com
It happens at run time.
I have 0 errors and 0 warnings at compile time.

On Mon, Sep 12, 2011 at 12:26 AM, Y2i <yur...@gmail.com> wrote:
Does java.lang.NoClassDefFoundError: org/json/JSONException happen during compilation or run-time?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
--
Pav

Y2i

unread,
Sep 12, 2011, 11:59:33 AM9/12/11
to google-we...@googlegroups.com
Not sure what to say...

May be, if you are in Eclipse, type Ctrl+Shift+T and search for JSONException.  How many do you see?  My hope is you'll see more then one.
Another option is trying to add org.json to your class path if it's not there yet (but if it was required for compilation, you would not be able to compile, so I'm not sure if this would help).

Alexander Orlov

unread,
Sep 12, 2011, 12:29:25 PM9/12/11
to google-we...@googlegroups.com
"Compile" scope in Maven means that it's also available at runtime. I had exact the same error several times and as far as I remember I solved it by adding gwt-servlet-deps.jar to the system scope which is basically the same as the compile scope in Maven.

Also gwt-servlet-deps.jar has JSONException you're missing.

Pavel Byles

unread,
Sep 12, 2011, 12:36:45 PM9/12/11
to google-we...@googlegroups.com
Hi Alexander,
I removed my hibernate-validator (because I was getting errors from that for some reason about missing org.loggerfactory).

I'm making progress!!! (I think)

So now I'm getting a 500 error: Problem accessing /gwtRequest

On Mon, Sep 12, 2011 at 11:29 AM, Alexander Orlov <alexand...@loxal.net> wrote:
"Compile" scope in Maven means that it's also available at runtime. I had exact the same error several times and as far as I remember I solved it by adding gwt-servlet-deps.jar to the system scope which is basically the same as the compile scope in Maven.

Also gwt-servlet-deps.jar has JSONException you're missing.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
--
Pav

Pavel Byles

unread,
Sep 12, 2011, 12:38:18 PM9/12/11
to google-we...@googlegroups.com
I added the gwt-servlet-deps.jar btw.

On Mon, Sep 12, 2011 at 11:29 AM, Alexander Orlov <alexand...@loxal.net> wrote:
"Compile" scope in Maven means that it's also available at runtime. I had exact the same error several times and as far as I remember I solved it by adding gwt-servlet-deps.jar to the system scope which is basically the same as the compile scope in Maven.

Also gwt-servlet-deps.jar has JSONException you're missing.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
--
Pav

Alexander Orlov

unread,
Sep 12, 2011, 12:41:16 PM9/12/11
to google-we...@googlegroups.com
Did you add a corresponding RF servlet handler to your web.xml?

    <servlet>
        <servlet-name>reqFactory</servlet-name>
        <servlet-class>com.google.web.bindery.requestfactory.server.RequestFactoryServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>reqFactory</servlet-name>
        <url-pattern>planer/gwtRequest</url-pattern>
    </servlet-mapping>

Alexander Orlov

unread,
Sep 12, 2011, 12:43:20 PM9/12/11
to google-we...@googlegroups.com
in your case maybe: <url-pattern>/gwtRequest</url-pattern>

Pavel Byles

unread,
Sep 12, 2011, 1:22:24 PM9/12/11
to google-we...@googlegroups.com
Here's what I have:

<servlet>
  <servlet-name>requestFactoryServlet</servlet-name>
  <servlet-class>com.google.web.bindery.requestfactory.server.RequestFactoryServlet</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>requestFactoryServlet</servlet-name>
  <url-pattern>/gwtRequest</url-pattern>
</servlet-mapping>


On Mon, Sep 12, 2011 at 11:43 AM, Alexander Orlov <alexand...@loxal.net> wrote:
>
> in your case maybe: <url-pattern>/gwtRequest</url-pattern>
>
> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/BuTwBMjVxgQJ.

Thomas Broyer

unread,
Sep 12, 2011, 1:48:57 PM9/12/11
to google-we...@googlegroups.com
You don't need gwt-servlet-deps if you add org.json:json and javax.validation:validation-api (see http://search.maven.org/#artifactdetails%7Ccom.google.gwt%7Cgwt-servlet%7C2.4.0%7Cjar copy/paste the dependenciesand remove the <optional>true</optional>); or you can simply use requestfactory-server instead, which has those dependencies as "non optional": http://search.maven.org/#artifactdetails%7Ccom.google.web.bindery%7Crequestfactory-server%7C2.4.0%7Cjar

See also http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven and http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation#Maven_builds (to be used instead of the requestfactory-apt dependency, depending on how your code is spread among maven modules).

...of course, if the error happens in DevMode (with embedded Jetty server), then it depends how/when you launch the DevMode. See http://code.google.com/eclipse/docs/faq.html#gwt_with_maven (and use the "If you're not able to use Eclipse for Java EE" steps)

Alexander Orlov

unread,
Sep 12, 2011, 5:16:22 PM9/12/11
to google-we...@googlegroups.com
On Monday, September 12, 2011 6:36:45 PM UTC+2, Pavel Byles wrote:
So now I'm getting a 500 error: Problem accessing /gwtRequest

500? You would get Error 404 when / isn't your app context what's mostly the case. My url-pattern is planer/gwtRequest because in my *.gwt.xml I've <module rename-to="planer">. If you're using Maven this would be the absolute minimal configuration to get RF working. 

Thomas Broyer

unread,
Sep 12, 2011, 5:43:12 PM9/12/11
to google-we...@googlegroups.com
The default URL is relative to the "host page base URL", not the module, so it doesn't matter how your module is compiled, only how it's loaded (or rather, where it's loaded from); so /gwtRequest is actually fine in most cases.

As for the 500 status, server logs should tell more about it.

Pavel Byles

unread,
Sep 12, 2011, 11:45:35 PM9/12/11
to google-we...@googlegroups.com
Hi Thomas,
thanks for the link.

Alexander, my host page url is: http://127.0.0.1:8888/ and I also tried ur solution. If I set the url-pattern to something wrong I do get a 404. So I think I'm getting a genuine 500 internal server error.

Console says I need to run the "ValidationTool" for my RequestFactory type.

I then followed http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation, then removed my maven reqeustfactory-server.jar and replaced w/ the stock GWT requestfactory-server.jar and voila!!

Works!!! Awesome!!!! I'm definitely excited about this!!
Thanks all for the help!!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
--
Pav
Reply all
Reply to author
Forward
0 new messages