On Wednesday, May 9, 2012 3:15:29 PM UTC+2, Christien Lomax wrote: > > Hi All, > > We could use a bit of insight and help if anyone has a moment. > > We currently have a project that is quite huge (thousands of classes) > including the GWT client, a spring service layer and > hibernate persistence layer. > > We are trying to split up the project into more manageable pieces > including: > > - client project (contains our GWT widgets, RequestFactories, etc, > Spring servlets) > - service project (contains the spring service layer, web services > (REST, SOAP)) > - persistence project (contains the domain beans - hibernate mapped > objects, persistence code, etc) > - shared project (classes that can be used on both the client (gwt > compiled) and server side. > > Everything compiles and works (unit tests, etc) until we hit GWT's > compile. At this point, we get complaints about GWT not being able to see > items in the service layer (which makes sense, it is trying > to compile references to the beans, services, etc). > We've tried a number of approaches, including using @ServiceName instead > of @Service and using the <source .../> specifications on the modules. > Right now we a few errors we are unable to resolve: > > 1 - we get this one for every Adapte:) > [ERROR] Errors in 'file:/C:/workspace/client/src/main/java/com/ > mycompany/adapter/alert/AlertBeanGwtAdapter.java' > [ERROR] Line 14: No source code is available for type > com.mycompany.service.alerts.IAlertService; did you forget to inherit a > required module? >
You ahve to produce a source JAR for your artifacts, and then reference them as dependencies in your GWT project. See https://github.com/tbroyer/gwt-maven-archetypes/tree/master/modular-requestfactory/src/test/resources/projects/basic-rf/reference for an example (here, the GWT client-side, server-side, and shared code –RequestFactory interfaces– are separated into 3 distinct modules; the client module depends on the shared module's <classifier>sources</classifier> to bring its sources in the GWT compiler classpath. > 2 - if we omit the "-strict" parameter when compiling GWT, we get this: > [ERROR] An internal compiler exception occurred > com.google.gwt.dev.jjs.InternalCompilerException: Failed to get JNode > ... > [ERROR] <no source info>: public interface com.mycompany > .service.alerts.IAlertService > ... > org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding > [ERROR] at AlertBeanGwtAdapter.java(14): private IAlertService > getService() { > return (IAlertService) > EcmLocator.getApplicationContext().getBean(IAlertService.TYPE); > } > org.eclipse.jdt.internal.compiler.ast.MethodDeclaration > > Can anyone shed any light on what we may be doing wrong? When it is all > in one project, everything works fine, but splitting it into multiple > projects (that are references via maven) it fails. > > Example source (some code is omitted): > > *Client Layer:* > > *...client.alerts.request.**IAlertRequest.java* > @ServiceName(value = "com.mycompany.service.alerts.IAlertService.class", > locator = "SpringServiceLocator.class") > Don't include the ".class", it's not part of the name of the class. > public interface IAlertRequest extends RequestContext > { > Request<Long> countAlerts(String eventClass, Date dateLimit); > Request<List<IAlertTypeProxy>> listAlertTypes(); > Request<List<IAlertBeanProxy>> listUnviewedAlerts(); > } > > *...web.**SpringServiceLocator.java** > * > public class SpringServiceLocator implements ServiceLocator > { > public Object getInstance(Class<?> clazz) > { > ApplicationContext context = > WebApplicationContextUtils.getWebApplicationContext(RequestFactoryServlet > .getThreadLocalServletContext()); > return context.getBean(clazz); > } > } > > *OurProject.gwt.xml* > <?xml version="1.0" encoding="UTF-8"?> > <module rename-to='Oris4'> > > <inherits name='com.google.gwt.editor.Editor' /> > <inherits name='com.google.gwt.json.JSON' /> > <inherits name='com.google.gwt.logging.Logging' /> > <inherits name='com.google.gwt.resources.Resources' /> > <inherits name='com.google.web.bindery.requestfactory.RequestFactory' /> > <inherits name='com.google.gwt.user.User' /> > <inherits name="com.google.gwt.i18n.I18N" /> > > <inherits name='com.mycompany.theme.clean.Clean' /> > <inherits name='com.mycompany.Persistence' /> > > <entry-point class='com.mycompany.client.OurEntryPoint' /> > > <set-configuration-property name="UiBinder.useSafeHtmlTemplates" > value="true" /> > This is the default in GWT 2.4 AFAIK (or will it only be starting with 2.5?) > > <source path='client' /> > <source path='web' /> > <source path='adapter' /> > </module> > > *Service Layer:* > > *...services.alerts.**IAlertService.java* > public interface IAlertService > { > String TYPE = "AlertService"; > Long countAlerts(String eventClass, Date dateLimit); > List<AlertType> listAlertTypes(); > List<AlertBean> listUnviewedAlerts(); > } > > *...services.alerts.AlertService.java* > @Service("AlertService") > @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) > public class AlertService extends EcmService implements IAlertService > { > public Long countAlerts(String eventClass, Date dateLimit) {...}; > public List<AlertType> listAlertTypes() {...}; > public List<AlertBean> listUnviewedAlerts() {...}; > } > > *Persistence Layer:* > > *...domain.alerts.AlertBean.java* > @Entity > @Immutable > @Table(name = "alertdisplayview") > public class AlertBean implements Serializable > { > ... > } > > *...domain.alerts.* *AlertType.java* > @Entity > @Immutable > @Cache(usage = CacheConcurrencyStrategy.READ_ONLY) > @Table(name = "alerttype") > @NamedQueries({ > @NamedQuery(name = "alertType.findByName", query = "select alt from > AlertType alt where alt.name =:name or alt.internalName =:name") > }) > public class AlertType implements Serializable > { > ... > } > > *Persistence.gwt.xml* > <?xml version="1.0" encoding="UTF-8"?> > <module rename-to='Persistence'> > <source path="domain" /> > </module> > > -- 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/-/sNUK44gRdq0J. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
