jndi

How to lookup JNDI resources on WebLogic?

会有一股神秘感。 提交于 2019-11-27 04:33:46
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' at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139) at weblogic

Declaring @Resource and @EJB at the class level in Java EE6

南楼画角 提交于 2019-11-27 02:01:21
问题 Is there any situation still ( given that Java EE6 has java:global/, app/, module/ naming standards) that necessitates declaring EJBs or Resources like the example below? @EJB (name = "ejb/PlaceBid", beanInterface = PlaceBid.class) public class ActionBazaarBidControllerServlet extends HttpServlet { } Looking up PlaceBid in the helper class used by ActionBazaarBidControllerServlet PlaceBid placeBid = (PlaceBid)context.lookup("java:comp/env/ejb/PlaceBid"); 回答1: The java:comp/env/ namespace is

Tomcat vs Weblogic JNDI Lookup

我的梦境 提交于 2019-11-27 00:46:09
The Weblogic servers we are using have been configured to allow JNDI datasource names like "appds". For development (localhost), we might be running Tomcat and when declared in the <context> section of server.xml, Tomcat will hang JNDI datasources on "java:comp/env/jdbc/*" in the JNDI tree. Problem: in Weblogic, the JNDI lookup is "appds" whilst in Tomcat, it seems that that I must provide the formal "java:comp/env/jdbc/appds". I'm afraid the Tomcat version is an implicit standard but unfortunately, I can't change Weblogic's config ... so that means we end up with two different spring config

How do I connect to a Websphere Datasource with a given JNDI name?

给你一囗甜甜゛ 提交于 2019-11-27 00:23:24
问题 I'm using Websphere Portal 7.0 and creating a portlet with RAD 8.0. My portlet is trying to make a db2 connection to a remote server. I wrote a java program locally to do a basic JDBC connection to the server and get records from a table. The code works fine; however, when I add the code to my portlet as well as the db2jcc4.jar, the connection doesn't work. I'm using the basic: Connection connection = DriverManager.getConnection("jdbc:db2://server:port/db:user=user;password=pw;"); I figure

Connection cannot be cast to oracle.jdbc.OracleConnection

ⅰ亾dé卋堺 提交于 2019-11-26 22:23:18
问题 Why java.sql.Connection cannot be cast to oracle.jdbc.OracleConnection in code below? My main goal is to pass to Oracle connection new user name and save it in 'SESSION' table in for example 'osuser' column because I want to trace in DB user changes and display it in the table. @Repository public class AuditLogDAOImpl implements AuditLogDAO { @PersistenceContext(unitName="myUnitName") EntityManager em; @Resource(name = "dataSource") DataSource dataSource; public void init() { try { Connection

java使用数据库连接池

家住魔仙堡 提交于 2019-11-26 22:07:03
连接池的实现方式是首先使用 JNDI(JavaTM Naming and Directory Interface) 将数据源对象注册为一个命名服务,然后使用 JNDI 提供的服务接口,按照名称检索对应的数据源。 查找数据源的方法: 1 、创建一个命名服务环境( Context )。 2 、利用该环境对象的 lookup 方法按名查询,得到相应数据源对象。 3 、调用数据源对象的 getConnection 方法获取与数据库的连接。 第一步: Tomcat 安装目录下的 conf 的 context.xml 的 <Context></Context> 中添加代码: 修改 context.xml 文件加入如下代码: <Context> <Resource name="jdbc/cartds" type="javax.sql.DataSource" password="" driverClassName="com.mysql.jdbc.Driver" maxIdle="20" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/logistic" /> </Context> 第二步: 将相关的数据库驱动程序放置在项目中 的 lib 文件夹中。例如:库包中 mysql 包,并加入libraries 第三步

Trying to configure LDAP as JNDI Resource in Tomcat

不羁的心 提交于 2019-11-26 21:21:13
问题 I have an ldap server that I'm using to authenticate users within a tomcat web application. I'm using the JNDIRealm and it's configured within a context file and this works great. I'll also need to search the ldap for user information. I've figured out how to do this with the "jndi method" and I have it working fine outside of tomcat by creating my own jndi context using a hashtable. However, instead of configuring the jndi properties in code, I'd like to create a JNDI Rsource in my context

how to put(bind) object to jndi in spring declaratively?

纵然是瞬间 提交于 2019-11-26 21:19:44
问题 We have a plain standalone spring application and we need to put jdbc datasource in jndi. (we use jboss treecache and it need datasource to be in the jndi). Some googling found most of all jndi-lookup examples with spring, where an object is already put in jndi (by tomcat or application server etc), but we need otherwise: I have a plain datasource Spring bean, which I inject to other services, but I can't inject it to TreeCache, because it needs it only from jndi. Found org.springframework

Configure hibernate to connect to database via JNDI Datasource

匆匆过客 提交于 2019-11-26 19:39:05
Hi all I'm using Hibernate+Struts2+Tomcat6+Mysql as my J2EE framework. I've been using hibernate's built-in connection pooling mechanism but it turned out to be problematic where mysql closes it's connections after 8 hours. Anyway I googled around a little bit and found that I should get my connections through JNDI datasource but I couldn't reach a good and complete tutorial on this. What steps should I take to do so? please provide me enough of details, I'm kinda new on this. here is my hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-/

JNDI----数据连接池

本小妞迷上赌 提交于 2019-11-26 19:11:29
JNDI:提供了查找和访问各种命名和目录服务的通用,统一的接口       常用的配置属性:          name:表示以后要查找的名称。通过此名称可以找到DataSource,此名称任意更换,但是程序中最终要查找的就是此名称。                   auth:由容器进行授权及管理,指的用户名和密码是否可以在容器上生效         type:此名称所代表的类型,现在为javax.sql.DataSource         maxActive:表示一个数据库在此服务器上所能打开的最大连接数         maxIdle:表示一个数据库在此服务器上维持的最小连接数         maxWait:最大等待时间。10000毫秒         username:数据库连接的用户名         password:数据库连接的密码         driverClassName:数据库连接的驱动程序         url:数据库连接的地址    配置 MySQL数据库的JNDI数据源 <Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root"