tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Apache Fan (JIRA)" <>
Subject [jira] [Created] (OPENEJB-2113) Embeddable EjbContainer - unable to set up environment variables
Date Sun, 05 Apr 2015 12:11:33 GMT
Apache Fan created OPENEJB-2113:

             Summary: Embeddable EjbContainer - unable to set up environment variables
                 Key: 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.

    @Resource(name = "serviceendpoint.url")
    private String serviceEndpointUrl;

    @Resource(lookup = "java:comp/env/serviceendpoint.url")
    private String serviceEndpointUrl2;


Tomee context.xml:
<Environment name="serviceendpoint.url" type="java.lang.String" value=""

Use of EJBContext:
final Properties p = new Properties();
p.put("serviceendpoint.url", "");

final Context context = EJBContainer.createEJBContainer(p).getContext();
context.bind("java:comp/env/serviceendpoint.url", "");

MyBean bean = (MyBean) context.lookup("java:global/myApp/myBean");

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?

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");

This message was sent by Atlassian JIRA

View raw message