Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Jetty mysql connection-pool configuration error: javax.naming.NameNotFoundException; remaining name 'env/jdbc/---(mysql 5.0+jetty 7.0.1)

My configuration files

project/WEB-INF/web.xml:

<resource-ref>
    <description>ConnectionPool DataSource Reference</description>
    <res-ref-name>jdbc/mysql</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

project/WEB-INF/jetty-env.xml:

<New id="mysql" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
<Arg>jdbc/mysql</Arg>
    <Arg>
        <New class="org.apache.commons.dbcp.BasicDataSource">
            <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
            <Set name="url">jdbc:mysql://localhost:3306/db</Set>
            <Set name="username">user</Set>
            <Set name="password">pwd</Set>
            <Set name="maxActive">50</Set>
        </New>
    </Arg>
</New>


code to invoke:

{
ctx = new InitialContext();
ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mysql");
con=ds.getConnection();
}


scripts to start jetty:

java -DOPTIONS=plus -jar start.jar

java -jar start.jar

Either way to start jetty,I got following error:


javax.naming.NameNotFoundException; remaining name 'env/jdbc/mysql' at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:632) at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:663) at org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:678) at org.eclipse.jetty.jndi.java.javaRootURLContext.lookup(javaRootURLContext.java:110) at javax.naming.InitialContext.lookup(Unknown Source)


The questions are:

what is the problem here?Any other configurations needed?

where to put following jar files:

commons-dbcp-1.2.2.jar mysql-connector-java-5.1.10-bin.jar

Thank you!

 

 

 


Back to the top