How To Install Oracle Weblogic Server In Eclipse
Oracle Coherence and Oracle WebLogic Server: Setting Up an Eclipse Development Environment
This tutorial shows you how to configure an Eclipse-based development environment to develop Web and enterprise applications for Oracle WebLogic Server that use the Oracle Coherence data caching system.
Approximately 1 hour
This tutorial covers the following topics:
Overview | ||
Scenario | ||
Prerequisites | ||
Configuring the Products and Environment | ||
Creating the Eclipse Project | ||
Coding the SimpleCacheServlet | ||
Deploying to Oracle WebLogic Server and Testing | ||
Configuring the Coherence Node Settings | ||
Summary | ||
Related Information | ||
Where to Go from Here |
Place the cursor over this icon to load and view all the screenshots for this tutorial. (Caution: This action loads all screenshots simultaneously, so the response time may be slow depending on your Internet connection.)
Note: Alternatively, you can place the cursor over each individual icon in the following steps to load and view only the screenshot associated with that step.
This tutorial walks you through the setup required to create Java enterprise (Web) applications that run on Oracle WebLogic Server, use Oracle Coherence, and are developed by using Eclipse.
Oracle Coherence is a component of Oracle Fusion Middleware that enables organizations to predictably scale mission-critical applications by providing fast and reliable access to frequently used data. By automatically and dynamically partitioning data in memory across multiple servers, Oracle Coherence enables continuous data availability and transactional integrity, even in the event of a server failure. As a shared infrastructure, Oracle Coherence combines keeping data local with the local processing power to perform real-time data analysis, in-memory grid computations, and parallel transaction and event processing. Oracle Coherence comes in three editions: Java Edition, C++ Edition, and .NET Edition. This tutorial covers the Java Edition.
Oracle WebLogic Server 10g is the world's best application server for building and running enterprise applications and services. It fully implements the latest Java EE standards and offers choice in development frameworks and integral tooling. Comprehensive and accessible management capabilities enable administration of sophisticated systems via a well-designed graphical console and/or automation. All users benefit from Oracle WebLogic Server's reliability and performance, which has been tested over years of enterprise-grade production use in demanding customer environments the world over.
The steps in this tutorial will take you from the product prerequisites to the basic setup that is required to code, deploy, and test a Web application that uses Oracle Coherence.
Back to Topic List
You can use Oracle Coherence with applications that run on Oracle WebLogic Server in the following ways:
- Direct application interaction with Coherence
- Application server–level (Session) access to Coherence
This OBE covers the basic setup and a very high-level example of the first way. By simply adding a .jar file (Java library) to your application or application server classpath, and with a few lines of code, your application can cache information that can be accessed by other applications in such a way that is fault tolerant and scalable, all without needing the extra overhead and infrastructure of relational databases, persistence (such as JPA, EJB, Hibernate, and so on), or Object Relationship Management (ORM) facilities. Instead, you can use simple Plain Old Java Objects (POJOs), which can be handled by servlets or JSPs on WebLogic Server.
Back to Topic List
All the software for this tutorial can be freely downloaded. This tutorial was developed using Microsoft Windows XP SP2, but these instructions can be modified to work on Linux as well if you have the requisite knowledge of the differences between the two operating systems.
Before starting this tutorial, you should:
1. | Have access to or have installed the following software:
Additionally, you need the Oracle Enterprise Pack for Eclipse (OEPE), which is a free set of plug-ins and extensions that will make developing for and deploying to Oracle WebLogic Server easier and smoother. The OEPE can be installed using Eclipse's Software Update function and is detailed in the section of this tutorial titled "Install Oracle Enterprise Pack for Eclipse." Oracle WebLogic Server installs a Java 1.6 JDK, which is required for running the server and other products. After the products are installed, ensure that it is the WebLogic-supplied JDK that you are using by setting your system's path environment settings appropriately. Although you can install the products in locations of your choice, the following generic labels refer to these locations in the tutorial instructions.
|
2. | Refer to the following documentation:
|
3. | Download the tutorial source code for reference. |
Back to Topic List
This section assumes that you have:
- Installed all the required products (Oracle Coherence, Oracle WebLogic Server, and Eclipse 3.4)
- Verified that Oracle Coherence works according to the Coherence installation or verified the instructions that were linked in the previous section
In this topic, you create a WebLogic Server domain, choose the basic Eclipse workspace, and install the Oracle Enterprise Pack for Eclipse.
Back to Topic List
To create the WebLogic Server domain, perform the following steps:
1. | Read the following documentation on creating an Oracle WebLogic Server domain with the Domain Configuration Wizard: http://download-llnw.oracle.com/docs/cd/E12840_01/common/docs103/confgwiz/index.html |
2. | Open the WebLogic Domain Configuration Wizard by selecting Start > All Programs > Oracle WebLogic > WebLogic Server 10gR3 > Tools > Configuration Wizard.
|
3. | Select the Create a new WebLogic Server domain option and click Next. |
4. | Create a domain based on WebLogic Server. (Accept the default that is presented.) Click Next. |
5. | Enter the login credentials to be used. Enter weblogic as the username and password. |
6. | Accept the defaults for Development Mode and the JDK (Sun SDK 1.6), and click Next. |
7. | Select No for any further changes. Click Next. |
8. | Name the domain WLS_A. Choose the location, and then click Create to generate the domain. |
9. | When finished, make sure that Start Admin Server is deselected and click Done. |
Back to Topic
Back to Topic List
To choose the Eclipse workspace location, perform the following steps:
1. | Launch Eclipse. |
2. | You will be presented with the Eclipse Workspace Launcher. Choose a location for your workspace. (For example, use D:\oracle\tutorial. This location will be referred to as $WORKSPACE from this point forward.) Click OK. |
Back to Topic
Back to Topic List
To install the Oracle Enterprise Pack for Eclipse, perform the following steps:
1. | With your Eclipse workspace open, close the Welcome screen that is displayed. |
2. | Access the Eclipse Software Update function. From the Help menu, select Software Updates. |
3. | Click the Available Software tab, and then click Add Site. |
4. | Enter the following URL: http://download.oracle.com/otn_software/oepe/ganymede. Click OK. Note: You can find more information about the Oracle Enterprise Pack for Eclipse here. |
5. | Expand the new site that you just added and select the check box for Oracle Enterprise Pack for Eclipse. Confirm that all the subcomponents are selected and click Install. |
6. | Click Next on the Install screen. |
7. | Accept the license terms and click Finish on the Review Licenses screen. |
8. | After the installation, you see a dialog box to finalize the process. Click Yes to restart Eclipse. When prompted, open your tutorial workspace again. |
Back to Topic
Back to Topic List
In this topic, you create the Coherence-enabled Web project in Eclipse.
Back to Topic List
To create a new Coherence-enabled Web application project, perform the following steps:
1. | Select File > New > Dynamic Web Project.
|
2. | Name the project SimpleCacheApp and click the New button for Target Runtime. |
3. | Select Oracle > Oracle WebLogic Server 10gR3 as the type and click Next. |
4. | Browse to the WebLogic Server home ($MIDDLEWARE_HOME\wlserver_10.3) and click Finish. |
5. | The Dynamic Runtime Module version automatically updates to 2.5 and the Configuration is set to Default Configuration for Oracle WebLogic Server 10gR3. No further configuration is needed. Click Finish. |
Back to Topic
Back to Topic List
To add the libraries that are necessary for your application to use Coherence, perform the following steps:
1. | Right-click SimpleCacheApp in the Project Explorer and select Properties. |
2. | Go to the Java Build Path category and click the Libraries tab. Click Add Library. |
3. | Select User Library and click Next. |
4. | Click the User Libraries button. Next click the New button in User Libraries. |
5. | Name the library Coherence , and then click OK. |
6. | Click the Add JARs button. Browse to the $COHERENCE_HOME/lib folder. Select the coherence.jar file and click Open. |
7. | Click OK, Finish, and then OK again. The Coherence library is added to the project. |
8. | You can add Coherence libraries in the following ways:
Copy the coherence.jar file from the $COHERENCE_HOME/lib folder to the $DOMAIN_HOME/WLS_A/lib folder. Note: Any JAR files added to the domain's lib folder are automatically added to that domain's classpath and should be accessible to any applications deployed in that domain. |
Back to Topic
Back to Topic List
To add the server configuration to Eclipse so that you can deploy the application directly, perform the following steps:
1. | Select the Servers view in the bottom pane of the Eclipse window. Right-click inside the view and select New > Server. |
2. | Accept the defaults for the server host name (localhost), the server type (Oracle WebLogic Server 10gR3), and Server Runtime. Change Server Name to Oracle WebLogic Server A. Click Next. |
3. | Change the name again to Oracle WebLogic Server A, and browse to the domain directory that you created ($DOMAIN_HOME/WLS_A). Click Finish. |
4. | Start your domain by using the startWebLogic.cmd script found in the $DOMAIN_HOME/WLS_A directory. Verify that after the server is up and running. Eclipse reports the server state as Started. |
Eclipse is now configured to be able to deploy projects to the Oracle WebLogic Server. In a subsequent step, you add the project to the server configuration and the Oracle Enterprise Pack for Eclipse deploys it for you. |
Back to Topic
Back to Topic List
In this topic, you create a simple HttpServlet that connects to and exchanges data with the Coherence cache server. This code provides an example of application-level interaction with Oracle Coherence.
Back to Topic List
To create a simple HttpServlet that uses Coherence, perform the following steps:
1. | Expand SimpleCacheApp in the Project Explorer. Right-click the Java Resources node and select New > Servlet. |
2. | Set the package to obe.coherence and name the class SimpleCacheTest1 . Click Next. |
3. | Accept the default values for Initialization Parameters and URL Mappings and click Next. |
4. | Deselect doPost, but keep all other defaults selected. Click Finish. |
5. | Code the doGet() method to do the following:
|
6. | Connect to the Coherence cache by using the following code: CacheFactory.ensureCluster(); When you add this code, CacheFactory initially has a red underline because the CacheFactory class must be imported. Because there is only one CacheFactory in the classpath (com.tangosol.net.CacheFactory, which comes from coherence.jar), it is automatically imported. Additionally, when you enter "." after the CacheFactory declaration, Eclipse opens a code completion box that shows you all the methods that are available for the class. |
7. | Now connect to the cache called mycache using CacheFactory . NamedCache cache = CacheFactory.getCache("mycache"); This time, because there are several possibilities for NamedCache, it is not automatically imported. Click the Red X symbol in the left margin and select Import 'NamedCache' (com.tangosol.net). This import is now added at the top of the source code. |
8. | Now retrieve a value from the cache that can be found with a key of "greeting" and store it as a String. String cachedValue = (String) cache.get("greeting"); Note: For objects to be cached, they must be serializable, and String automatically implements Serializable. |
9. | Output this value to the server console and the browser by using the following code. // Output this value to the server console System.out.println("Value retrieved from cache: " + cachedValue); // Output this value to the browser that called this servlet. response.setContentType("text/html; charset=ISO-8859-1"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head><title>SimpleCacheTest</title></head>"); out.println("<body>"); out.println("<p><br>The value from the Coherence Cache is : " + cachedValue + "</p>"); out.println("</body></html>"); out.close(); Import any classes that are required by using the same procedure from step 7. |
10. | Save your code. |
Back to Topic
Back to Topic List
Now that the code is complete, you can test it by deploying it to your WebLogic Server domain.
To test your servlet or Coherence code, perform the following steps:
1. | Ensure that there are no errors in your code. (Look for any red marks in the source view margins.) |
2. | If they are not already running, start an instance of the Coherence cache server, an instance of the Coherence shell client, and your WebLogic Server Domain. Ensure that they start without any issues. To start the Coherence cache server, run: $COHERENCE_HOME/bin/cache-server.cmd. To start the Coherence shell client, run: $COHERENCE_HOME/bin/coherence.cmd. To start the WebLogic Server Domain, run: $DOMAIN_HOME/WLS_A/startWebLogic.cmd. |
3. | From the Coherence shell client, connect to the "mycache" cache. Map (?): cache mycache You should see the XML schema for this cache displayed in the client. You should also see a brief burst of activity in the Coherence Shell window. |
4. | Enter a value in the cache. Using the Coherence shell client, create a value with a key of greeting and a value of hello . Map (mycache): put greeting hello The client should return a response of null. |
5. | Deploy your project to the WebLogic Server. Right-click the Oracle WebLogic Server entry in the Servers view in Eclipse and select Add and Remove Projects. |
6. | Add SimpleCacheApp to Configured projects and click Finish. Eclipse deploys the application to the WebLogic Server. Ensure that the status for the Server entry shows "Synchronized" and that there are no errors reported in the WebLogic Server console window. |
7. | Right-click SimpleCacheTest1 in the Project Explorer (under SimpleCacheApp\Java Resources\src\obe.coherence) and select Run As > Run on Server. |
8. | In the Run On Server dialog box, click Finish. While the servlet is loaded and the Eclipse test browser is invoked to access it, the doGet() method is called and the servlet connects to the Coherence cache (because you see Coherence-related information in the WebLogic Server window as well as activity in the Coherence cache server window). Both the WLS window and the Eclipse test browser should show the value that you entered via the Coherence shell client. |
9. | Change the value using the Coherence client shell. put greeting howdy Rerun the servlet by clicking the Refresh icon in the Eclipse test browser. The updated value should be immediately shown in the test browser. |
10. | Bonus Challenge: Update the servlet to update the value for the greeting after the original value has been retrieved and displayed. How would you accomplish this? (Hint: What command do you use in the Coherence client? Is there a similar method available to the NamedCache object?) After you make a change, note that the Status for the Server entry in Eclipse has changed to Republish. This means that your code and the deployed application are out of sync and the server is not running the latest version of the application. Right-click the server entry and select Publish again. After the status says Synchronized, make sure that there is a value in the cache using the Coherence client (set the greeting value to hello again), and then test the servlet again using the Eclipse test browser. Note that the value you set with the client is shown in the browser and the WebLogic Server window as before. Use the client to check what value is currently in the cache. Map (mycache): list The value returned should be the same as the cache.put() value that you added to the servlet code. Try refreshing the Eclipse test browser right now. What value does it show? Click here to see the solution code for this if you need help. |
Back to Topic
Back to Topic List
Oracle Coherence uses a peer-to-peer architecture with no masters or slaves. By default, when a node connects to the Coherence grid, it becomes part of the grid as one of the cache servers, not just a client or consumer. There are advantages and disadvantages to this scenario. The advantages are that data in the cache (particularly in replicated models) is now "local" to the application server and no network traffic is needed for the application to retrieve the data after it is replicated. The disadvantage is that this is an additional process and a memory overhead for the application server JVM and hardware, which may be undesirable.
By setting the "local-storage" of a node to "false," that node becomes a consumer only (just a client). This is done by passing a command-line argument to the Coherence node. But if it is an application running on a Java application server that is the node, you add the needed argument, -Dtangosol.coherence.distributed.localstorage=false to the Java parameters that are being passed during the WebLogic Server startup.
Background on the scripts that start a WebLogic Server domain:
If you look at your domain directory ($DOMAIN_HOME/WLS_A) closely you may notice that there are two startWebLogic.cmd scripts: One in the domain's root folder, and one in the bin folder. Here is an explanation of how they work:
Script | Description |
---|---|
DOMAIN_HOME/startWebLogic.cmd | Convenience script that calls the startWebLogic.cmd script in the bin folder |
DOMAIN_HOME/bin/startWebLogic.cmd | Script that calls setDomainEnv.cmd to set the WebLogic Server environment, and performs the actual startup of the server |
DOMAIN_HOME/bin/setDomainEnv.cmd | Script that sets the environment for starting the WebLogic Servers for this domain. This is called by DOMAIN_HOME/bin/startWebLogic.cmd. You can set Coherence configuration arguments through Java properties in this file. |
To configure the Coherence node spawned by the WebLogic Server, perform the following steps:
1. | Open $DOMAIN_HOME/WLS_A/bin/setDomainEnv.cmd in a text editor. Look for a line in the setDomainEnv.cmd file similar to the following line (approximately line 258): set JAVA_PROPERTIES=%JAVA_PROPERTIES% %WLP_JAVA_PROPERTIES% |
2. | Above it, add the following lines: @REM ADDING COHERENCE SETTINGS set COHERENCE_PROPERTIES=-Dtangosol.coherence.distributed.localstorage=false |
3. | Modify the JAVA_PROPERTIES line that you identified in step 1 to include the new environment variable that you created. set JAVA_PROPERTIES=%COHERENCE_PROPERTIES% %JAVA_PROPERTIES% %WLP_JAVA_PROPERTIES% |
4. | Start (or restart) your WebLogic Server domain and shut down any running Coherence cache server and Coherence shell client instances. Redeploy the test application and test the servlet again as you did in the previous section. What result do you get this time? If the Coherence cache server is shut down, the test should fail with a "storage not configured" exception. This is because you have configured the WebLogic Server domain to act only as a client node and it cannot provide caching services to the application. |
5. | Start up the Coherence cache server again as well as the Coherence client shell, and retest the application as you did in the previous section. (Remember to add a value with the Coherence shell client first). Does it work now? There are additional Coherence configuration settings that can be made via command-line arguments, such as overriding the cache configuration settings. |
Back to Topic
Back to Topic List
In this lesson, you learned how to:
Create and configure a domain that can host applications that use Oracle Coherence | ||
Set up an Eclipse development environment to deploy to the Oracle WebLogic Server and create applications that use Oracle Coherence | ||
Create a Web application project and code a servlet that connects to and shares data with an Oracle Coherence Data Cache | ||
Deploy and test a Coherence application from Eclipse to the Oracle WebLogic Server | ||
Configure the Coherence Node Settings from the Application Server Node |
Back to Topic List
To learn more about Oracle Coherence, you can refer to:
Oracle Coherence on OTN | ||
Oracle Coherence 3.4x Documentation | ||
Oracle Coherence Knowledge Base Dashboard | ||
Oracle Coherence Incubator | ||
Oracle Coherence OBE section on the OTN Web site |
Back to Topic List
This tutorial has given you the basic environment settings needed to use Coherence in an application-level context for a Web or an enterprise application running on a Java application server. Refer to the Coherence tutorials listed in the Oracle Coherence Documentation and try to apply them to a Web application through what you have learned in this tutorial.
Back to Topic List
Place the cursor over this icon to hide all screenshots.
How To Install Oracle Weblogic Server In Eclipse
Source: https://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/coherence/obe34coherence_wls/coherence_wls_eclipse_setup/coherence_wls_eclipse_setup.htm
Posted by: saxtononsgived.blogspot.com
0 Response to "How To Install Oracle Weblogic Server In Eclipse"
Post a Comment