users@glassfish.java.net

How to set up for String _at_Resource

From: <glassfish_at_javadesktop.org>
Date: Tue, 16 Dec 2008 12:13:01 PST

I'm using the @Resource annotation for the first time, as a test, and I'm having a problem setting things up in GlassFish.

As a simple test my servlet has this:

@Resource public String myTestValue;

The web.xml is set like this:

<web-app version="2.5" metadata-complete="false">

The way I understand it, that should be enough; the container should inject the value when the application is deployed.

The problem comes in trying to set the value up in the server. On the Resources>JNDI>Custom Resources>New page, I tried to set up the value by setting JNDI Name="myTestValue", Resource Type = "java.lang.String"; however it insists on a Factory class and I have no idea what that should be set to and how I set my specific value. This makes me suspect that the Resources page is not the place for this - on other applications we've used an Environment tag in (I think) the META-INF/context.xml but I can't find an Environment section in the GlassFish configuration, only the Resources section.

I'm obviously missing something here and could use some advice. How do I set up the system so that configuration-specific values get injected using the @Resource annotations?
[Message sent by forum member 'peterjford' (peterjford)]

http://forums.java.net/jive/thread.jspa?messageID=321966