cancel
Showing results for 
Search instead for 
Did you mean: 

Overloaded ejbCreate() method

Former Member
0 Kudos

Hi.

Is it possible to overload ejbCreate method?

I've tried it and deployment of my project

finished with error saying that an application is

incorrect - home interface should have only one method

create with no arguments.

Has anyone tried to create overloaded jebCreate method?

Regards,

Grzegorz.

Message was edited by: Grzegorz Slowik

Accepted Solutions (0)

Answers (1)

Answers (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Grzegorz,

you are speaking of what kind of EJB's?!

For SessionBeans, it is allowed to have more than one ejbCreate methods. Creating an instance works this way:

- container calls <i>newInstance</i>

- container calls <i>setSessionContext</i>

- container calls <i>ejbCreate</i> "whose signature matches the signature of the <i>create<METHOD></i> method invoked by the client". "Each session bean class must have <i>at least</i> one ejbCreate<METHOD> method. The number and signatures of a session bean's create<METHOD> methods are specific to each session bean class."(Quoted from EJB 2.0 spec.)

Almost the same holds for entity beans: "There are zero or more ejbCreate<METHOD>(...) methods, whose signatures match the signatures of the create<METHOD>(...) methods of the entity bean's home interface. The container invokes an ejbCreate<METHOD>(...) method on an entity bean instance when a client invokes a matching create<METHOD>(...) method on the bean's home interface.

Only for message-driven ejb's the contrary holds: "Each message-driven bean class must have one ejbCreate method, with no arguments."

Hope it helps <i>and</i> that the answer shows how useful a spec can be...

Detlev

PS: You also forgot to mention on what J2EE Engine / EJB API you are working; you should have this in mind when choosing the right spec to look for such questions.

Former Member
0 Kudos

Hi Detlev.

Thank you for your response. It was helpful.

In the meantime I took a look into EJB2.0 spec.

And now evrything is clear. My problem arised

because I tried to overload create method for

stateless session bean ( which is against EJB spec. ).

Stateless bean can have one and only one create method

(without parameters).

BTW. I use WAS6.40 and Developer Studio

Thanks and regards,

Grzegorz.

Former Member
0 Kudos

Hmmm.... now I've tried to overload create() method of the stateful bean and I failed.

I've added a few parameters to the ejbCreate() method and I've also changed home interface - create() method with the same set of the parameters.

I can compile my project but during deployment I receive an error saying: "Incorrect application...... can not find ejbCreate() in bean class".

Can anyone give me any hint?

Regs,

Grzegorz

detlev_beutner
Active Contributor
0 Kudos

Hi Grzegorz,

first, sorry for almost leading you on the wrong track with my undifferentiated answer concerning Session Beans (but: the spec is really horrible on this, look at 7.5.5, where on Sun site the differentiation is missing).

Next, for your new problem, as I read it, you did no <i>overload</i> the create method but simply <i>changed</i> it's signature?!

Nevertheless, this should be ok?! But, as a workaround, you could really implement an overloaded <i>ejbCreate</i>, that means implement both, parameterless and with parameters, methods. At least ejbCreate() then should be found...?!

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev.

This is exactly what I did. I left ejbCreate() and

created additional ejbCreateJCO(parameters) and it works.

Anyway in order to EJB2.0 spec there should be

possibility to use ejbCretae() with parameters.

From the other hand I've just learned that this is

a must to have ejbCreate() with no parameters;

what is not exactly what EJB2.0 spec says.

Regs,

Grzegorz

detlev_beutner
Active Contributor
0 Kudos

Hi Grzegorz,

> I've just learned that this is

> a must to have ejbCreate() with no parameters;

> what is not exactly what EJB2.0 spec says.

I would call it the opposite of what EJB 2.0 spec says...

If you have the time, try implementing this on the J2EE reference implementation of SUN. It's the reference... If it works, it's a violation of the spec by SAP. If it works not, open a documentation bug message at SUN, if it not already has been done (search the bug database).

Hope it helps

Detlev

Former Member
0 Kudos

Hi.

We can finish this topic. Everything is fine.

This was my mistake (shame on me). We can add parameters

to the ejbCreate() method. What I did wrong? I had

generated both interfaces local and remote but

unfortunately I've changed signature of the create

method only in one of them. That was my mistake.

So, Detlev, seems that's everything is OK with SAP WAS.

Best regards,

Grzegorz.

PS.

Hope someone will learn on my mistake.