Return-Path: X-Original-To: apmail-tomee-commits-archive@www.apache.org Delivered-To: apmail-tomee-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22A6B1789F for ; Sun, 5 Apr 2015 12:11:34 +0000 (UTC) Received: (qmail 93365 invoked by uid 500); 5 Apr 2015 12:11:34 -0000 Delivered-To: apmail-tomee-commits-archive@tomee.apache.org Received: (qmail 93335 invoked by uid 500); 5 Apr 2015 12:11:34 -0000 Mailing-List: contact commits-help@tomee.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tomee.apache.org Delivered-To: mailing list commits@tomee.apache.org Received: (qmail 93326 invoked by uid 500); 5 Apr 2015 12:11:33 -0000 Delivered-To: apmail-openejb-commits@openejb.apache.org Received: (qmail 93323 invoked by uid 99); 5 Apr 2015 12:11:33 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Apr 2015 12:11:33 +0000 Date: Sun, 5 Apr 2015 12:11:33 +0000 (UTC) From: "Apache Fan (JIRA)" To: commits@openejb.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (OPENEJB-2113) Embeddable EjbContainer - unable to set up environment variables MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Apache Fan created OPENEJB-2113: ----------------------------------- Summary: Embeddable EjbContainer - unable to set up environment variables Key: OPENEJB-2113 URL: https://issues.apache.org/jira/browse/OPENEJB-2113 Project: OpenEJB Issue Type: Bug Components: configuration Affects Versions: 4.7.1 Environment: Tomee 1.7.1, Java 1.7.0_72 64bit, Windows 7 Reporter: Apache Fan My singleton EJB pulls environment value resources from web.xml and Tomee's context.xml. It works fine when executed in Tomee, but it is not possible to initialize the bean by using Embeddable EJBContext, the references to the resource remain null. EJB: {noformat} @Resource(name = "serviceendpoint.url") private String serviceEndpointUrl; @Resource(lookup = "java:comp/env/serviceendpoint.url") private String serviceEndpointUrl2; {noformat} web.xml {noformat} serviceendpoint.url java.lang.String https://blabla.com/rest/ {noformat} Tomee context.xml: {noformat} {noformat} Use of EJBContext: {noformat} final Properties p = new Properties(); p.put("serviceendpoint.url", "https://blahhhhhh.com/rest/"); final Context context = EJBContainer.createEJBContainer(p).getContext(); context.bind("java:comp/env/serviceendpoint.url", "https://blahhhhhh.com/rest/"); MyBean bean = (MyBean) context.lookup("java:global/myApp/myBean"); {noformat} As a result the serviceEndpointUrl and serviceEndpointUrl2 members remain null during the use of EJBContainer. In Tomee container they do fine. What could cause this problem? Workaround: {noformat} @PostConstruct public void getConnection() { if (serviceEndpointUrl == null) { // support for embedded EJB container for testing: serviceEndpointUrl = System.getProperty("serviceendpoint.url"); if (serviceEndpointUrl == null) { throw new IllegalStateException("unable to determine the value of environment var: serviceendpoint.url"); } } .... } {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)