jndi

Oracle driver memory leak - Tomcat

随声附和 提交于 2019-11-30 20:26:18
We're using tomcat-7.0.33. Spring 3.0.1 and JPA using a tomcat JNDI datasource. Oracle 10g on the backend using ojdbc6.jar (latest). When we try to undeploy the application some Oracle classes seem to be leaking. I don't see this when using the older ojdbc14.jar drivers but we can't use those as we're migrating to Oracle 11g which requires the newer drivers. I'm guessing this is a bug in the Oracle drivers? Is there anything I can do to clean these resources up? I've tried closing the database connection pool and other things to no avail... Would I be better off not using Tomcat's connection

tomcat下JNDI的三种配置方式(转载+原创)

China☆狼群 提交于 2019-11-30 20:06:39
JNDI( Java Naming and Directory Interface, Java 命名和目录接口)是一组在Java应用中访问命名和目录服务的API。命名服务将名称和对象联系起来,使得我们可以用名称访问对象。目录服务是一种命名服务,在这种服务里,对象不但有名称,还有属性。 tomcat配置jndi有全局配置和局部配置。大致的有以下三种配置方式: 第一种:全局配置。 1)在tomcat的conf文件夹下的context.xml配置文件中加入: <Resource name="jndi/mybatis" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/appdb" username="root" password="123456" maxActive="20" maxIdle="10" maxWait="10000" /> 2)在项目的web.xml中加入资源引用: <resource-ref> <description>JNDI DataSource</description> <res-ref-name>jndi/mybatis</res-ref-name> <res-ref-type

SQLNestedException: Cannot create JDBC driver

ぃ、小莉子 提交于 2019-11-30 20:06:14
用DataSource 通过JNDI取得连接问题 ,抛出如下异常: java.lang.RuntimeException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' 原因是:部署webapp应用方式的问题,导致tomcat启动时找不到/META-INF/context.xml文件 往tomcat部署webapp应用有很多方式: 第1种方式: 这种方式最简单,就是在$CATALINA_BASE/conf/server.xml文件里做如下配置: <Context docBase="D:\java\workspace\JspServletNote\WebContent" path="/JspServletNote" reloadable="true" /> 这种方式,就能导致 tomcat启动时找不到/META-INF/context.xml文件 解决方法就是: 把自个的WebAppProject里的 /META-INF/context.xml 的内容复制到 $CATALINA_BASE/conf/context.xml里或者 $CATALINA_BASE/conf/server.xml里 参见: http:/

Shutting down Spring application makes JNDI name for datasource go away from jdbc context

天大地大妈咪最大 提交于 2019-11-30 18:38:32
I'm trying to setup a web application using Spring MVC and Spring Data JPA on my Weblogic server. The application works fine the first time I deploy it to the Weblogic server but when I stop the application the jndi name (jdbc/myDS) to my datasource disappears from the JNDI Tree on my Weblogic server, and then when I try to start the application again I get the following error: Caused By: javax.naming.NameNotFoundException: Unable to resolve 'jdbc.myDS'. Resolved 'jdbc'; remaining name 'myDS' I'm setting up the following at startup in JPAConfiguratation.java: package mySpringApp.application;

使用jndi技术在jsp中打印Connection对象

坚强是说给别人听的谎言 提交于 2019-11-30 16:10:12
1、修改tomcat/conf目录下的context.xml,将以下信息复制进去 <Resource name="jdbc/shop" <!--名字可随意取,该name值为通过上下文获取数据源的name参数后缀--> auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root" <!--mysql 用户名--> password="123456" <!--mysql 密码--> driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/shop?useUnicode=true&characterEncoding=utf8"/> <!--localhost:3306/shop 表示本机中库名为shop的数据库-->   将以上文本信息加到</Context> 标签上面        2、创建BaseDao类通过上下文获取数据源,以下的获取连接的方法 public Connection getConnection() { try { // 初始化上下文 Context context = new InitialContext(); //获取数据源

Servlet-spec: <context-param> vs <env-entry> in web.xml?

霸气de小男生 提交于 2019-11-30 15:07:11
问题 Why does the Servlet specification define two distinct ways (context parameters and environment entries) to provide a web application with configuration parameters? What are the respective advantages of these approaches (when should which be preferred)? 回答1: Environment entries are available via JNDI which may be useful when you don't have a ServletContext directly at hands, such as in EJBs. The one in the web.xml is actually the last in precedence chain as to overridding environment entires.

Setting up a datasource with WebSphere Liberty Profile 8.5

倖福魔咒の 提交于 2019-11-30 15:06:08
问题 My web app is getting a data source from JNDI with: javax.naming.InitialContext ctx = new javax.naming.InitialContext(); javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/db"); In the app's WEB-INF/web.xml , I have: <resource-ref> <description>DataSource</description> <res-ref-name>jdbc/db</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> In the app's WEB-INF/ibm-web-bnd.xml , I have: <web-bnd xmlns="http:/

Out of container JNDI data source

南楼画角 提交于 2019-11-30 14:41:45
问题 I would like to configure a DataSource using JNDI in a Java SE app. What is the best way to do this? So far, I've come across 2 projects: Apache Naming. The project page has a specific example for configuring a data source, but it looks like the project is super old and no longer active. JBossNS. It looks like it's easy to configure a local-only JNDI using LocalOnlyContextFactory , but I haven't found any docs on how to actually configure a data source. If possible, I would like to also

Java ldap authentication issue

痴心易碎 提交于 2019-11-30 14:09:41
问题 I'm trying to have my custom java application use our Active Directory Server for authentication but I cannot get it to work for some reason. Can anyone see why this is? Here is my method below: private boolean authenticate(String serverName, String userId, String password) throws NamingException { DirContext ctx = null; Hashtable env = new Hashtable(11); boolean b = false; try { env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap:

Setting up a datasource with WebSphere Liberty Profile 8.5

不打扰是莪最后的温柔 提交于 2019-11-30 13:47:10
My web app is getting a data source from JNDI with: javax.naming.InitialContext ctx = new javax.naming.InitialContext(); javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/db"); In the app's WEB-INF/web.xml , I have: <resource-ref> <description>DataSource</description> <res-ref-name>jdbc/db</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> In the app's WEB-INF/ibm-web-bnd.xml , I have: <web-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation