@Resource and env-entry

I used the JSF2 GuessNumber example as the basis for my project. I'm running a simple JSF2 application (my first, although I'm very familiar with JSF1) on Tomcat 7.0.16.
I have the following bean:
@ManagedBean
@SessionScoped
public class ConfigBean {
     @Resource
     private String dataDirectory;
     public String getDataDirectory() {
          return dataDirectory;
     public void setDataDirectory(String dataDirectory) {
          this.dataDirectory = dataDirectory;
}I want to access the data directory property in a .xhtml file as follows:
#{configBean.dataDirectory}To populate the property, I have the following in web.xml:
<env-entry>
  <env-entry-name>dataDirectory</env-entry-name>
  <env-entry-type>java.lang.String</env-entry-type>
  <env-entry-value>D:\Users\kdean\projects\DemoJSF2\data</env-entry-value>
</env-entry>I put a breakpoint in getDataDirectory() to confirm that it's being called (it is) but the value is always null.
What am I missing? Thanks.

Hi,
JDeveloper 10.1.3 is using JEE 1.4, not JEE 1.5. JDeveloper 11 would be the build to use and I am currently testing if it works in here
Frank

Similar Messages

  • Env-entry from web.xml not in generated plan.xml

    Hello,
    Recently I migrated a JDeveloper 10.1.3.4 project to 11.1.1.3 and from there to 11.1.2.4. When I deploy this project to an 10.3.5. weblogic server then the 'env-entry' entires in the web.xml are not available on the application server.
    Even when i use weblogic.PlanGenerator with the -all option to create a plan.xml from the WAR-file the env-enties are not found.
    The web.xml is like this:
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <listener>
    <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>jaxrpc</servlet-name>
    <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
    <servlet-name>VersionServlet</servlet-name>
    <servlet-class>nl.deltalloyd.alfa.keten.version.VersionServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>VersionServlet</servlet-name>
    <url-pattern>/version</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>jaxrpc</servlet-name>
    <url-pattern>/RelatieSoapHttpPort</url-pattern>
    </servlet-mapping>
    <jsp-config/>
    <security-role>
    <role-name>Administrators</role-name>
    </security-role>
    <resource-ref>
    <res-ref-name>jdbc/AlfaDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    <env-entry>
    <env-entry-name>appl/version</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>2013.06</env-entry-value>
    </env-entry>
    <env-entry>
    <env-entry-name>appl/releasedate</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>13-06-2013</env-entry-value>
    </env-entry>
    <env-entry>
    <env-entry-name>appl/loglevel</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>INFO</env-entry-value>
    </env-entry>
    <env-entry>
    <env-entry-name>appl/omgeving</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>
    <env-entry>
    <env-entry-name>service/case</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>http://test.services.intranet.company.nl/GixoCaseWeb/services/CaseServiceHttp</env-entry-value>
    </env-entry>
    <env-entry>
    <env-entry-name>mqueue/rc/host</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>nl001wwavm058.ad.intra</env-entry-value>
    </env-entry>
    <env-entry>
    <env-entry-name>mqueue/rc/port</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>1414</env-entry-value>
    </env-entry>
    </web-app>
    Maybe I missed something in the migration path. Can someone please help me.
    With kind regard,
    Martin

    Let me describe my case in few more words...
    I have some kind of client-server app. Clients have OC4J installed and they download myApp.ear and myApp_plan.dat files and by using script (Windows CMD batch file) clients install those files with admin_client.jar, OC4J's admin utility. The problem is that I have 2 different types of clients and I have client specific settings set in web.xml file and each time I compile myApp.ear I have to uncomment/comment some lines in web.xml.
    So, to make a long story short, I need a way to deploy those settings separated from (outside of) myApp.ear. By following you link, I have read that orion-web.xml should reside inside WEB-INF folder of myApp.ear, which is not good for me.

  • env-entry and InitialContext

    Hi
    I have put a String value, named "myval" into my web.xml file using
    <env-entry> tags. In my code I use the following:
    // assume this gets with default values...
    InitialContext ctxt = new InitialContext();
    String myval = (String) ctxt.lookup("java:comp/env/myval");
    and that usually extracts myval with no problems if I do it within a Web
    context, i.e. from a JSP or a class referenced initially from a JSP.
    However, it fails to extract myval when I do it within an EJB context, i.e.
    call from an EJB.
    Also, new InitialContext() sometimes goes into an infinite loop.
    So, I have two problems, can anyone clarify them?
    1. At random (not repeatable) the new InitialContext() call goes into an
    infinite loop. The WebLogic debug file just shows it looping and looping
    indefinitely, ending with a "Problematic thread" error!!! This is from a Web
    context or Servlet Context (not sure of what this is called)
    2. The EJB I use in another part of the application cannot get the
    InitialContext(). When I try to do this I get NamingException thrown.
    Fran

    Thanks for this Mahendra.
    Does anybody have any idea as to the first problem? i.e. looping error?
    I'm calling this code many times, so maybe it's getting 'confused' but
    that's not really a good explanation of the problem!
    Many thanks again
    Fran
    "Mahendra Dhamdhere" <[email protected]> wrote in message
    news:3a96799a$[email protected]..
    As per my knowledge,
    env-entrys defined in web.xml are local to that container, a Container in
    which your servlet is deployed. For each web application, weblogic createsa
    ServletContainer and a ServletContext. That's why we can use differentlocal
    names from same global resources.
    As your servlet container and ejb container are different container andthey
    have different environment, to solve your problem, you can defineenv-entry
    in your deployment descriptor file(ejb-jar.xml).
    HTH,
    Mahendra
    Fran <[email protected]> wrote in message
    news:[email protected]..
    Hi
    I have put a String value, named "myval" into my web.xml file using
    <env-entry> tags. In my code I use the following:
    // assume this gets with default values...
    InitialContext ctxt = new InitialContext();
    String myval = (String) ctxt.lookup("java:comp/env/myval");
    and that usually extracts myval with no problems if I do it within a Web
    context, i.e. from a JSP or a class referenced initially from a JSP.
    However, it fails to extract myval when I do it within an EJB context,i.e.
    call from an EJB.
    Also, new InitialContext() sometimes goes into an infinite loop.
    So, I have two problems, can anyone clarify them?
    1. At random (not repeatable) the new InitialContext() call goes into an
    infinite loop. The WebLogic debug file just shows it looping and looping
    indefinitely, ending with a "Problematic thread" error!!! This is from aWeb
    context or Servlet Context (not sure of what this is called)
    2. The EJB I use in another part of the application cannot get the
    InitialContext(). When I try to do this I get NamingException thrown.
    Fran

  • Env-entry in web.xml and 6.0 sp4

    Does anyone know if iws 6.0 sp4 supports env-entry elements in web.xml???
    According to servlet specs 2.2 it should support it since it has JSP support.
    From 2.3 specs:
    "The following addtional elements exist in the web application deployment
    descriptor to meet the requirements of web containers that are JSP enabled or part
    of a J2EE application server. They are not required to be supported by containers
    wishing to support only the servlet specification.:
    � taglib
    � syntax for looking up JNDI objects (env-entry, ejb-ref, ejb-local-ref, resourceref,
    resource-env-ref)
    See the DTD comments for further description of these elements."

    Additional info...actually the code throws a NamingException.

  • Updated env-entries in  web.xml

              We are using WLS 5.1 SP10.
              In a web-application we like to have some parameters (related to the webapp as
              a whole) which can easily be changed (without having to restart the server).
              What is the best way to do that?
              I was thinking of env-entries.
              But when I change them the web.xml is not reloaded and the changes have no affect.
              Is dynamic reload of web.xml possible under WLS5.1 SP10?
              When should env-entries be used, and when init-params?
              Init-params seems to be servlet(JSP) related, while the environment entries affect
              the web-app environment. Are there other elements to take in consideration?
              In the doc I found no real explanation of when to use what...
              Any help would be appreciated,
              Frederic
              Please send answers also to my e-mail: [email protected]
              

    Hi,
    these are only configurations and don't cause a harm or use resources. So I suggest to leave them in just in case yu need them later
    Frank

  • Changing env-entry after deployment

    Hi,
    I was wondering how I can change the value of an env-entry after deployment? Do I have to change the value in the ejb-jar.xml, redeploy the application, or is there a utility I can use?
    thanks
    Steve

    Okay gentlemen, I dug around and couldn't find anything on this concept of defining an env-entry after deployment using Sun Java System Application Server 8.1 - so I just came up with my own hack. Thought I'd share it in case others have the same question and can't find the answer.
    Just to restate the problem: In SJAS you can't seem to define an environment entry that you can just look up via JNDI (you can do this in Tomcat pretty easy though using the context.xml file and an env-entry like syntax) - the benefit of this being of course that you can easily define deployment-time variables which a system administrator can set based on his setup. There seems to be no way to do this is SJAS 8.1
    As a workaround, you can create your own custom JNDI resource which will expose the properties that you set in the Admin Console as a simple java.util.Map that you can use from your app.
    Here's the blow by blow:
    2. Create a JNDIProperties object that implements java.util.Map but does NOT implement java.io.Serializable:
    package helpers.jndi;
    import java.util.Collection;
    import java.util.Map;
    import java.util.Set;
    public final class JNDIProperties implements Map {
        private Map map;
        public JNDIProperties(Map aMap) { map = aMap; }
        public boolean containsKey(Object key) { return map.containsKey(key); }
        public void clear() { map.clear(); }
        public Object get(Object key) { return map.get(key); }
        public boolean containsValue(Object value) { return map.containsValue(value); }
        public Set entrySet() { return map.entrySet(); }
        public boolean isEmpty() { return map.isEmpty(); }
        public Set keySet() { return map.keySet(); }
        public Object put(Object key, Object value) { return map.put(key, value); }
        public void putAll(Map t) { map.putAll(t); }
        public Object remove(Object key) { return map.remove(key); }
        public int size() { return map.size(); }
        public Collection values() { return map.values(); }
    }2. Create an object that implements javax.naming.spi.ObjectFactory and returns an instance of JNDIProperties containing the properties defined in the container:
    package helpers.jndi;
    import java.util.Enumeration;
    import java.util.Hashtable;
    import java.util.Map;
    import javax.naming.Context;
    import javax.naming.Name;
    import javax.naming.RefAddr;
    import javax.naming.Reference;
    import javax.naming.spi.ObjectFactory;
    public class PropertyFactory implements ObjectFactory {
        public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception {
            Map myMap = new Hashtable();
            Reference myReference = (Reference)obj;
            Enumeration myEnumeration = myReference.getAll();
            while (myEnumeration.hasMoreElements()) {
                RefAddr myRefAddr = (RefAddr)myEnumeration.nextElement();
                myMap.put(myRefAddr.getType(), myRefAddr.getContent());
            JNDIProperties myJNDIProperties = new JNDIProperties(myMap);
            return myJNDIProperties;
    }3. Build this and copy the jar to $SJAS_HOME/domains/domain1/lib/ext/ (or other appropriate folder for your setup), then restart the app server to get to load the jar.
    4. Go to the admin console and go to Resources -> JNDI -> Custom Resources -> New. Give it a sensible JNDI name (I'll use "testproperties" in this example), enter java.util.Map as the resource type and the name of your factory class for the "factory class" field, e.g. "helpers.jndi.PropertyFactory". Below that under "Additional Properties", add in each of the properties that you want to expose, for example enter a property named "testproperty1" with the value of "my test".
    5. You can now get a java.util.Map that contains the properties that you set for your custom JNDI resource by doing something like the following (example in JSP):
    <%
    Context myContext = new InitialContext();
    Context myEnvContext = (Context)myContext.lookup("java:comp/env");
    Map myMap = (Map)myEnvContext.lookup("testproperties");
    %>
    <%=myMap.get("testproperty1")%>Output is:
    my testNOTE: If this sounds convoluted - I agree, it is. If anyone's got a better idea, please post it; as I could not find another solution to this seemingly simple problem.

  • Env-entry MDB

    Environment: Weblogic 10.3
    I am trying to access an env-entry via @Resource injection. However, when I deploy my MDB, the Resource value is not being injected.
    @MessageDriven
    public class FooMdb {
    @Resource
    private String mdbId;
    <ejb-jar>
    <enterprise-beans>
    <message-driven>
    <ejb-name>FooMdb</ejb-name>
    <ejb-class>FooMdb</ejb-class>
    <env-entry>
    <env-entry-name>FooMdb/mdbId</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>fooOne</env-entry-value>
    </env-entry>
    </message-driven>
    </enterprise-beans>
    </ejb-jar>
    When I deploy the above the resource is not being injected and neither am I getting any errors. Any assistance would be appreciated.
    Thanks.

    the envenv-entry-name should be "qualifiedClassName/fieldName". it should work well. You could verify your env-entry-name is correct. if so, please post your full example here. thanks
    -Albert

  • SQL 2012 SP1 - How to determine a query that causes Error 8623 in SQL Log: The query processor ran out of internal resources and could not produce a query plan. This is a rare event...

    We are getting multiple 8623 Errors in SQL Log while running Vendor's software.
    How can you catch which Query causes the error?
    I tried to catch it using SQL Profiler Trace but it doesn't show which Query/Sp is the one causing an error. 
    I also tried to use Extended Event session to catch it, but it doesn't create any output either.
    Error:
    The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that
    reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
    Extended Event Session that I used;
    CREATE EVENT SESSION
        overly_complex_queries
    ON SERVER
    ADD EVENT sqlserver.error_reported
        ACTION (sqlserver.sql_text, sqlserver.tsql_stack, sqlserver.database_id, sqlserver.username)
        WHERE ([severity] = 16
    AND [error_number] = 8623)
    ADD TARGET package0.asynchronous_file_target
    (SET filename = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xel' ,
        metadatafile = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xem',
        max_file_size = 10,
        max_rollover_files = 5)
    WITH (MAX_DISPATCH_LATENCY = 5SECONDS)
    GO
    -- Start the session
    ALTER EVENT SESSION overly_complex_queries
        ON SERVER STATE = START
    GO
    It creates only .xel file, but not .xem
    Any help/advice is greatly appreciated

    Hi VK_DBA,
    According to your error message, about which query statement may fail with error message 8623, as other post, you can use trace flag 4102 & 4118 for overcoming this error. Another way is looking for queries with very long IN lists, a large number of
    UNIONs, or a large number of nested sub-queries. These are the most common causes of this particular error message.
    The error 8623 occurs when attempting to select records through a query with a large number of entries in the "IN" clause (> 10,000). For avoiding this error, I suggest that you could apply the latest Cumulative Updates media for SQL Server 2012 Service
    Pack 1, then simplify the query. You may try divide and conquer approach to get part of the query working (as temp table) and then add extra joins / conditions. Or You could try to run the query using the hint option (force order), option (hash join), option
    (merge join) with a plan guide.
    For more information about error 8623, you can review the following article.
    http://blogs.technet.com/b/mdegre/archive/2012/03/13/8623-the-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Trailing spaces in env-entry-type elements

    Hi,
    We have been porting our EJB application from another app server over to Oracle iAS (9.0.3 Lite) and have encountered a rather frustrating problem.
    We have an CMP (2.x) entity bean that has ejbSelect methods. There are corresponding <query> blocks in the ejb-jar.xml file for these methods. In the same ejb-jar.xml file there are <env-entry> blocks that setup a few things that are needed by the bean.
    If the <env-entry-type> element is written as "<env-entry-type>java.lang.String </env-entry-type>" (note the trailing space after the type name) the following exception occurs during deployment of the ear file;
    java.lang.InstantiationException: Failure to initialize EJBQL descriptors: com.sun.enterprise.deployment.xml.ContentTransformationException: java.lang.String is not an allowed property value type
         at com.evermind.server.ejb.deployment.EJBPackage.initializeEjbqlDescriptors(EJBPackage.java:2075)
         at com.evermind.server.ejb.deployment.EJBPackage.init(EJBPackage.java:2054)
         at com.evermind.server.ServerComponent.init(ServerComponent.java:208)
         at com.evermind.server.ejb.EJBPackageDeployment.getPackage(EJBPackageDeployment.java:672)
         at com.evermind.server.administration.ServerApplicationInstallation.finish(ServerApplicationInstallation.java:547)
         at com.evermind.server.administration.ServerApplicationInstallation.deploy(ServerApplicationInstallation.java:913)
         at com.evermind.server.administration.DefaultApplicationServerAdministrator.deploy(DefaultApplicationServerAdministrator.java:337)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:479)
    Error during deployment: Failure to initialize EJBQL descriptors: com.sun.enterprise.deployment.xml.ContentTransformationException: java.lang.String is not an allowed property value type
    Removing the trailing space and the deployment proceeds to completion without exceptions.
    I should also add that if the ejbSelect methods are remove d from the application and the trailing space left in place the resulting ear file will deploy sucessfully.
    It is trivial to reproduce this problem with the ORMAP demo that ships with 9.0.3.
    This was a really subtle problem that is not present on the *3* other appserver implementations that our application runs on. It was very frustrating to locate and perhaps some consideration could be given to how PCDATA is handled when parsing <env-entry-type> blocks.
    Cheers,
    Mick.

    Hi ,
    Create two Characteristic InfoObjects in BW With length 60 Char  and then in the Transfer Rules of this two InfoObjects write the Formula using Left() and right() function present in the Formula Builder .
    That is First infoObject Contains the Left 60 Char and next one Contains the right 60 Char.
    Regards,
    Vijay.

  • Query Reg env-entry in ejb jar xml

    Hi,
    I have the following tag in the ejb-jar of my application:
    <env-entry>
    <env-entry-name>postingDate</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>Request</env-entry-value>
    </env-entry>
    When a JNDI LookUp is done for this variable in the application, it doesn't pick up the value of the variable which is "Request" but it picks up the Value of the Posting Date.
    I need to know how this works!
    Just an Fyi, Posting Date is a date entered from the UI.

    I feel it is like declaring global and local variables with the same name and trying to access that variable.

  • Validation error when using env-entry in web.xml

    I've added an env-entry element to my web.xml and it falls over at deploy time with a validation error. However, from what I can see, this is valid based on the schema.
    And infact, it matches the example in the weblogic doco - http://edocs.bea.com/wls/docs103/webapp/web_xml.html#wp1025195
    The error I'm getting is:
    <17/12/2008 11:45:56 AM EST> <Error> <J2EE> <BEA-160197> <Unable to load descriptor D:\workspace\source_checkout\investment_control\ic-web\src\main\webapp/WEB-INF/web.xml of module ic-web.war. The error is weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
    problem: cvc-complex-type.2.4a: Expected elements 'mapped-name@http://java.sun.com/xml/ns/javaee injection-target@http://java.sun.com/xml/ns/javaee' instead of 'env-entry-type@http://java.sun.com/xml/ns/javaee' here in element env-entry@http://java.sun.com/xml/ns/javaee:<null>
         at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:234)
         at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:221)
    My web.xml looks like:
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5">
         <description>IC Web</description>
         <env-entry>
              <env-entry-name>aEntry</env-entry-name>
              <env-entry-value>aValue</env-entry-value>
              <env-entry-type>java.lang.String</env-entry-type>
         </env-entry>
    </web-app>
    Any suggestions???

    Found a resolution to this in the end.
    Unless you have the sub-elements in the order below, it will get validation errors.
    <env-entry>
    <env-entry-name>maxAmount</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>aString</env-entry-value>
    </env-entry>
    A bit weird and very frustrating....

  • Issue with [env-entry] element in web.xml

    I know it's possible to define [env-entry] elements in web.xml for environment
    properties of a web application. But how do you access [env-entry] elements from
    classes that do not exist within a web application? In other words, this is my
    problem:
    I have an EAR file, enterprise.ear, which contains the following...
    employee.jar
    employeeSearchEJB.jar
    webApp1.war
    META-INF/
    application.xml
    The employee.jar file is a utility archive that contains common classes, one of
    which is a class called LogManager. LogManager needs to read environment properties
    in order to initialize itself. Currently, LogManager reads these properties from
    a property file, and therefore it needs to know the name of the property file
    in order to access it. I dont like this approach because I'm forced to hard-code
    the name of the property file in LogManager. I would rather leverage the power
    of J2EE deployment descriptors and use the [env-entry] element to define the environment
    properties for the LogManager class. Then, I would simply use JNDI to get the
    values of the [env-entry] elements without ever having to specify their location
    aside from the default JNDI context; java:comp/env, which is standard anyway.
    The problem I'm having is that you can define the [env-entry] element in only
    2 types of deployment descriptors; namely, web.xml and ejb-jar.xml, neither of
    which are available to LogManager because LogManager exists at the EAR root level.
    I was hoping application.xml supported the [env-entry] element, but it doesn't.
    Any suggestions?
    SAF

    SAF,
    I am not sure if this applies to you situation but if you create an initial context
    instance and then grab the value using the jndi name within that context then
    you should be able to grab that environment variable.
    I have a helper class that is used as part of a deployed application. The helper
    class doesn't have access to the Servlet context but it is created as part of
    the application workflow. When it gets initiated it grabs an env-entry created
    in the web.xml deployment descriptor to find the default url for a content path.
    After I create an initialContext, I perform a initContext.lookup("jndi.env.entry.here")
    where "jndi.env.entry.here" is the name specified in the env-entry tag.
    This returns the value of the entry.
    This works under both Jrun and Weblogic so my guess is it should work for you.
    Again, I am assuming that your class will at least be able to grab a context
    object to communicate back to the server.
    Hope this helps,
    Troy
    "SAF" <[email protected]> wrote:
    >
    I know it's possible to define [env-entry] elements in web.xml for environment
    properties of a web application. But how do you access [env-entry] elements
    from
    classes that do not exist within a web application? In other words, this
    is my
    problem:
    I have an EAR file, enterprise.ear, which contains the following...
    employee.jar
    employeeSearchEJB.jar
    webApp1.war
    META-INF/
    application.xml
    The employee.jar file is a utility archive that contains common classes,
    one of
    which is a class called LogManager. LogManager needs to read environment
    properties
    in order to initialize itself. Currently, LogManager reads these properties
    from
    a property file, and therefore it needs to know the name of the property
    file
    in order to access it. I dont like this approach because I'm forced to
    hard-code
    the name of the property file in LogManager. I would rather leverage
    the power
    of J2EE deployment descriptors and use the [env-entry] element to define
    the environment
    properties for the LogManager class. Then, I would simply use JNDI to
    get the
    values of the [env-entry] elements without ever having to specify their
    location
    aside from the default JNDI context; java:comp/env, which is standard
    anyway.
    The problem I'm having is that you can define the [env-entry] element
    in only
    2 types of deployment descriptors; namely, web.xml and ejb-jar.xml, neither
    of
    which are available to LogManager because LogManager exists at the EAR
    root level.
    I was hoping application.xml supported the [env-entry] element, but it
    doesn't.
    Any suggestions?
    SAF

  • Bug in lookup of web.xml env-entry in WL 7.0?

    If I create an "env-entry" block for a name (e.g. "MySchemaName") in my web.xml
    file and deploy the web app, I should be able to look up the name from my webapp
    with the line:
    <br>
    myInitialContext.lookup("java:comp/env/MySchemaName");
    <br>
    However when I do that I get the error message:
    <br>
    javax.naming.NameNotFoundException: Unable to resolve 'java:comp.env/MySchemaName'
    <br>
    Note that the "comp/env" prefix has been changed to "comp.env". This worked under
    WL 6.1. Is this a bug in WL 7's JNDI or a bug in the error message or both or
    something else altogether?
    The immediately previous line successfully performs an EJBHome lookup using the
    same Initial Context object. The main difference is that the EJBHome name is defined
    thru the EJB deployment descriptors, not the web.xml.
    Thanks,
    Steve

    Ah, I was trying to do a lookup from session bean for the env-entry defined in
    the web.xml. After reading the J2EE spec, I see this just won't work. env-entries
    are only accessible from within the component where they are defined.
    Still the error message with "comp.env" instead of the expected "comp/env" is
    a bit confusing.
    Not much traffic in this newsgroup, is there?
    Steve
    "Steve Ditlinger" <[email protected]> wrote:
    >
    >
    >
    If I create an "env-entry" block for a name (e.g. "MySchemaName") in
    my web.xml
    file and deploy the web app, I should be able to look up the name from
    my webapp
    with the line:
    <br>
    myInitialContext.lookup("java:comp/env/MySchemaName");
    <br>
    However when I do that I get the error message:
    <br>
    javax.naming.NameNotFoundException: Unable to resolve 'java:comp.env/MySchemaName'
    <br>
    Note that the "comp/env" prefix has been changed to "comp.env". This
    worked under
    WL 6.1. Is this a bug in WL 7's JNDI or a bug in the error message or
    both or
    something else altogether?
    The immediately previous line successfully performs an EJBHome lookup
    using the
    same Initial Context object. The main difference is that the EJBHome
    name is defined
    thru the EJB deployment descriptors, not the web.xml.
    Thanks,
    Steve

  • Use of env-entry in ejb-jar

    In my ejb-jar.xml I have a Session bean with a env-entry:
    <env-entry>
    <env-entry-name>xslNameFile</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>pdftemplate.xsl</env-entry-value>
    </env-entry>
    In a class where I use the bean I make a lookup of this env-entry (using the same
    context):
    Context environment = (Context)ctx.lookup("java:comp/env/");
    val = (String)environment.lookup("xslNameFile");
    And I have the following Exception:
    javax.naming.NameNotFoundException: Unable to resolve 'comp/env/xslNameFile' Reso
    lved: 'comp/env' Unresolved:'xslNameFile' ; remaining name 'xslNameFile'
    What I m doing wrong??
    Could anyone help me?
    Thanks
    F.Canonica

    HI ,
    The Primary Purpose of <env-entry> tag
    is used to Customize your bean at Runtime
    and to Make your bean as an DataDriven one.
    ( instead of Storing it in DataBase )
    Regards
    Karthikeyan Gangadharan
    "Deepak Vohra" <[email protected]> wrote:
    >
    >
    >
    InitialContext ic = new InitialContext();
    String val = (String) ic.lookup("java:/comp/env/xslNameFile");
    "canonica" <[email protected]> wrote:
    In my ejb-jar.xml I have a Session bean with a env-entry:
    <env-entry>
    <env-entry-name>xslNameFile</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>pdftemplate.xsl</env-entry-value>
    </env-entry>
    In a class where I use the bean I make a lookup of this env-entry (using
    the same
    context):
    Context environment = (Context)ctx.lookup("java:comp/env/");
    val = (String)environment.lookup("xslNameFile");
    And I have the following Exception:
    javax.naming.NameNotFoundException: Unable to resolve 'comp/env/xslNameFile'
    Reso
    lved: 'comp/env' Unresolved:'xslNameFile' ; remaining name 'xslNameFile'
    What I m doing wrong??
    Could anyone help me?
    Thanks
    F.Canonica

  • env-entry element in ejb-jar.xml

    I just started to create my ejb-jar.xml (deployment descriptor file) manually so
    that I won't depend on those generated by proprietary IDEs.
    The ejb-jar_2_0.dtd specifies that env-entry is used in
    entity, message-driven, and session elements.
    My question is - When do we use the element <env-entry>? Under what
    circumstances that ejb-jar_2_0.dtd necessitates its provision in the ejb-jar.xml
    in relation to entity, message-driven, and session elements?

    Hi,
    I've same prob here
    <env-entry>
    <env-entry-name>config.file.location</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>C:/bea/ITReportingConf.xml</env-entry-value>
    </env-entry>
    Right now config file is out side of my EAR, How can i put it within the EAR I tried with changing the
    <env-entry-value>/ITReportingConf.xml</env-entry-value> Value
    But i dont know which dir it is refering to and where should i put "ITReportingConf.xml" File
    Thanks

Maybe you are looking for