"Halas, Miroslav" wrote:
> 
> We were still unable to resolve this. Just one question, is anybody out
> there using environment properties using XML deployment descriptors with
> Jonas 2.0. Does it work? Can you send us and example? Thanks,
> 
Hi Halas,
I don't understand why you cannot resolve any names in java:comp/env
context.
Have you succeeded to run the $JONAS_ROOT/examples/src/eb example?
As you can see in AccountExplBean.java the getConection method obtains
the datasource via a lookup :
initialContext.lookup("java:comp/env/jdbc/AccountExplDs");

Here is an example from our test suite where we use the environement
naming context:
 
In a Session Bean we have :


        // Check from initial Context
        try {
            String value = (String) ictx.lookup("java:comp/env/myname");
            if (!value.equals("mysession")) {
                Trace.errln("NSession: "+method+": ictx.lookup failed:
myname="+value);
                throw new EJBException("NSession 6: "+method);
            }
        } catch (NamingException e) {
            Trace.errln("NSession: "+method+": ictx.lookup raised
exception:\n"+e);
            throw new EJBException("NSession 7: "+method);
        }

the corresponding part of the DD is:
  <enterprise-beans>
    <session>
      <ejb-name>NSession</ejb-name>
      <home>tests.ejb.naming.NSessionHome</home>
      <remote>tests.ejb.naming.NSession</remote>
      <ejb-class>tests.ejb.naming.NSessionBean</ejb-class>
      <session-type>Stateful</session-type>
      <transaction-type>Container</transaction-type>
      <env-entry>
        <env-entry-name>myname</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>mysession</env-entry-value>
      </env-entry>


JOnAS supports also the deprecated EJBContext.getEnvironment() method
Here is an example that is running:

        // Test old method (EJB 1.0 - deprecated but must be supported)
        try {
            String oldvalue =
ejbContext.getEnvironment().getProperty("old-prop");
            if (oldvalue == null) {
                Trace.errln("NSession: "+method+": myEnv.lookup failed:
old-prop=null");
                throw new EJBException("NSession 5a: "+method);
            }
            if (!oldvalue.equals("old-prop value")) {
        Trace.errln("NSession: "+method+":myEnv.lookup
failed:old-prop="+oldvalue);
                throw new EJBException("NSession 5b: "+method);
            }
        } catch (Exception e) {
            Trace.errln("NSession: "+method+": \n"+e);
            throw new EJBException("NSession 5c: "+method);
        }

The corresponding part of the DD is:

      <env-entry>
        <env-entry-name>ejb10-properties/old-prop</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>old-prop value</env-entry-value>
      </env-entry>


I Hope it helps

Best regards,
-- 
        Philippe

Philippe Coq  Groupe Bulll/BullSoft/OpenMaster  Phone: (33) 04 76 29 78
49
Bull S.A  - 1 rue de Provence - 38432 Echirolles Cedex France
[EMAIL PROTECTED]  http://www-frec.bull.com
Download our EJBServer at http://www.bullsoft.com/ejb
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to