On Mon, 09 Mar 2015 08:59:33 +0000, Mark Thomas wrote:

> On 09/03/2015 03:59, Thusitha Thilina Dayaratne wrote:
>> Hi,
>> 
>> I want to access the JNDI Directory context in Tomcat8. I've used
>> *DirContextURLStreamHandler* class which was in Tomcat 7. But now that
>> has been removed.
>> Can someone tell me how can I access the JNDI Directory Context in
>> Tomcat 8?
> 
> Via the standard JNDI API.
> 
> Mark



Can you elaborate a little?  For this example:


public static void main(String[] args) {
    try {
        // Gets the JNDI context
        Context jndiContext = new InitialContext();
        // Looks up the administered objects
        ConnectionFactory connectionFactory = (ConnectionFactory)
                jndiContext.lookup("jms/javaee7/ConnectionFactory");
        Destination queue = (Destination) jndiContext.lookup("jms/javaee7/
Queue");
        // Sends a text message to the queue
        try (JMSContext context = connectionFactory.createContext()) {
            context.createProducer().send(queue, "Text message sent at " 
+ new Date());
        }
    } catch (NamingException e) {
        e.printStackTrace();
    }
}

http://stackoverflow.com/questions/23037845/



how can that be modified to load the jndi.properties file?


thanks,

Thufir


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to