EJB 3 Stable Generation

I have an ejb-3 compatible ejb let's say

@Remote interface Hai{ String sayHai(); } Stateless(name = "xxx", mappedname="yyy") public class HaiImpl implements Hai{ public String sayHai(){ return "Hai"; } } 

And I need to create a stub for this EJB. but I do not want to use the websphere tool or the maven tool. Is there a way to generate a stub using jdk?

When creating a remote client

  Hai hai = (Hai)ctx.lookup("yyy#com.zz.Hai"); System.out.println(hai.sayHai()); 

will work in weblogic or jboss, but in websphere, even this is ejb 3, you need to write like this

 Object o = ctx.lookup("yyy"); Hai hai = (Hai)javax.rmi.PortableRemoteObject.narrow(o,Hai.class); System.out.println(hai.sayHai()); 

In this case, if the stub is not presented on the client, it will throw an exception, there is a way to generate a stub using the websphere ejb stub generatorater tool. But I do not want to use any platform-specific tools.

+6
source share
2 answers

No, you should use WAS_HOME / bin / createEJBStubs. The rmic command included in the Java SDK, which is commonly used to create stubs, cannot be used on "clean" EJB 3 remote interfaces that do not extend java.rmi.Remote.

Please note: if you use the application client container (WAS_HOME / bin / launchClient), or your β€œclient” is a different server, you do not need to create stubs: the container will generate one for you. You need to use createEJBStubs if you are using unmanaged thinclient.

+4
source

I created the maven-plugin shell for the createEJBStub script.

Why?

This allows us to create maven test projects that run as part of our CI installation against our application after deployment.

More specifically, together with maven, this allows our test project:

  • Use Maven's dependency management to pull out the jar of APIs that we publish in our internal link store.
  • Create Stub Classes as Part of the Life Cycle of maven Generator Generators
  • Run a junit test case with an application server with EJB to conduct integration testing.
0
source

Source: https://habr.com/ru/post/921291/


All Articles