NameNotFoundException in Web-Application for 'java:comp/env'
hiro.protagonist Sep 25, 2007 5:13 AMI am deploying a web application into JBoss 4.0.4GA with an embedded Tomcat 5.5 . The deployment descriptor (WEB-INF/web.xml) contains an <env-entry>:
... <!-- Setup ENC for this webapp --> <env-entry> <env-entry-name>ecms/configfile</env-entry-name> <env-entry-value>server.properties</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> ...
This entry I would like to access via JNDI:
Context initial = new InitialContext(); Context environment = (Context)initial.lookup("java:comp/env");
This results in a NameNotFoundException for "env". The code works with a standalone Tomcat but not inside JBoss. The JNDI-View confirms that there is no "java:comp/env":
java: Namespace +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory) +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource) +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory) +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter) +- comp (class: javax.naming.Context) +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl) +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory) +- jaas (class: javax.naming.Context) | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext) | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext) | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext) +- timedCacheFactory (class: javax.naming.Context) Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy cannot be cast to javax.naming.NamingEnumeration +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory) +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory) +- Mail (class: javax.mail.Session) +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter) +- TransactionManager (class: org.jboss.tm.TxManager)
My question: How can this happen? I thought the ENC has to exist for every application component, including webapps.
How do I need to configure JBoss to make an ENC available for my web application?
Any help really appreciated.
Forgive me my spelling errors since english is not my native language.