jndi

Java EE 6 embedded glassfish embedded derby EJB unit test

泄露秘密 提交于 2019-12-04 14:40:53
问题 questing is about javaee6 with embedded glassfish and embedded derby jndi lookup for data source at the time of deployment before unit test is executed.... Please find the persistence.xml here... <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> <persistence

Unable to access datasource remotely through JBoss

吃可爱长大的小学妹 提交于 2019-12-04 14:32:22
Context I have a JBoss where I have sucessfully deployed a datasource mydatasource-ds.xml . It's JNDI name is java:mydatasourceDS . JBoss claims that the datasource is succesfully deployed. The JMX console agress too. Problem I want to use this datasource from a client java app launched on a separate JVM. But I get an exception saying the java:mydatasourceDS cannot be found. java.lang.ClassCastException: javax.naming.Reference cannot be cast to javax.sql.DataSource Details Here is the persistence.xml file : <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java

Jetty Bind DataSource in JNDI Context

别等时光非礼了梦想. 提交于 2019-12-04 13:20:21
I would like to bind DataSource object to (eclipse) jetty's JNDI context programatically. I need for testing purpose. Here's a piece of code I have now: server = new Server(SERVER_PORT); webAppContext = new WebAppContext(); webAppContext.setResourceBase("."); webAppContext.setContextPath("/" + SERVER_CONTEXT); webAppContext.addEventListener(prepareServletContextListener()); webAppContext.addFilter(GuiceFilter.class, "/*", null); webAppContext.addServlet(DefaultServlet.class, "/"); Resource r = new Resource(webAppContext,"jdbc/testDS",createDataSource()); server.setHandler(webAppContext);

I don't understand @Resource mappedName element at all

爷,独闯天下 提交于 2019-12-04 10:24:52
I've read both and I don't understand them, can someone give an example and explain it in plain english please ? mainly what's the difference between it and the "name" element/ From Oracle tutorial The mappedName element is a non-portable, implementation-specific name that the resource should be mapped to. Because the name element, when specified or defaulted, is local only to the application, many Java EE servers provide a way of referring to resources across the application server. This is done by setting the mappedName element. Use of the mappedName element is non-portable across Java EE

javax.naming.NameNotFoundException

时光毁灭记忆、已成空白 提交于 2019-12-04 10:17:49
问题 I am running an example of ejb using JBoss5 Container. I am using an example from here(Part one). In the example I deployed bean in JBoss and an application in Tomcat(to acces the bean from JBoss). I am getting the error in the screen of tomcat server javax.naming.NameNotFoundException: greetJndi not bound ( greetJndi is the jndi-name in jboss.xml file ) Is there any specific directory structure to deploy in JBoss? Thanks 回答1: I am getting the error (...) javax.naming.NameNotFoundException:

How to show all objectclasses description of ldap directory using jndi

三世轮回 提交于 2019-12-04 08:29:45
I want to show all objectclasses present in schema of LDAP Directory to help user to input available objectclasses for adding new entry. DirContext schema = ctx.getSchema(""); Attributes answer = schema.getAttributes("ClassDefinition/person"); but that shows information about person only. You have to query the subschema subentry i.e cn=schema (the below code has been tested against the Apache Directory Server) DirContext ctx = new InitialLdapContext( env, null ); SearchControls searchControls = new SearchControls(); searchControls.setSearchScope( SearchControls.OBJECT_SCOPE ); searchControls

Tomcat 6/7 JNDI with multiple datasources

柔情痞子 提交于 2019-12-04 07:29:45
When there are more than one <Resource> elements in context.xml and more than one <resource-ref> elements in web.xml, my application begins to throw TNS:no appropriate service handler found and ORA-01017: invalid username/password; logon denied However, if there is only one of the data sources in JNDI, meaning the other one use regular JDBC data source, the application runs like a charm Both data sources come from same db URL but use different schema. My guess is that it may be caused by the same database URL of each resources with different username/password(schema). But tomcat should be

How to setup JNDI lookup in a Spring-JUnit test?

家住魔仙堡 提交于 2019-12-04 07:26:42
I'm using Maven 3.0.3, Spring 3.1.0.RELEASE, and JUnit 4.8.1. How do I create JNDI functionality outside the container (which in my case would be JBoss)? I thought Spring's jndiTemplate would do the trick (from my testApplicationContext.xml file): <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate" lazy-init="true"> <property name="environment"> <props> <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop> <prop key="java.naming.provider.url">localhost:1099</prop> </props> </property> </bean> ... <!-- Can't change the below code --> <bean

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

二次信任 提交于 2019-12-04 07:11:29
Hi When I try to connect to the datasource using JNDI, I am getting this error: [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(BasicDataSource.java:1044) at org.apache.roller.weblogger.business.DatabaseProvider.getConnection(DatabaseProvider.java:179) at org.apache.roller.weblogger

Change AD user expired password in Java

让人想犯罪 __ 提交于 2019-12-04 07:08:32
问题 I'm using JNDI to change LDAP user's password. In most cases (when user's password isn't expired) this code works just fine: public InitialLdapContext connect(String url, String securityPrincipal, String password) throws AuthenticationException, NamingException { System.setProperty("javax.net.ssl.trustStore", truststore); Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY