Cannot lookup env-entry from within a JPA entity

Solution Unverified - Updated

Environment

  • JBoss Enterprise Application Plaform [EAP] 6

Issue

  • ear containing
    • application.xml with env-entry
    • persistence unit
  • lookup of env-entry throws NameNotFoundException during persistence unit startup

Resolution

  • Upgrade to EAP6.4.CP10 or higher to include fix for [Bug 1320132 - This content is not included.GSS naming context is not setup when starting the persistence unit](https://bugzilla.redhat.com/1320132)

Diagnostic Steps

  • add env-entry in application.xml
  • try to lookup during persistent unit startup, e.g.
public class MyType implements UserType {
...
    @Override
    public int[] sqlTypes() {
        try {
            Object ctx = new InitialContext().lookup("java:app/env");
            log.info("java:app/env from JPA = " + ctx);
        } catch (Exception e) {
            log.error("unable to get java:app/env from JPA", e);
        }

        return new int[] { Types.VARCHAR };
    }
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.