Recap: the
2014-07-22 15:11 GMT+03:00 Reza Rahman <reza.rahman_at_oracle.com>:
> Let's kindly start from a working baseline before getting into a discussion of what should and should not be.
>
> Did my suggested changes work?
>
> Sent from my iPhone
>
>> On Jul 22, 2014, at 5:37 AM, Lachezar Dobrev <l.dobrev_at_gmail.com> wrote:
>>
>> 1. Yes, env-entry-value is not filled.
>> These are configuration parameters, and I do not know what values
>> they will be assigned at deployment time. Hence the env-entry-value is
>> missing, and I *expect* them to be filled on deployment using whatever
>> means the server has. Manually *fixing* the web.xml descriptor in an
>> already packaged (and possibly cryptographically signed) WAR file is
>> not my idea of server deployment tools.
>>
>> 2. Do I *need* to omit the java:comp/env, or I *can* omit the prefix?
>> With other J2EE servers I was only able to get it running using the
>> full java:comp/env/config/user location.
>>
>>
>> I find it hard to believe, that deploying and configuring an
>> application would require:
>> a) Hard-coding values by the developer.
>> b) Manually editing packaged files by hand.
>>
>> Am I missing something? Am I supposed to recompile/repackage the WAR
>> for every instance? Because I can't find a way for this to work
>> otherwise. I thought I am to provide a WAR file with declared
>> references to configuration parameters, that are configured/linked
>> when deploying to the server.
>>
>>
>> After hard-coding some values for the configuration attributes in
>> web.xml and attempting to deploy the application I got:
>>
>>> An error has occurred
>>> Error occurred during deployment: null. Please see server.log for more details.
>>
>> And the server.log has:
>>> [2014-07-22T12:28:03.320+0300] [glassfish 4.0] [INFO] [] [org.glassfish.admingui] [tid: _ThreadID=122 _ThreadName=admin-listener(9)] [timeMillis: 1406021283320] [levelValue: 800] [[
>>> Exception Occurred :Error occurred during deployment: null. Please see server.log for more details.]]
>>
>> Which is unhelpful to say the least. I suspect a NPE occurs
>> somewhere on the server, but the exception is
>> masked/wrapped/ignored/printed and the actual cause eludes me.
>>
>> The same thing happens if I try to deploy the application without
>> starting it: I get an error message 'null', and then trying to deploy
>> the application again yields:
>>
>>> An error has occurred
>>> Error occurred during deployment: Application name DemoApplication is already in use. Please pick a different name.. Please see server.log for more details.
>>
>>
>> 2014-07-21 21:25 GMT+03:00 Reza Rahman <reza.rahman_at_oracle.com>:
>>> You seem to have two problems:
>>>
>>> * env-entry-value is undefined.
>>> * You simply need @Resource(name = "config/user")
>>>
>>>
>>>> On 7/21/2014 11:53 AM, Lachezar Dobrev wrote:
>>>>
>>>> Hello all.
>>>> I'm having trouble using environment entries to configure an
>>>> application on deployment in Glassfish.
>>>>
>>>> web.xml:
>>>>
>>>> <web-app ...>
>>>> <env-entry>
>>>> <env-entry-name>config/user</env-entry-name>
>>>> <env-entry-type>java.lang.String</env-entry-type>
>>>> </env-entry>
>>>> </web-app>
>>>>
>>>>
>>>> ServiceProducer.java:
>>>>
>>>> @ApplicationScoped
>>>> public class ServiceProducer {
>>>> @Produces
>>>> @Default
>>>> public Service get() {
>>>> return new ServiceImpl(user);
>>>> }
>>>>
>>>> private String user;
>>>> @Resource(name = "java:comp/env/config/user")
>>>> public void setUser(String user) {
>>>> this.user = user;
>>>> }
>>>> }
>>>>
>>>> With "GlassFish Server Open Source Edition 4.0 (build 89)" the
>>>> ServiceProducer.get() is called before setUser() is called.
>>>>
>>>> I'm at a loss here: How can I configure the application?
>>>>
>>>> I have added a config/user JNDI Custom Resource:
>>>> Resource Type: java.lang.String
>>>> Factory Class:
>>>> org.glassfish.resources.custom.factory.PrimitivesAndStringFactory
>>>> Status : Enabled (checked)
>>>> Properties:
>>>> name = "value", value = "ConfiguredUserName"
>>>>
>>>> Please advise! I'm getting seriously frustrated with this.
>>>
>>>