简体   繁体   中英

GWT not finding custom classes?

I've been all over the Internet and can't seem to get a straight answer, just looking to clarify something.

I need my web app to return from the server an ArrayList. Por is a custom class that implements Serializable and follows all the rules I've been able to find about being serializable for GWT.

My gwt.xml file (in com.pbot package) has:

<source path='com.pbot'/>

and all my custom classes (including Por) are in that same com.pbot package. But I'm still getting the "No source code is available for type com.pbot.Por; did you forget to inherit a required module?" message. Do I need to make a second gwt.xml with com.pbot as source and import it? If so, how do I do that and where do I put it? If not, what am I missing?

Entire gwt.xml code below:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  When updating your version of GWT, you should also update this DTD reference,
  so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
  "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='pbot'>
  <!-- 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                                      -->

  <!-- Specify the app entry point class.                         -->
<entry-point class='com.pbot.client.Pbot'/>
  <!-- Specify the paths for translatable code                    -->
  <source path='client'/>
  <source path='shared'/>
  <source path='com.pbot'/>

</module>

Add

<source path=''/>

instead of

<source path='com.pbot'/>

But still I think you should put your custom classes into correct packages, so in case of Por into shared package (beacause you're using Por on client side and also on server side). However, I don't know the circumstances (if you can do that) so that's just an advice.

The reason behind that is that with this you are providing your whole package com.pkg to be translated into JavaScript and soon or later you will get into trouble with this attitude. So best thing is - put your custom classes into client or shared package if it's possible and then remove

<source path=''/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM