开发者

GWT 2.2 + JPA problem

开发者 https://www.devze.com 2023-02-20 09:28 出处:网络
I am working with GWT 2.2, JPA, Java EE 6 Web, glassfish v3. My problem is that I receive the following error if I use my entity in an RPC call: \"No source code is available for type entity.User; did

I am working with GWT 2.2, JPA, Java EE 6 Web, glassfish v3. My problem is that I receive the following error if I use my entity in an RPC call: "No source code is available for type entity.User; did you forget to inherit a required module?"

First I tought the problem was the annotation, but then I read that from GWT 2.0 version should be working if "The class is annotated with a JPA javax.persistence.Entity annotation".

So what can be the problem?

Ummm, I think I just write here everything. I have the GWT project with the following packages:

org.ecommunity

org.ecommunity.client (and org.ecommunity.client.view)

org.ecommunity.server -> and here is just a service impl.:

public class ECommunityServiceImpl extends RemoteServiceServlet implements ECommunityService  {
    @EJB
    ECommunitySB bean;

    @Override
    public User loginService(String username) {
        return bean.getUserByUsername(username);
    }
}

My Main.gwt.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module>
    <inherits name="com.google.gwt.user.User"/>
    <inherits name='com.google.gwt.user.theme.standard.Standard'/>
    <entry-point class="org.ecommunity.client.MainEntryPoint"/>
    <source path="client"/>
</module>

And I have an EJB Module with the following packages: entity (in here is my User entity class) and a sessionbean (with my sessionbean)

and if I add the <source path='server' /> the problem is the same with this new one: "The import javax.ejb cannot be resolved. EJB cannot be re开发者_运维百科solved to a type."


You have to delete your EJB Module and put the sessionbean and the entity class into the gwt projet. So now you have only 1 project. And you have to add the EclipseLink (JPA 2.0) library to the classpath (because of the annotations).


I think you might be missing a source path in your {project}.gwt.xml

<source path='yourpath' />

I'll take a guess here lets say your {project}.gwt.xml is located in

 org.ecommunity

There probably is a package

 org.ecommunity.client

With allready some GWT stuff which is what is included by <source path='client' /> but your entity classes are in: org.ecommunity.server.entity So you would have to put in another source for <source path='server' />. BTW it might be better to move the entities out from under server to a for instance org.ecommunity.entity and add <source path='entity' /> because I guess that under server there is a lot of code that is not relevant for the client code.

0

精彩评论

暂无评论...
验证码 换一张
取 消