jndi

Why use JNDI for data sources

我们两清 提交于 2019-11-26 19:08:00
问题 Can anyone help explain why JNDI should be a preferred way to expose services such as a database / jms? The posts I run into all talk about the advantage of not having to load a specific driver manager, benifiting from connection pooling etc. but thats easily achievable by specifying the driver manager in a properties file and using reflection. Connection pooling can also be achieved by wiring in the right implementation into an application bean via spring or otherwise. So why would using

Code to list all the entries in jndi on remote machine

末鹿安然 提交于 2019-11-26 19:05:50
问题 Can any one tell or point me to code to list all the jndi entries in a remote machine 回答1: It is possible to list all entries of an InitialContext. You can use this snippet: InitialContext ctx = new InitialContext(); NamingEnumeration<NameClassPair> list = ctx.list(""); while (list.hasMore()) { System.out.println(list.next().getName()); } If you are using an application server, there is usually the option to browse the JNDI tree. 回答2: The previous answers didn't give me the "full picture" (on

How do a LDAP search/authenticate against this LDAP in Java

一个人想着一个人 提交于 2019-11-26 18:49:43
问题 I am playing with LDAP and Java search. Here's my LDIF export with a simple organization version: 1 dn: dc=example,dc=com objectClass: organization objectClass: dcObject objectClass: top dc: example o: MyOrganization description: Test Description dn: ou=people, dc=example,dc=com objectClass: organizationalUnit objectClass: top ou: people description: All users in demo company dn: cn=Johnny Doe,ou=people,dc=example,dc=com objectClass: organizationalPerson objectClass: person objectClass:

Cannot create JDBC driver of class ' ' for connect URL 'null' : I do not understand this exception

亡梦爱人 提交于 2019-11-26 17:49:05
Why does it say null URL and gives a empty ' ' class in the exception when i have provided the database URL ? I try to connect to derby database via a servlet while using Tomcat . When the servlet gets run,I get the following exceptions : org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection

Proper usage of JDBC Connection Pool (Glassfish)

我的未来我决定 提交于 2019-11-26 14:17:07
问题 I need a database connection in Java Web service implemented as a session bean, and I'm not sure if I do it right. I created a class public final class SQLUtils { //..... private static DataSource m_ds=null; static { try { InitialContext ic = new InitialContext(); m_ds = (DataSource) ic.lookup(dbName); //Connection pool and jdbc resource previously created in Glassfish , dbName contains the proper JNDI resource name } catch (Exception e) { e.printStackTrace(); m_ds = null; } } public static

ejb lookup failing with NamingException

隐身守侯 提交于 2019-11-26 13:53:35
问题 I've added the following in my web.xml: <ejb-ref> <ejb-ref-name>ejb/userManagerBean</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <home>gha.ywk.name.entry.ejb.usermanager.UserManagerHome</home> <remote>what should go here??</remote> </ejb-ref> The following java code is giving me NamingException: public UserManager getUserManager () throws HUDException { String ROLE_JNDI_NAME = "ejb/userManagerBean"; try { Properties props = System.getProperties(); Context ctx = new InitialContext(props

JNDI path Tomcat vs. Jboss

丶灬走出姿态 提交于 2019-11-26 13:08:20
问题 I have DataSource which is configured on Tomcat 6 in context.xml as MyDataSource. And I\'m fetching it the following way: DataSource dataSource; try { dataSource = (DataSource) new InitialContext().lookup(\"java:comp/env/MyDataSource\"); } catch (NamingException e) { throw new DaoConfigurationException( \"DataSource \'\" + url + \"\' is missing in JNDI.\", e); } Everything works fine. Now I\'m exporting this code to Jboss AP 6. and I configured my dataSource and its connection pool as local

How to lookup JNDI resources on WebLogic?

狂风中的少年 提交于 2019-11-26 12:45:22
问题 I deployed a legacy application on WebLogic 11g. The application has the following code: Context context = new InitialContext(); dataSource = (javax.sql.DataSource) context.lookup(\"java:myDataSource\"); I also have a data source configured in WebLogic with the JNDI name of: jdbc/myDataSource When the above java code runs, I get the following exception: javax.naming.NameNotFoundException: While trying to look up /myDataSource in /app/webapp/axis2.war/60105275.; remaining name \'/myDataSource\

The meaning of NoInitialContextException error

橙三吉。 提交于 2019-11-26 12:23:14
I am writing a client for my EJB and when trying to execute it, I get the following exception : javax.naming.NoInitialContextException : Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file. I just can't understand what the problem is. The javax.naming package comprises the JNDI API. Since it's just an API, rather than an implementation, you need to tell it which implementation of JNDI to use. The implementations are typically specific to the server you're trying to talk to. To specify an implementation, you pass in a

Best practice to get EntityManagerFactory

本秂侑毒 提交于 2019-11-26 11:57:47
问题 What is the best approach to get EntityManagerFactory in web app(jsp/servlets)? Is this a good way When should EntityManagerFactory instance be created/opened?, or is it better to get it from JNDI, or something else? 回答1: They're heavyweight and they're supposed to be in the application scope. So, you need to open them on application startup and close them on application shutdown. How to do that depends on your target container. Does it support EJB 3.x (Glassfish, JBoss AS, etc)? If so, then