You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Paul Spencer <pa...@mindspring.com> on 2008/11/18 14:44:11 UTC

How to use annotation in client application?

I have a EJB3 client application that is not getting the the bean via 
annotation. Getting the bean via the initial context works.

***
* Annotation to get the customerBean
***
   @EJB (name="CustomerBeanRemote)
   private CustomerBean customerBean


1) How do I use annotations, like @EJB, in an EJB3 client?

2) Is their Maven configuration other then a dependency on
    openejb-client that is necessary?

Paul Spencer


Re: How to use annotation in client application?

Posted by packpaul <pa...@mail.ru>.
Hi!

As of Aug 2015, TomEE ver. 1.7.2. How does it look like with the possibility
of running application clients? Does TomEE have a utility like 'appclient'?

Dain, following your advise I couldn't successfully lunch my application
with

java -Dopenejb.client.moduleId=ID_FROM_CONTAINER  -jar openejb-client.jar
[args]

No ID_FROM_CONTAINER was shown in the log for my client module, only this:

INFO: Found ClientModule in classpath:
d:\programs\tomcat\7.0.63\apps\cart\cart-appclient.jar



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/How-to-use-annotation-in-client-application-tp980967p4676001.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: How to use annotation in client application?

Posted by Manu George <ma...@gmail.com>.
Sure I have opened https://issues.apache.org/jira/browse/OPENEJB-962
to track this

Regards
Manu

On Tue, Nov 25, 2008 at 9:03 PM, Dain Sundstrom <da...@iq80.com> wrote:
> On Nov 24, 2008, at 11:51 PM, Manu George wrote:
>
>> Hi Dain,
>>
>> Good to know that. I was not aware that a Java EE App Client container
>> existed. Is there any docs on this?
>
> I couldn't find any docs.
>
>> If not maybe we should create some.
>
> If you have time, that would be great.  David wrote the bulk of the
> container, but I played with it a year ago.
>
> -dain
>

Re: How to use annotation in client application?

Posted by Dain Sundstrom <da...@iq80.com>.
On Nov 24, 2008, at 11:51 PM, Manu George wrote:

> Hi Dain,
>
> Good to know that. I was not aware that a Java EE App Client container
> existed. Is there any docs on this?

I couldn't find any docs.

> If not maybe we should create some.

If you have time, that would be great.  David wrote the bulk of the  
container, but I played with it a year ago.

-dain

Re: How to use annotation in client application?

Posted by Manu George <ma...@gmail.com>.
Hi Dain,

Good to know that. I was not aware that a Java EE App Client container
existed. Is there any docs on this? If not maybe we should create
some.

Regards
Manu

On Mon, Nov 24, 2008 at 11:51 PM, Dain Sundstrom <da...@iq80.com> wrote:
> OpenEJB does have a client container, but I fully remember how it works.
>  You need to deploy an app-client as part of your ear.  IIRC when it
> deploys, the container will print the module id for the app-client.  Then
> you run a command like this:
>
> java -Dopenejb.client.moduleId=ID_FROM_CONTAINER  -jar openejb-client.jar
> [args]
>
> or the full version if you need to augment the classpath
>
> java -Dopenejb.client.moduleId=ID_FROM_CONTAINER -cp
> openejb-client.jar:other-jars org.apache.openejb.client.Main [args]
>
> If I were you, I'd just follow example Manu posted as it is easier then
> dealing with a JEE app-client.
>
> -dain
>
>
> On Nov 23, 2008, at 11:31 PM, Manu George wrote:
>
>> Hi Paul,
>>            AFAIK there is no client container in openejb. However
>> you can get DI to work for clients by using the code in the testcases.
>> See the class org.apache.openejb.test.TestClient. It has two methods
>> processFieldInjections and processSetterInjections which scan the
>> classpath for @EJB annotations and inject the values after lookup from
>> JNDI. You can add this code to the main class that runs for yout
>> client and you can get injection to work
>>
>> Regards
>> Manu
>>
>>
>>
>> On Fri, Nov 21, 2008 at 5:58 PM, Manu George <ma...@gmail.com>
>> wrote:
>>>
>>> Hi Paul,
>>>
>>> I am not sure about this. If you look into the iTests it seems to have
>>> something similar in the RemoteiTests. I think some of the remote
>>> clients are using @EJB. If anyone knows how to configure this, please
>>> advise.  Meanwhile let me try to figure out how this works
>>>
>>> Regards
>>> Manu
>>>
>>> On Wed, Nov 19, 2008 at 7:10 PM, Paul Spencer
>>> <pa...@mindspring.com> wrote:
>>>>
>>>> Manu,
>>>> Is their a "client container"?  Or stated another way; how can OpenEJB
>>>> be
>>>> configured to be a container for the client application, but services
>>>> like
>>>> bean declaration and authentication services be done by a remote
>>>> container?
>>>>
>>>> Paul Spencer
>>>>
>>>> Manu George wrote:
>>>>>
>>>>> Hi Paul,
>>>>>
>>>>> If it is a standalone client application with its own main method, it
>>>>> runs outside the container.So you cannot get beans injected and you
>>>>> will need to always look them up via remote JNDI lookup
>>>>>
>>>>> Regards
>>>>> Manu
>>>>>
>>>>> On Tue, Nov 18, 2008 at 7:14 PM, Paul Spencer
>>>>> <pa...@mindspring.com> wrote:
>>>>>>
>>>>>> I have a EJB3 client application that is not getting the the bean via
>>>>>> annotation. Getting the bean via the initial context works.
>>>>>>
>>>>>> ***
>>>>>> * Annotation to get the customerBean
>>>>>> ***
>>>>>> @EJB (name="CustomerBeanRemote)
>>>>>> private CustomerBean customerBean
>>>>>>
>>>>>>
>>>>>> 1) How do I use annotations, like @EJB, in an EJB3 client?
>>>>>>
>>>>>> 2) Is their Maven configuration other then a dependency on
>>>>>> openejb-client that is necessary?
>>>>>>
>>>>>> Paul Spencer
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>
>

Re: How to use annotation in client application?

Posted by Dain Sundstrom <da...@iq80.com>.
OpenEJB does have a client container, but I fully remember how it  
works.  You need to deploy an app-client as part of your ear.  IIRC  
when it deploys, the container will print the module id for the app- 
client.  Then you run a command like this:

java -Dopenejb.client.moduleId=ID_FROM_CONTAINER  -jar openejb- 
client.jar [args]

or the full version if you need to augment the classpath

java -Dopenejb.client.moduleId=ID_FROM_CONTAINER -cp openejb- 
client.jar:other-jars org.apache.openejb.client.Main [args]

If I were you, I'd just follow example Manu posted as it is easier  
then dealing with a JEE app-client.

-dain


On Nov 23, 2008, at 11:31 PM, Manu George wrote:

> Hi Paul,
>             AFAIK there is no client container in openejb. However
> you can get DI to work for clients by using the code in the testcases.
> See the class org.apache.openejb.test.TestClient. It has two methods
> processFieldInjections and processSetterInjections which scan the
> classpath for @EJB annotations and inject the values after lookup from
> JNDI. You can add this code to the main class that runs for yout
> client and you can get injection to work
>
> Regards
> Manu
>
>
>
> On Fri, Nov 21, 2008 at 5:58 PM, Manu George  
> <ma...@gmail.com> wrote:
>> Hi Paul,
>>
>> I am not sure about this. If you look into the iTests it seems to  
>> have
>> something similar in the RemoteiTests. I think some of the remote
>> clients are using @EJB. If anyone knows how to configure this, please
>> advise.  Meanwhile let me try to figure out how this works
>>
>> Regards
>> Manu
>>
>> On Wed, Nov 19, 2008 at 7:10 PM, Paul Spencer
>> <pa...@mindspring.com> wrote:
>>> Manu,
>>> Is their a "client container"?  Or stated another way; how can  
>>> OpenEJB be
>>> configured to be a container for the client application, but  
>>> services like
>>> bean declaration and authentication services be done by a remote  
>>> container?
>>>
>>> Paul Spencer
>>>
>>> Manu George wrote:
>>>>
>>>> Hi Paul,
>>>>
>>>> If it is a standalone client application with its own main  
>>>> method, it
>>>> runs outside the container.So you cannot get beans injected and you
>>>> will need to always look them up via remote JNDI lookup
>>>>
>>>> Regards
>>>> Manu
>>>>
>>>> On Tue, Nov 18, 2008 at 7:14 PM, Paul Spencer
>>>> <pa...@mindspring.com> wrote:
>>>>>
>>>>> I have a EJB3 client application that is not getting the the  
>>>>> bean via
>>>>> annotation. Getting the bean via the initial context works.
>>>>>
>>>>> ***
>>>>> * Annotation to get the customerBean
>>>>> ***
>>>>> @EJB (name="CustomerBeanRemote)
>>>>> private CustomerBean customerBean
>>>>>
>>>>>
>>>>> 1) How do I use annotations, like @EJB, in an EJB3 client?
>>>>>
>>>>> 2) Is their Maven configuration other then a dependency on
>>>>> openejb-client that is necessary?
>>>>>
>>>>> Paul Spencer
>>>>>
>>>>>
>>>>
>>>
>>>
>>


Re: How to use annotation in client application?

Posted by Manu George <ma...@gmail.com>.
Hi Paul,
             AFAIK there is no client container in openejb. However
you can get DI to work for clients by using the code in the testcases.
See the class org.apache.openejb.test.TestClient. It has two methods
processFieldInjections and processSetterInjections which scan the
classpath for @EJB annotations and inject the values after lookup from
JNDI. You can add this code to the main class that runs for yout
client and you can get injection to work

Regards
Manu



On Fri, Nov 21, 2008 at 5:58 PM, Manu George <ma...@gmail.com> wrote:
> Hi Paul,
>
> I am not sure about this. If you look into the iTests it seems to have
> something similar in the RemoteiTests. I think some of the remote
> clients are using @EJB. If anyone knows how to configure this, please
> advise.  Meanwhile let me try to figure out how this works
>
> Regards
> Manu
>
> On Wed, Nov 19, 2008 at 7:10 PM, Paul Spencer
> <pa...@mindspring.com> wrote:
>> Manu,
>> Is their a "client container"?  Or stated another way; how can OpenEJB be
>> configured to be a container for the client application, but services like
>> bean declaration and authentication services be done by a remote container?
>>
>> Paul Spencer
>>
>> Manu George wrote:
>>>
>>> Hi Paul,
>>>
>>> If it is a standalone client application with its own main method, it
>>> runs outside the container.So you cannot get beans injected and you
>>> will need to always look them up via remote JNDI lookup
>>>
>>> Regards
>>> Manu
>>>
>>> On Tue, Nov 18, 2008 at 7:14 PM, Paul Spencer
>>> <pa...@mindspring.com> wrote:
>>>>
>>>> I have a EJB3 client application that is not getting the the bean via
>>>> annotation. Getting the bean via the initial context works.
>>>>
>>>> ***
>>>> * Annotation to get the customerBean
>>>> ***
>>>>  @EJB (name="CustomerBeanRemote)
>>>>  private CustomerBean customerBean
>>>>
>>>>
>>>> 1) How do I use annotations, like @EJB, in an EJB3 client?
>>>>
>>>> 2) Is their Maven configuration other then a dependency on
>>>>  openejb-client that is necessary?
>>>>
>>>> Paul Spencer
>>>>
>>>>
>>>
>>
>>
>

Re: How to use annotation in client application?

Posted by Manu George <ma...@gmail.com>.
Hi Paul,

I am not sure about this. If you look into the iTests it seems to have
something similar in the RemoteiTests. I think some of the remote
clients are using @EJB. If anyone knows how to configure this, please
advise.  Meanwhile let me try to figure out how this works

Regards
Manu

On Wed, Nov 19, 2008 at 7:10 PM, Paul Spencer
<pa...@mindspring.com> wrote:
> Manu,
> Is their a "client container"?  Or stated another way; how can OpenEJB be
> configured to be a container for the client application, but services like
> bean declaration and authentication services be done by a remote container?
>
> Paul Spencer
>
> Manu George wrote:
>>
>> Hi Paul,
>>
>> If it is a standalone client application with its own main method, it
>> runs outside the container.So you cannot get beans injected and you
>> will need to always look them up via remote JNDI lookup
>>
>> Regards
>> Manu
>>
>> On Tue, Nov 18, 2008 at 7:14 PM, Paul Spencer
>> <pa...@mindspring.com> wrote:
>>>
>>> I have a EJB3 client application that is not getting the the bean via
>>> annotation. Getting the bean via the initial context works.
>>>
>>> ***
>>> * Annotation to get the customerBean
>>> ***
>>>  @EJB (name="CustomerBeanRemote)
>>>  private CustomerBean customerBean
>>>
>>>
>>> 1) How do I use annotations, like @EJB, in an EJB3 client?
>>>
>>> 2) Is their Maven configuration other then a dependency on
>>>  openejb-client that is necessary?
>>>
>>> Paul Spencer
>>>
>>>
>>
>
>

Re: How to use annotation in client application?

Posted by Paul Spencer <pa...@mindspring.com>.
Manu,
Is their a "client container"?  Or stated another way; how can OpenEJB 
be configured to be a container for the client application, but services 
like bean declaration and authentication services be done by a remote 
container?

Paul Spencer

Manu George wrote:
> Hi Paul,
> 
> If it is a standalone client application with its own main method, it
> runs outside the container.So you cannot get beans injected and you
> will need to always look them up via remote JNDI lookup
> 
> Regards
> Manu
> 
> On Tue, Nov 18, 2008 at 7:14 PM, Paul Spencer
> <pa...@mindspring.com> wrote:
>> I have a EJB3 client application that is not getting the the bean via
>> annotation. Getting the bean via the initial context works.
>>
>> ***
>> * Annotation to get the customerBean
>> ***
>>  @EJB (name="CustomerBeanRemote)
>>  private CustomerBean customerBean
>>
>>
>> 1) How do I use annotations, like @EJB, in an EJB3 client?
>>
>> 2) Is their Maven configuration other then a dependency on
>>   openejb-client that is necessary?
>>
>> Paul Spencer
>>
>>
> 


Re: How to use annotation in client application?

Posted by Manu George <ma...@gmail.com>.
Hi Paul,

If it is a standalone client application with its own main method, it
runs outside the container.So you cannot get beans injected and you
will need to always look them up via remote JNDI lookup

Regards
Manu

On Tue, Nov 18, 2008 at 7:14 PM, Paul Spencer
<pa...@mindspring.com> wrote:
> I have a EJB3 client application that is not getting the the bean via
> annotation. Getting the bean via the initial context works.
>
> ***
> * Annotation to get the customerBean
> ***
>  @EJB (name="CustomerBeanRemote)
>  private CustomerBean customerBean
>
>
> 1) How do I use annotations, like @EJB, in an EJB3 client?
>
> 2) Is their Maven configuration other then a dependency on
>   openejb-client that is necessary?
>
> Paul Spencer
>
>