jndi

EJB 3.1 | Error calling remote session bean via JNDI

走远了吗. 提交于 2019-12-10 10:27:49
问题 I'm trying to call a simple stateless session bean from a Java SE (Simple class). Here's my bean import javax.ejb.Stateless; /** * * @author MMRUser */ @Stateless public class CapitalBean implements CapitalBeanRemote { public String greetingsEjb(String name) { return "Hello " + name; } } Remote interface import javax.ejb.Remote; /** * * @author MMRUser */ @Remote public interface CapitalBeanRemote { public String greetingsEjb(String name); } From my client side I used stand-alone java class

Multiple dynamic data sources for a servlet context

廉价感情. 提交于 2019-12-10 00:40:45
问题 I'm developing a java servlet web application that manages information from multiple databases (all structurally the same) each corresponding to a different "business". The user selects "the current business" which is stored in the session and the application can display or modify that "current business". I would like to use tomcat Resources in a dynamic way to have access to these businesses using jndi. In this way I can use the jstl sql tags or context lookups in servlets. I can not define

Programmatically creating a JNDI DataSource for Spring

一个人想着一个人 提交于 2019-12-09 17:44:16
问题 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 -

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

流过昼夜 提交于 2019-12-09 17:29:07
问题 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

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

有些话、适合烂在心里 提交于 2019-12-09 17:06:55
问题 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? 回答1: Actually thread local is only way to

How to Configure JNDI DataSource in Tomcat 8 with Java Configuration:

穿精又带淫゛_ 提交于 2019-12-09 07:08:24
问题 How to Configure JNDI DataSource in Java Configuration File Instead of Following Code Snippet in "web.xml" Servlet Context: <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/DatabaseName</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> 回答1: Note: Don't Forget to Copy the "mysql-connector-java-5.1.36.jar" Into Tomcat's "lib" Subfolder in Main Installation Folder. First: Add following Dependency in Your "pom.xml"

Jetty 7: configuring JNDI for Start.java

给你一囗甜甜゛ 提交于 2019-12-09 05:39:45
问题 Following Wicket 1.5's lead, I'm converting a project from Jetty 6.1.25 to 7.5.0.v20110901. My existing Start.java contains the following setup, which I use to configure JNDI: EnvConfiguration envConfiguration = new EnvConfiguration(); URL url = new File("src/main/webapp/WEB-INF/jetty-env.xml").toURI().toURL(); envConfiguration.setJettyEnvXml(url); bb.setConfigurations(new Configuration[]{new WebInfConfiguration(), envConfiguration, new org.mortbay.jetty.plus.webapp.Configuration(), new

How to solve sun/io/MalformedInputException during JNDI lookup on remote WebSphere

别等时光非礼了梦想. 提交于 2019-12-09 00:40:51
问题 I use WebSphere 8.5 to host my application and configured some JDBC resources on the application server. Also I developed a client application using the thin client runtime library. When the JNDI look-up is performed in the following manner: env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); env.put(Context.PROVIDER_URL, "corbaloc:iiop:serv:2809"); Context initialContext = new InitialContext(env); DataSource ds = (DataSource) initialContext.lookup(

Glassfish 4: how to set application or module name for JNDI

[亡魂溺海] 提交于 2019-12-08 16:49:44
问题 I use EJB inside OSGi bundles. And now when I need to get EJB I have long jndi, for example: bean = (InterfaceName) ctx.lookup("java:global/longBundleName_version/OrganizationDirBean!and.plus.path.and.InterfaceName"); I want to change this part: longBundleName_version I mean, when I deploy bundle this part must be set from [glassfish-]application.xml or from [glassfish-]-ejb-jar.xml or from any other xml descriptor. I want jndi name for my ejb to be like: java:global

Specify a `DataSource` factory instead of Tomcat's default

元气小坏坏 提交于 2019-12-08 12:13:44
问题 tl;dr How do I tell Tomcat 9 to use a Postgres-specific object factory for producing DataSource object in response to JNDI query? Details I can easily get a DataSource object from Apache Tomcat 9 by defining an XML file named the same as my context. For example, for a web-app named clepsydra , I create this file: <?xml version="1.0" encoding="UTF-8"?> <Context> <!-- Domain: DEV, TEST, ACPT, ED, PROD --> <Environment name = "work.basil.example.deployment-mode" description = "Signals whether to