jndi

How does the EJB client locate the EJB server without url?

痴心易碎 提交于 2019-11-29 01:49:26
I am new to Java EE. At present I am going through The Java EE 6 Tutorial, Volume 1 (Basic Concepts Beta) by Sun Microsystems. To escape from monotonous reading time to time I play with few Java EE projects/codes written by others. I came from SE. My head is still filled with SE. In SE ( two tier application) I use DATABASE_URL = "jdbc:mysql://something.db_server.com/db_name" This is how my client knows where the database server is. In one Java EE example I saw // Access JNDI Initial Context. Properties p = new Properties(); p.put("java.naming.factory.initial","org.jnp.interfaces

Initialcontext in a standalone Java program

为君一笑 提交于 2019-11-28 23:14:23
I'm using a JNDI for creating tomcat connection pool. It works great in a web application. I believe the InitialContext is provided by the tomcat server. Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); dataSource = (DataSource)envContext.lookup("jdbc/testdb"); But when I try to call the same utility from a standalone Java program, the initContext object is null. How can I explicitly provide all the necessary properties that Context object is expecting. Error : javax.naming.NoInitialContextException: Need to specify class name in

how to accept self-signed certificates for JNDI/LDAP connections?

邮差的信 提交于 2019-11-28 20:35:07
问题 I need to connect to an LDAP directory over SSL. In non-production environments, we use self-signed certificates which, of course, fails to validate with: javax.naming.CommunicationException: simple bind failed: ldapserver:636 [Root exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target] at com.sun.jndi.ldap

Easy way to start a standalone JNDI server (and register some resources)

筅森魡賤 提交于 2019-11-28 19:50:48
For testing purposes, I'm looking for a simple way to start a standalone JNDI server, and bind my javax.sql.DataSource to "java:/comp/env/jdbc/mydatasource" programmatically. The server should bind itself to some URL, for example: "java.naming.provider.url=jnp://localhost:1099" (doesn't have to be JNP), so that I can look up my datasource from another process. I don't care about which JNDI server implementation I'll have to use (but I don't want to start a full-blown JavaEE server). This should be so easy, but to my surprise, I couldn't find any (working) tutorial. The JDK contains a JNDI

java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool DataSourceFactory

半世苍凉 提交于 2019-11-28 19:40:39
I'm investigating moving away from an Oracle connection pool and using the Tomcat connection pool. I followed the myriad of example for configuring the <Resource> in Tomcat's /conf/server.xml . I found great info here . However, when I start Tomcat, I get the following error: javax.naming.NamingException: Could not load resource factory class [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool DataSourceFactory] I'm using Tomcat 6.0. My <Resource> config in /conf/server.xml is: <Resource name="jdbc/myds" type="javax.sql.DataSource" auth="Container" factory="org

Configure Multiple DataSource in Spring Boot with JNDI

ⅰ亾dé卋堺 提交于 2019-11-28 18:59:44
I want to manage multiple DataSource using your Application Servers built-in features and access it using JNDI. I am using Spring boot with Spring JPA data. I am able to configure the application.properties for single datasource: spring.datasource.jndi-name=jdbc/customers And my configuration in context.xml file as below: <Resource name="jdbc/customer" auth="Container" type="javax.sql.DataSource" maxTotal="100" maxIdle="30" maxWaitMillis="10000" username="root" password="root" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/customer"/> Everything works fine. But when I

How can i config module and application name for JNDI Lookups

人盡茶涼 提交于 2019-11-28 17:06:18
In EJB 3.1 JNDI Lookups can be made with different Lookup-Names: java:global[/<app-name>]/<module-name>/<bean-name>!<fully-qualifiedbean interface-name> java:global[/<app-name>]/<module-name>/<bean-name> java:app/<module-name>/<bean-name>!<fully-qualified-bean-interface-name> java:app/<module-name>/<bean-name> java:module/<bean-name>!<fully-qualified-bean-interface-name> java:module/<bean-name> In my JavaEE 6 Project (with Maven 2, Netbeans 6 and Glassfish v3) the Application name is X-Snapshot.ear and the EJB-Module is Y-Snapshot.jar. How can i config this maven project to use another

在tomcat中配置JNDI数据源 .

僤鯓⒐⒋嵵緔 提交于 2019-11-28 16:34:39
在tomcat5.0中配置数据源(全局数据源、局部数据源),通过连接池机制连接数据库 1. odbc-jdbc桥连 2. 通过加载本地驱动连接 3. 在web应用服务器中设置数据源,通过池接技术连接数据库(加载本地驱动) 4. 在框架中设置数据源,通过内置连接池或者集成外部连接池与数据库交互 Tomcat全局数据源的设置: 1. 启动tomcat服务器,登陆admin服务器控制台,点击【Resources】-》【Data Sources】,选择【create new Data Source】, 输入相关的信息,点击保存(save),提交变化(commit change),将信息添加到 server.xml文件中。 2. 编写应用程序,获取数据源,连接数据库,将web应用部署到web容器中 初始化jndi的上下文接口 this.context = new InitialContext(); //查找数据源 //java:comp/env 目录是java默认的命名 空间 //hygj 名字是资源链接名,不是全局资源的jndi名 this.ds = (DataSource) this.context.lookup("java:comp/env/hygj"); 3. 登陆admin服务器控制台,给部署的web应用配置资源连接 点击【service】-》【host】--》【Context】-

What is the relationship between java:comp/env and java:global?

此生再无相见时 提交于 2019-11-28 16:20:13
问题 What is the relationship between java:comp/env and java:global (regarding 3.1 spec)? Seems like java:comp/env contains specific to EJB references. What means "specific" in this case? 回答1: java:global is a namespace that's global for the entire application server, which includes other EAR modules (which are considered to be different applications). java:comp/env is a much smaller namespace. For the web module, it corresponds to all web components (servlets etc) which are all together

what is java:comp/env?

雨燕双飞 提交于 2019-11-28 15:17:26
what is meant by java:comp/env ? What does the look up like : Context envContext = (Context)initContext.lookup("java:comp/env"); do ? I understand that a look-up like : (DataSource)envContext.lookup("jdbc/MyDatasource") looks up for the name MyDatasource in the context.xml or web.xml to get the URL of the database. Is it so ? !! But what does the former look up do ? JB Nizet java:comp/env is the node in the JNDI tree where you can find properties for the current Java EE component (a webapp, or an EJB). Context envContext = (Context)initContext.lookup("java:comp/env"); allows defining a