-
1. Re: migrating a tomcat application to JBoss 7.1.1 - problems with context.xml
jensaug Nov 13, 2013 9:34 AM (in response to gioppoluca)Hi luca,
If you don't need access to this file outside the WAR, you might move the init-params to the standard descriptor file web.xml.
Snippet;
... <servlet> <servlet-name>My Servlet</servlet-name> <servlet-class>com.controller.TestServlet</servlet-class> <init-param> <description>This is an init parameter example</description> <param-name>cfgFile</param-name> <param-value>config.txt</param-value> </init-param> </servlet>
More details found here.
If you need access outside the WAR, here a link to another thread for those who need a replacement to context.xml outside the WAR
Tomcat's ResourceLink links a global JNDI name to module (WAR) JNDI name. You won't be able to lookup global resources using local JNDI names inside your components unless you've made this mapping. So if it's ok for you to move it to the standard descriptor file web.xml, here's a snippet that might cut it for you:
<resource-ref> <res-ref-name>jdbc/srqa</res-ref-name> <res-type>javax.sql.DataSource</res-type> <lookup-name>java:global/jdbc/srqa</lookup-name> </resource-ref>
However, in your specific case you're trying to lookup a datasource and if you've configure it the "normal" way (using CLI or Web Console) and follow best practices, your datasource will be located in the jboss namespace in JNDI. So the lookup-name is more likely to be
<lookup-name>java:jboss/datasources/srqa</lookup-name>
In general, the JBoss jboss-web.xml is the replacement file for context.xml. But you should prefer to use the standard web.xml descriptor file whenever possible.
br,
Jens