Calling an EJB from swing application

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Calling an EJB from swing application

Kostas Karadamoglou
Hi all, I am new to EJBs. I am trying to create my first with Netbeans.

I have implement a simple EJB but I dont know how to call it from my
client code.

The client is a simple swing application.

I didn't find any wizard or command in Netbeans that helps at that.

Which is the way to call an EJB from the client? What do I have to do?

Thank you in advance, Kostas

Reply | Threaded
Open this post in threaded view
|

Re: Calling an EJB from swing application

Petr Blaha
Hi,
NetBeans doesn't support EJB in J2SE projects. It means you can't invoke
   'Call EJB' action in J2SE application.

Good tutorial about EJB clients is here:
http://docs.sun.com/source/817-6087/dgacc.html#wp1022105

Here is simple EJB client:

1) lookup your bean (bean should be created wirth remote interface)

InitialContext ctx = new InitialContext();  // initial context
             Object objRef = ctx.lookup("ejb/MathBasicBean");
             mathBasic =
((MathBasicRemoteHome)PortableRemoteObject.narrow(objRef,
MathBasicRemoteHome.class)).create();

here you can invoke your business methods

2) add j2ee.jar and appserv-rt.jar to project classpath. appserv-rt.jar
is located in $SUN_APPSERV/lib directory.

Petr

Kostas Karadamoglou wrote:

> Hi all, I am new to EJBs. I am trying to create my first with Netbeans.
>
> I have implement a simple EJB but I dont know how to call it from my
> client code.
>
> The client is a simple swing application.
>
> I didn't find any wizard or command in Netbeans that helps at that.
>
> Which is the way to call an EJB from the client? What do I have to do?
>
> Thank you in advance, Kostas
>
Reply | Threaded
Open this post in threaded view
|

Re: Calling an EJB from swing application

Kostas Karadamoglou
Hi Petr

I just have 2 questions:

1) Do I have to add to the client project the Remote and RemoteHome classes?
2) Is the client code locked in a specific application server (by using
appserv-rt.jar)?

thank you in advance, Kostas

Petr Blaha wrote:

> Hi,
> NetBeans doesn't support EJB in J2SE projects. It means you can't invoke
>   'Call EJB' action in J2SE application.
>
> Good tutorial about EJB clients is here:
> http://docs.sun.com/source/817-6087/dgacc.html#wp1022105
>
> Here is simple EJB client:
>
> 1) lookup your bean (bean should be created wirth remote interface)
>
> InitialContext ctx = new InitialContext();  // initial context
>             Object objRef = ctx.lookup("ejb/MathBasicBean");
>             mathBasic =
> ((MathBasicRemoteHome)PortableRemoteObject.narrow(objRef,
> MathBasicRemoteHome.class)).create();
>
> here you can invoke your business methods
>
> 2) add j2ee.jar and appserv-rt.jar to project classpath. appserv-rt.jar
> is located in $SUN_APPSERV/lib directory.
>
> Petr
>
> Kostas Karadamoglou wrote:
>
>> Hi all, I am new to EJBs. I am trying to create my first with Netbeans.
>>
>> I have implement a simple EJB but I dont know how to call it from my
>> client code.
>>
>> The client is a simple swing application.
>>
>> I didn't find any wizard or command in Netbeans that helps at that.
>>
>> Which is the way to call an EJB from the client? What do I have to do?
>>
>> Thank you in advance, Kostas
>>
>

Reply | Threaded
Open this post in threaded view
|

Why can't I run my Applet?

jhodgski
I have created a very simple JApplet. I've checked the properties for the
class which confirms it 'Is Applet'.

But when in the 'Files' tab, I right-click on the class file but there is no
'Run' option in the contextual menu. I've tried right-clicking on
everything, but no Run option appears.

Can anyone help? Could there be something missing from my installation?

Cheers,
James


Reply | Threaded
Open this post in threaded view
|

Re: Why can't I run my Applet?

Gregg Sporar

James -

I don't think that will work from the 'Files' tab.  I'm pretty sure you
have to be in the 'Projects' tab in order to get the 'Run' option in the
context menu.  FYI, in case you haven't seen it, this tutorial has more
info.: http://www.netbeans.org/kb/41/tutorial-applets.html

- Gregg

James Hodgskiss wrote:

> I have created a very simple JApplet. I've checked the properties for
> the class which confirms it 'Is Applet'.
>
> But when in the 'Files' tab, I right-click on the class file but there
> is no 'Run' option in the contextual menu. I've tried right-clicking
> on everything, but no Run option appears.
>
> Can anyone help? Could there be something missing from my installation?
>
> Cheers,
> James
>

Reply | Threaded
Open this post in threaded view
|

Re: Re: Calling an EJB from swing application

Petr Blaha
In reply to this post by Kostas Karadamoglou
Hi,
my answers are inline.

Petr

Kostas Karadamoglou wrote:
> Hi Petr
>
> I just have 2 questions:
>
> 1) Do I have to add to the client project the Remote and RemoteHome
> classes?

   Yes, you should add these interfaces (Remote, RemoteHome and
RemoteBusiness) to client's classpath

> 2) Is the client code locked in a specific application server (by using
> appserv-rt.jar)?

   This jar is valid only for App server. For instance, when you develop
apps for JBoss you should add to classpath jboss-client.jar.


>
> thank you in advance, Kostas
>
> Petr Blaha wrote:
>
>> Hi,
>> NetBeans doesn't support EJB in J2SE projects. It means you can't
>> invoke   'Call EJB' action in J2SE application.
>>
>> Good tutorial about EJB clients is here:
>> http://docs.sun.com/source/817-6087/dgacc.html#wp1022105
>>
>> Here is simple EJB client:
>>
>> 1) lookup your bean (bean should be created wirth remote interface)
>>
>> InitialContext ctx = new InitialContext();  // initial context
>>             Object objRef = ctx.lookup("ejb/MathBasicBean");
>>             mathBasic =
>> ((MathBasicRemoteHome)PortableRemoteObject.narrow(objRef,
>> MathBasicRemoteHome.class)).create();
>>
>> here you can invoke your business methods
>>
>> 2) add j2ee.jar and appserv-rt.jar to project classpath.
>> appserv-rt.jar is located in $SUN_APPSERV/lib directory.
>>
>> Petr
>>
>> Kostas Karadamoglou wrote:
>>
>>> Hi all, I am new to EJBs. I am trying to create my first with Netbeans.
>>>
>>> I have implement a simple EJB but I dont know how to call it from my
>>> client code.
>>>
>>> The client is a simple swing application.
>>>
>>> I didn't find any wizard or command in Netbeans that helps at that.
>>>
>>> Which is the way to call an EJB from the client? What do I have to do?
>>>
>>> Thank you in advance, Kostas
>>>
>>
>