jndi

Bind JNDI datasource in tomcat?

只愿长相守 提交于 2019-12-01 17:21:17
Is it possible to bind programatically a DataSource to Tomcat's 6 JNDI? I want to create a DataSource on the fly and then make it available through JNDI ( to ColdFusion for instance ). This is what I have: public void bindToConext(DataSource dataSource) throws NamingException, SQLException { Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); envContext.bind("jdbc/mydatasource", dataSource); } But I'm getting this exception: javax.naming.OperationNotSupportedException: Context is read only Is there a work around? Well it was not

Using JNDI to share servlet session objects and data in Tomcat

自闭症网瘾萝莉.ら 提交于 2019-12-01 17:18:23
问题 Over the last few weeks i have been looking at solutions to share an object between two contexts/war files. There are a number of ways this can be done and one of them is JNDI. I am not very familiar with JNDI used in Tomcat so would like a few questions clarified: Basically i have an instance of an object that would provide the following services to more than one context/application Check that the user is logged on Check that the user's session is valid Logon user - Includes logging the

Configuring and looking up a simple String via JNDI in WebSphere

。_饼干妹妹 提交于 2019-12-01 17:16:51
问题 For the configuration of our applications we want to place some of the configuration in the application server. We are currently using the WebSphere JNDI facility for looking up urls and datasources. In addition we want to place simple Strings in the application server. We don't want to use the WebSphere "Enviroment variables". Can the "Resource Environment" be used for such a purpose? If so, how can it be used? We'd like to get the Strings with: InitialContext ctx = new InitalContext();

How to access JNDI data source defined in weblogic 10.3.6

谁说胖子不能爱 提交于 2019-12-01 17:07:27
I have created a JNDI data-source using my weblogic console but I am not able to access the object from my web application. Below are the details In weblogic 10.3.6, I have given the JNDI name for datasource as : jdbc/mydb To get DB connection from my web application I have written this code in my web application: Context initContext = new InitialContext(); DataSource ds = (DataSource)initContext.lookup("java:/comp/env/jdbc/mydb"); jndiConnection = ds.getConnection(); Earlier I was using Tomcat as server and I was able to get DB connection when I configured the resource details in the file

how to override JndiObjectFactoryBean in spring and set decrypted password in java

旧城冷巷雨未停 提交于 2019-12-01 13:10:15
I have a datasource in tomcat which has password that is encrypted using some algorithm and I want to decrypt the same when i establish connection with DB. Following is my spring config code <!--<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="${jdbc.jndiName}"/> </bean>--> <bean id="dataSource" class="my.app.util.EncryptedDataSource"> <property name="jndiName" value="${jdbc.jndiName}"/> </bean> The above bean is a custom one that extends the JndiObjectFactoryBean public class EncryptedDataSource extends JndiObjectFactoryBean{ ... }

cannot find my bean using the InitialContext.lookup() method

拟墨画扇 提交于 2019-12-01 12:14:02
I have tried to use struts 1.3 API to make a small application with EJB 3.0. Unfortunatelly i cannot use the @EJB annotation to call my bean object from inside my action class. I have solved this problem using different workarounds ( the first one is to use my global jndi name of my bean and the other is to call another class first and use the @EJB annotation from that class). Still these two workarounds have significant disadvantages. I would like to call my EJB directly from my action class. I have read plenty examples using the "java:comp/env/beanName" JNDI name but still haven't figure out

how to override JndiObjectFactoryBean in spring and set decrypted password in java

隐身守侯 提交于 2019-12-01 12:01:48
问题 I have a datasource in tomcat which has password that is encrypted using some algorithm and I want to decrypt the same when i establish connection with DB. Following is my spring config code <!--<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="${jdbc.jndiName}"/> </bean>--> <bean id="dataSource" class="my.app.util.EncryptedDataSource"> <property name="jndiName" value="${jdbc.jndiName}"/> </bean> The above bean is a custom one that

cannot find my bean using the InitialContext.lookup() method

这一生的挚爱 提交于 2019-12-01 11:33:48
问题 I have tried to use struts 1.3 API to make a small application with EJB 3.0. Unfortunatelly i cannot use the @EJB annotation to call my bean object from inside my action class. I have solved this problem using different workarounds ( the first one is to use my global jndi name of my bean and the other is to call another class first and use the @EJB annotation from that class). Still these two workarounds have significant disadvantages. I would like to call my EJB directly from my action class

Jetty Data Source, Hibernate, datasource not found

孤街浪徒 提交于 2019-12-01 10:39:01
问题 I'm attempting to configure a data source in Jetty 7.4. I was able to do this successfully with my webapp in a Tomcat context.xml. Here's what I have in the jetty.xml (this is going to be the only application in this jetty instance, so I don't mind having the DB connection server-wide - I'd rather not have to configure it inside the war). It's at the very bottom just above the last </Configure> : <New class="org.eclipse.jetty.plus.jndi.Resource" id="myDB"> <Arg> <Ref id="Server"/> </Arg> <Arg

How to retrieve DB connection using DataSource without JNDI?

一世执手 提交于 2019-12-01 10:31:05
We want our own db connection configuration instead of using JNDI, but in the meantime, we also want to use DataSource instead of using DriverManager, how to do so? Arun P Johny You use a connection pool library like c3p0 or commons dbcp . C3P0 ComboPooledDataSource cpds = new ComboPooledDataSource(); cpds.setDriverClass( "org.postgresql.Driver" ); //loads the jdbc driver cpds.setJdbcUrl( "jdbc:postgresql://localhost/testdb" ); cpds.setUser("dbuser"); cpds.setPassword("dbpassword"); Connection connection = cpds.getConnection(); DBCP BasicDataSource ds= new BasicDataSource(); ds