问题
I want to return an instance of a class I created, named User. Where should I put this class, so that my EJB can return it when I call a method? I mean, should I put it only in the interface project, or in the ejb module and in the war module?
Thanks
回答1:
You should have a copy of your custom object in both EJB folder, and in your war project, if you want to use concrete implementation. Nevertheless, you might have an interface in your .war, which EJB module method returns, and EJB nethod call would return a concrete instance of that interface. In this case you refer to concrete implementation by its interface. In case your EJB and war are on different machines, you should make your custom class Serializable
.
回答2:
If you plan to run on JBoss AS 7 or Wildfly you should ensure that such classes do not appear in utility jars (interface jar) AND in a module, ie war or ejb jar. JBoss will throw an error when finding the class file in a library and a module.
So I'd recommend putting it only into the interface jar.
来源:https://stackoverflow.com/questions/23725196/remote-ejb-return-type