jndi

jndi.properties in JBoss

ぐ巨炮叔叔 提交于 2019-12-05 09:32:33
Is there any way to configure JNDI so the lookup first checks localhost and if it doesn't find matching name it performs automatic discovery of other jndi servers? Pascal Thivent My understanding of the documentation is that this is the default behavior when using clustering: 16.2.2. Client configuration The JNDI client needs to be aware of the HA-JNDI cluster. You can pass a list of JNDI servers (i.e., the nodes in the HA-JNDI cluster) to the java.naming.provider.url JNDI setting in the jndi.properties file. Each server node is identified by its IP address and the JNDI port number. The server

EJB3 Glassfish JNDI lookup

心已入冬 提交于 2019-12-05 09:16:15
I am using Glassfish-bundled Eclipse IDE. I wrote a simple EJB application. but it doesn't work. @Stateless @Remote(CalculatorRemote.class) @Local(CalculatorLocal.class) public class Calculator implements CalculatorRemote, CalculatorLocal { @Override public String sayHello(String name) { System.out.println("ejb:"+name); return null; } } ---- @Remote public interface CalculatorRemote { public String sayHello(String name); } ------- @Local public interface CalculatorLocal { public String sayHello(String name); } I wrote a standalone client to test, but failed. can't find JNDI. public class Main

Eclipse: Overriding JNDI Resource in Tomcat

你。 提交于 2019-12-05 08:06:02
I'm working on a Java web application in Eclipse and deploying to an instance of Tomcat that is run by Eclipse. I'm trying to get this application to talk to a database on another host via a JNDI Resource element. The context.xml file included in the application attempts to connect to a MySQL server running on localhost, like so: <?xml version="1.0" encoding="UTF-8"?> <Context> <Environment name="log4j.configuration" value="/path/to/installed/log4j.properties" type="java.lang.String" /> <Resource name="jdbc/configDB" auth="Container" type="javax.sql.DataSource" username="dbuser" password=

What is the difference between mappedName and lookup attributes of @Resource annotation in EJB?

会有一股神秘感。 提交于 2019-12-05 07:32:47
I'm confused between two attributes of @Resource annotation. Java Documentations says : mappedName : A product specific name that this resource should be mapped to. The name of this resource, as defined by the name element or defaulted, is a name that is local to the application component using the resource. (It's a name in the JNDI java:comp/env namespace.) Many application servers provide a way to map these local names to names of resources known to the application server. This mapped name is often a global JNDI name, but may be a name of any form. lookup : The name of the resource that the

Getting Internal Attributes of LDAP Object

北城余情 提交于 2019-12-05 06:06:53
I am trying to fetch LDAP User internal attributes, but couldn't find how to fetch them DirContext ctx = this.getDirContext(); List<Employee> list = new ArrayList<Employee>(); NamingEnumeration<SearchResult> results = null; try { SearchControls controls = new SearchControls(); controls.setSearchScope(SearchControls.SUBTREE_SCOPE); results = ctx.search("", "(objectclass=person)", controls); while (results.hasMore()) { SearchResult searchResult = results.next(); Attributes attributes = searchResult.getAttributes(); String fullName = this.getValue(attributes.get("cn")); //so on... } // so on from

How to use JNDI to obtain a new Stateful Session Bean, in EJB3?

筅森魡賤 提交于 2019-12-05 05:38:04
问题 I'm trying to use JNDI to obtain a new Stateful Session Bean in a servlet (as a local variable). My doGet() method has the following: Bean bean = (Bean) new InitialContext().lookup("beanName"); I've tried including java:comp/env but all of my attempts have led to naming exceptions. I'm attempting to bind the bean in the @Stateful annotation, using various guesses like @Stateful(name="beanName") and @Stateful(mappedName="beanName") 回答1: What I needed was to use the @EJB annotation on the

Documentation of Java Mail API configuration for JNDI in Tomcat

有些话、适合烂在心里 提交于 2019-12-05 05:23:26
I spend several days to figure out how to configure an javax.mail.Session in Tomcat via JNDI with authentication , now I get it but only after a deep dive in the code. In this time I have seen the worst code ever: javax.mail.Service#connect(String,String,String,String) Version 1.4.1 if (user == null) { user = url.getUsername(); if (password == null) // get password too if we need it password = url.getPassword(); } else { if (password == null && user.equals(url.getUsername())) // only get the password if it matches the username password = url.getPassword(); } When is the password assigned? and

Spring @Resource Handling

允我心安 提交于 2019-12-05 05:04:19
I'm having trouble with a field annotated as @Resource in a Spring bean. What I have: A field, with setter method, annotated @Resource @Resource private URL someUrl; public void setSomeUrl(URL someUrl) { this.someUrl = someUrl; } An <env-entry> tag in my deployment descriptor (web.xml) <env-entry> <env-entry-name>someUrl</env-entry-name> <env-entry-type>java.net.URL</env-entry-type> <env-entry-value>http://somedomain.net/some/path</env-entry-value> </env-entry> The application fails to start with a BeanCreationException , which I dont' expect because I don't necessarily want spring to inject a

jboss jndi context is empty

做~自己de王妃 提交于 2019-12-04 21:53:13
An ejb-jar deployed to jboss 7 has a jdni binding "java:global/foo!IFoo". Jboss management console shows this binding. The jndi port is 1099 as by default. A client on jboss gets an object to that binding but a standalone client running on the same machine does not. Properties properties = new Properties(); properties.put("java.naming.factory.initial", "org.jboss.as.naming.InitialContextFactory"); properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces"); properties.put("java.naming.provider.url","jnp://localhost:1099"); Context ctx = new InitialContext(properties);

Multiple dynamic data sources for a servlet context

泪湿孤枕 提交于 2019-12-04 21:05:21
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 each Resource in the web.xml file because they are stored in a SQL table. The end result is to be able