-
1. Re: Override JNDI names in persistence.xml and @resource annotation
ksreen Oct 27, 2014 1:17 AM (in response to paul.holding)Try this:
In the Jboss configuration file (standalone.xml or domain.xml) , define another mail session as follows.
<mail-session jndi-name="mail/myMailSession">
<smtp-server outbound-socket-binding-ref="mail-smtp"/>
</mail-session>
Refer to it in your code as @Resource(mappedName= "mail/myMailSession")
-
2. Re: Override JNDI names in persistence.xml and @resource annotation
emmartins Oct 28, 2014 10:02 AM (in response to paul.holding)Add a jboss xml descriptor to bind the resource in the expected JNDI name, e.g. for an EJB you would add a jboss-ejb3.xml to the EJB jar:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.1" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
<enterprise-beans>
<session>
<ejb-name>YourBeanNameHere</ejb-name>
<resource-ref>
<res-ref-name>mail/myMailSession</res-ref-name>
<lookup-name>java:mail/myMailSession</lookup-name>
</resource-ref>
</session>
</enterprise-beans>
</ejb-jar>