Note that there are some explanatory texts on larger screens.

plurals
  1. POContext is read only
    text
    copied!<p>Helo masters, I have to create a JNDI Datasource dynamically, I tried to do it with a listener called SetupApplicationListener. Here is the beginning of <code>WEB-LIB/web.xml</code></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee"&gt; &lt;display-name&gt;pri-web&lt;/display-name&gt; &lt;!-- Listeners --&gt; &lt;listener&gt; &lt;listener-class&gt;org.apache.myfaces.webapp.StartupServletContextListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;listener&gt; &lt;listener-class&gt;myapp.SetupApplicationListener&lt;/listener-class&gt; &lt;/listener&gt; </code></pre> <p>The code of the listener:</p> <pre><code>public class SetupApplicationListener implements ServletContextListener { public static Log LOG = null; public void contextInitialized(ServletContextEvent ctx){ try { createOracleDataSource(); ..... } } private void createOracleDataSource() throws SQLException, NamingException { OracleDataSource ds = new OracleDataSource(); ds.setDriverType(...); ds.setServerName(...); ds.setPortNumber(...); ds.setDatabaseName(...); ds.setUser(...); ds.setPassword(...); new InitialContext().bind("java:comp/env/jdbc/myDS", ds); } ..... } </code></pre> <p>And there is the error:</p> <pre><code>[ERROR] 29/01/2013 09:44:50,517 (SetupApplicationListener.java:86) -&gt; Error javax.naming.NamingException: Context is read only at org.apache.naming.NamingContext.checkWritable(NamingContext.java:903) at org.apache.naming.NamingContext.bind(NamingContext.java:831) at org.apache.naming.NamingContext.bind(NamingContext.java:171) at org.apache.naming.NamingContext.bind(NamingContext.java:187) at org.apache.naming.SelectorContext.bind(SelectorContext.java:186) at javax.naming.InitialContext.bind(InitialContext.java:359) at myapp.SetupApplicationListener.createOracleDataSource(SetupApplicationListener.java:102) </code></pre> <p>Can I set the read-only properties of the Context to "true"? Thanks! :)</p> <pre><code>Tomcat 6.0 Oracle 11g jdk1.5 </code></pre> <p><strong>EDIT</strong>: Don't need to be dynamically, i have to define a jndi datasource internally I can't modify the server files because it is a shared server. It must be jndi because other modules use it in that way, thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload