For the record.
After successive failures to perform any configuration of @Stateless
beans I resorted to the following solution.
Declare a @Singleton bean that contains the configuration information.
Declare a @WebListener implementing ServletContextListener that
looks up configuration information from the Servlet Context and sets
the contents of the @Singleton at initialisation. This approach allows
for command-line tool configuration, and allows for multiple instances
of the same application to have different configuration sets.
Definitely NOT elegant, but *works*, and that trumps everything else.
Using JNDI to configure entities works, but I found no way to set up
two instances of the same application with different settings. This is
a no-go.
Using set-web-env-entry seems to work for web components only, it
seems these are not injected into @Stateless.
2014-09-11 17:44 GMT+03:00 Reza Rahman <reza.rahman_at_oracle.com>:
> Please check the forum archives. This is something that has been discussed very recently.
>
> Sent from my iPhone
>
>> On Sep 11, 2014, at 10:19 AM, Lachezar Dobrev <l.dobrev_at_gmail.com> wrote:
>>
>> Hello,
>> I'm struggling with elementary stuff here.
>>
>> I have a WAR packaged application with @Stateless inside.
>> I am trying to make them configurable when the application is
>> installed in a Glassfish server.
>>
>>
>> package com.company;
>>
>> @Stateless
>> public class ServiceEJB implements Service {
>> @Resource
>> private String link;
>>
>> @Override
>> public void sendHelloWorld() {
>> // Hit the remote service
>> new URL(link).openStream().close();
>> }
>> }
>>
>>
>> The EJB is called by a servlet.
>>
>> I am unable to configure the link field.
>> Tried:
>> asadmin set-web-env-entry ... link
>> asadmin set-web-env-entry ... com.company.ServiceEJB/link
>> asadmin create-custom-resource ... link
>> asadmin create-custom-resource ... com.company.ServiceEJB/link
>>
>> None of these seem to have any effect on the situation.
>>
>> Please advise.