jndi

java.lang.IllegalStateException: Could not locate SessionFactory in JNDI

ⅰ亾dé卋堺 提交于 2019-12-04 06:25:24
问题 Good evening, i get the above exception when using Hibernate with JSF, i saw it many times in the past and the root cause was that like this <session-factory name="sessionFactory"> so i removed the name and change the generated code for creating the SessionFactory from that: protected SessionFactory getSessionFactory() { try { return (SessionFactory) new InitialContext() .lookup("SessionFactory"); } catch (Exception e) { log.error("Could not locate SessionFactory in JNDI", e); throw new

External LDAP JNDI connectivity using Tomcat

空扰寡人 提交于 2019-12-04 06:19:54
问题 I wanted to Know how external LDAP is connected using JNDI configuration in TOMCAT. My code is something like try { InitialContext iniCtx = new InitialContext(); ctx = (LdapContext) iniCtx.lookup("external/ldap/worker"); //System.out.println("LDAP Context initialized::"+ctx); if(ctx!=null) { urlProvider=ctx.getEnvironment().get("java.naming.provider.url").toString(); } } catch (NamingException ne) { throw new NamingException(ne.toString()); } My Context.xml in Tomcat has following entry

How to pass arguments to an LDAP custom socket factory with JNDI?

此生再无相见时 提交于 2019-12-04 05:49:17
I'm using JNDI to make LDAP connections. Example: Hashtable env = new Hashtable(); env.put(Context.PROVIDER_URL, LDAPS_URL); env.put(Context.SECURITY_AUTHENTICATION, "EXTERNAL"); env.put("java.naming.ldap.factory.socket", "ldaptest.CustomSocketFactory"); ... I need to pass parameters at run time to the CustomSocketFactory. Specifically a reference to a client certificate. How can I do this? I could use thread local storage. Is there a better way? Steffen Heil Actually thread local is only way to solve this I found so far. I posted my solution here: jndi LDAPS custom HostnameVerifier and

Programmatically creating a JNDI DataSource for Spring

对着背影说爱祢 提交于 2019-12-04 05:48:44
I have an existing Spring web-based application that has datasources defined using JNDI, and I'm trying to create a standalone app to use the beans. How can I create the JNDI entry and database properties programmatically in the standalone application? <bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/MyDS" /> </bean> public static void main(String[] args) { // this throws an error since the JNDI lookup fails - can I programmatically define the database properties here? ClassPathXmlApplicationContext ctx = new

providing certificates to tomcat jndi connection to postgresql

强颜欢笑 提交于 2019-12-04 05:32:43
问题 I want to connect to a postgresql server from a servlet in tomcat, using jndi. I have added the server cert to the truststore using keytool -keystore /usr/lib/jvm/java-11-openjdk-amd64/lib/security/cacerts -alias postgresql -import -file ~/postgres.infra-kk.der where the der file is the server cert converted to der. The home directory of tomcat user is /var/lib/tomcat9. /var/lib/tomcat9/.postgresql contains the following files: postgresql.crt the client certificate in pem format postgresql

Can I use ObjectChangeListener to listen for changes on any object?

核能气质少年 提交于 2019-12-04 05:18:26
问题 I've got an Integer called x; if it changes then i would like to update my table in a GUI. To listen to "x" I have tried ChangeEvent y = new javax.swing.event.ChangeEvent(x); and I implement javax.naming.event.ObjectChangeListener : class HDIManagementView extends FrameView implements ObjectChangeListener, ActionListener, TableModelListener { and I override the objectChanged method to update my table. Nothing happened public void objectChanged(javax.naming.event.NamingEvent name){ //gets

How does an application that uses Spring's SimpleNamingContextBuilder know to search its directory for resources?

此生再无相见时 提交于 2019-12-04 04:59:41
How does an application that uses Spring's SimpleNamingContextBuilder as its JNDI provider know to search its directory for resources? What links the application to the Spring naming directory? For example, how does the JndiObjectFactoryBean bean in this earlier answer know to find resource my-db in the Spring directory? Doesn't JndiObjectFactoryBean require a context environment with property java.naming.factory.initial set to some implementation of interface InitialContextFactory ? What should the value of java.naming.factory.initial be when using SimpleNamingContextBuilder as the JNDI

JNDI lookup failing with Jetty for JDBC connection pooling with MySQL?

ⅰ亾dé卋堺 提交于 2019-12-04 04:43:22
问题 I'm using Jetty 9.2 (embedded) with the standard MySQL connector API and I'm very confused by how this is supposed to be setup. Currently, I have this in my web.xml file: <webapp ... <resource-ref> <description>JDBC Data Source</description> <res-ref-name>jdbc/DataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </webapp> ...and this in my jetty-env.xml: <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <New id=

Spring 3 The matching wildcard is strict, but no declaration can be found for element 'jee:jndi-lookup'

主宰稳场 提交于 2019-12-04 04:42:15
So I am having an issue similar to here... Spring 3.0 Error: The matching wildcard is strict, but no declaration can be found for element my pom looks like this <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"

JNDI configuration/lookup in Glassfish

非 Y 不嫁゛ 提交于 2019-12-04 04:31:53
I'm having trouble getting some basic JNDI configuration going in Glassfish. I have what I think ought to be a simple task: at run time, determine if a particular property is set to true or not. I think this is a good application of JNDI, but can't seem to get the path correct between the app server and my servlet code. Here's how I have configured the property in Glassfish: In my servlet code, I'm trying to look up the value with: Boolean enabled = (Boolean) ctx.lookup("java:global/arizona/quartz_enabled"); In addition to this path, I've also tried the following without success: java:global