Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7195325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:33:23+00:00 2026-05-28T20:33:23+00:00

This doesn’t seem to work (=null): @Resource(name = java:app/AppName) private String appName; But a

  • 0

This doesn’t seem to work (=null):

@Resource(name = "java:app/AppName")
private String appName;

But a lookup of the same name does:

appName = (String) new javax.naming.InitialContext().lookup("java:app/AppName");

I found many examples having a lookup property in @Resource instead of name. However, I can’t find anything about that, I’m quite confident it should be name, the former isn’t part of the spec.

FYI, I’m using Glassfish 3.1 and I’m accessing appName from a @PostConstruct method in a singleton bean.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:33:25+00:00Added an answer on May 28, 2026 at 8:33 pm

    The use of “lookup” instead of “name” in this case is correct, as the entry is already defined in the java:app namespace and is merely being looked up, rather than defined. This is part of the Java EE 6 specification (which Glassfish 3.1 implements): @Resource#lookup().

    Alternative to looking up the app name using InitialContext, you can also use the @Resource annotation using the lookup attribute:

    @Resource(lookup = "java:app/AppName")
    private String appName;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This doesn't seem to work in jqTouch or iUI. But I know it's possible
This doesn't seem to work: NSString *string = [[NSString alloc] init]; string = @%@M,
This doesn't seem to work: <property name=foo value=\n bar \n/> I use the property
This doesn't have to be Java, but it's what I'm dealing with. Also, not
This doesn't seem to work as I intend. VB.NET: Dim x = Model.Discussions.OrderByDescending(Function(d) d.Messages.OrderByDescending(Function(m)
This doesn't seem to work (compiler complains that Something 's getFoo() method doesn't implement
This doesn't seem to work. Is it possible? public interface IInterface1 {} public interface
This doesn't seem to work in django 1.1 (I believe this will require a
This doesn't work, Runtime.getRuntime().exec(stat /*); nor this; Runtime.getRuntime().exec(new String[] {stat, /*}) Is there any
This doesn't seem like it should be difficult, but I'm stuck currently. I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.