Recipe 25.4 Configuring a JNDI Resource in WebLogic


Problem

You want to bind an object to BEA WebLogic's JNDI implementation.

Solution

Use the WebLogic Administration console.

Discussion

Here are the steps needed to bind a javax.mail.Session object (which I use as an example for this recipe) to WebLogic's JNDI implementation. The advantage of this approach is that the available Session is already configured with elements such as its SMTP host (see Table 25-1). The Session is "ready to go" for the code that will eventually look up and use the object.

  1. Log in to the WebLogic Administration console, which involves using a browser URL such as http://localhost:7001/console .

  2. Go to Your-domain- name Services Mail in the lefthand column menu.

  3. Click on "Configure a new Mail Session . . . " This produces the window shown in Figure 25-4.

Figure 25-4. Configuring a javax.mail.Session type as a JNDI object using the WebLogic Administration console
figs/jsjc_2504.gif
  1. Fill in the text fields in the resulting window. Give the Session object a JNDI name (under "JndiName"), which is the name that the code uses to look up the object.

  2. Enter any properties for the Session by typing in the property name, an equals sign (=), and the property value. See Table 25-1.

  3. Click the "Apply" button, then choose the "Targets" tab. The resulting screen allows you to associate the JNDI object with one or more servers.

Now the JNDI object is available to Java programs using the JNDI API and the name you bound the object under. Recipe 25.5 shows how to view the JNDI tree graphically to verify that the object has been bound properly.

Table 25-1. JavaMail properties set for this recipe's Session JNDI object

Property name

Description

Example

mail.host

The default mail server

mail.comcast.net

mail.smtp.host

Protocol-specific mail host; defaults to mail.host value

mail.comcast.net

mail. user

The username for connecting to the mail server

bruceperry

mail.from

The return address to use when sending mail.

author@jspservletcookbook.com

See Also

Recipe 25.6 on accessing a JNDI object with a servlet on WebLogic; Recipe 25.7 on accessing a JNDI object with a JSP on WebLogic; Chapter 2 on on accessing a JNDI object with a JSP on WebLogic; Chapter 2 on deploying web components with WebLogic.



Java Servlet & JSP Cookbook
Java Servlet & JSP Cookbook
ISBN: 0596005725
EAN: 2147483647
Year: 2004
Pages: 326

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net