jndi

WildFly JNDI lookup for local EJB deployed in a WAR

不问归期 提交于 2019-11-27 08:14:02
问题 I'm using WildFly 8.1.0 Final release. My application is a JavaEE web app deployed in a WAR (there is no EJB module .ear). I want to programmatically invoke local EJB with his name using JNDI. The EJB are just annotated with @Stateless (there is no Local or Remote interfaces) I try below function: private <E extends DomainObject> CrudService<E> lookUp(Class<E> cl) { try { final Hashtable jndiProperties = new Hashtable(); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client

Spring boot 发送电子邮件

让人想犯罪 __ 提交于 2019-11-27 08:12:43
Spring Framework提供了一个使用 JavaMailSender 接口发送电子邮件的简单抽象,Spring Boot为它提供了自动配置以及启动器模块。 有关如何使用JavaMailSender的详细说明,请参阅参考文档。 如果 spring.mail.host 和相关库(由 spring-boot-starter-mail 定义)可用,则创建默认 JavaMailSender (如果不存在)。可以通过 spring.mail 命名空间中的配置项进一步自定义发件人。有关详细信息,请参阅 MailProperties 。 特别是,某些默认超时值是无限的,您可能希望更改它以避免线程被无响应的邮件服务器阻塞,如以下示例所示: spring.mail.properties.mail.smtp.connectiontimeout=5000 spring.mail.properties.mail.smtp.timeout=3000 spring.mail.properties.mail.smtp.writetimeout=5000 也可以使用JNDI中的现有 Session 配置 JavaMailSender : spring.mail.jndi-name=mail/Session 设置 jndi-name 时,它优先于所有其他与会话相关的设置。 觉得有帮助的可以支持一下博主 来源:

ejb lookup failing with NamingException

北慕城南 提交于 2019-11-27 07:54:16
I've added the following in my web.xml: <ejb-ref> <ejb-ref-name>ejb/userManagerBean</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <home>gha.ywk.name.entry.ejb.usermanager.UserManagerHome</home> <remote>what should go here??</remote> </ejb-ref> The following java code is giving me NamingException: public UserManager getUserManager () throws HUDException { String ROLE_JNDI_NAME = "ejb/userManagerBean"; try { Properties props = System.getProperties(); Context ctx = new InitialContext(props); UserManagerHome userHome = (UserManagerHome) ctx.lookup(ROLE_JNDI_NAME); UserManager userManager =

JNDI path Tomcat vs. Jboss

不问归期 提交于 2019-11-27 07:19:08
I have DataSource which is configured on Tomcat 6 in context.xml as MyDataSource. And I'm fetching it the following way: DataSource dataSource; try { dataSource = (DataSource) new InitialContext().lookup("java:comp/env/MyDataSource"); } catch (NamingException e) { throw new DaoConfigurationException( "DataSource '" + url + "' is missing in JNDI.", e); } Everything works fine. Now I'm exporting this code to Jboss AP 6. and I configured my dataSource and its connection pool as local-tx dataSource under the same name. When I'm executing the code above, I'm getting NamingException exception. after

Deploying a war to Jetty with CDI

左心房为你撑大大i 提交于 2019-11-27 07:18:40
问题 I have a maven project in IntelliJ where I am trying to deploy a war file to a jetty container. The purpose of this is for a quick integration test of some of the functionality in said war file. Since out of the box Jetty does not come with CDI or JNDI, I am trying to add support for these but running into some issues. For example, I get the following error on startup: 15:30:50 [34mINFO [0;39m o.a.s.c.CdiObjectFactory - [lookup]: Checking for BeanManager under JNDI key java:comp/BeanManager

Best practice to get EntityManagerFactory

蹲街弑〆低调 提交于 2019-11-27 06:21:11
What is the best approach to get EntityManagerFactory in web app(jsp/servlets)? Is this a good way When should EntityManagerFactory instance be created/opened? , or is it better to get it from JNDI, or something else? They're heavyweight and they're supposed to be in the application scope. So, you need to open them on application startup and close them on application shutdown. How to do that depends on your target container. Does it support EJB 3.x (Glassfish, JBoss AS, etc)? If so, then you don't need to worry about opening/closing them (neither about transactions) at all if you just do the

Spring boot JNDI datasource lookup failure - Name comp/env/jdbc not found in context “java:”

三世轮回 提交于 2019-11-27 06:14:03
问题 I have setup a spring boot (v 1.1.9) application to deploy as a WAR file. And I'm trying to integrate this web application with an existing data service module (added as a maven dependency). Environment trying to deploy: WebSphere Application Server 8.5.5.4 The issue I'm facing is an application start-up failure when try to look-up a JNDI dataSource ( jdbc/fileUploadDS ) as below within the dependent data service module. @Configuration @Profile("prod") public class JndiDataConfig implements

What does java:comp/env/ do?

痞子三分冷 提交于 2019-11-27 05:52:23
I just spent too much time of my day trying to figure out some errors when hooking up some JNDI factory bean. The problem turned out to be that instead of this... <bean id="someId" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/loc"/> </bean> I had actually written this... <bean id="someId" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="jdbc/loc"/> </bean> I infer that the java:comp/env/ perhaps references some environment variable and makes it so that, ultimately, my context file is looked

What is JNDI? What is its basic use? When is it used?

浪子不回头ぞ 提交于 2019-11-27 05:45:22
What is JNDI ? What is its basic use? When is it used? duffymo What is JNDI ? It stands for Java Naming and Directory Interface . What is its basic use? JNDI allows distributed applications to look up services in an abstract, resource-independent way. When it is used? The most common use case is to set up a database connection pool on a Java EE application server. Any application that's deployed on that server can gain access to the connections they need using the JNDI name java:comp/env/FooBarPool without having to know the details about the connection. This has several advantages: If you

What is the purpose of JNDI

て烟熏妆下的殇ゞ 提交于 2019-11-27 04:58:27
问题 How can you realize the usage of JNDI , with an example if possible? 回答1: JNDI is the Java Naming and Directory Interface. It's used to separate the concerns of the application developer and the application deployer . When you're writing an application which relies on a database, you shouldn't need to worry about the user name or password for connecting to that database. JNDI allows the developer to give a name to a database, and rely on the deployer to map that name to an actual instance of