|
WebLogic Server 6.1 Code Examples, BEA Systems, Inc. | |||||
See:
Description
| Interface Summary | |
| Trader | The methods in this interface are the public face of TraderBean. |
| TraderHome | This interface is the home interface for the TraderBean.java, which in WebLogic is implemented by the code-generated container class TraderBeanC. |
| Class Summary | |
| InteropServlet | Call this servlet using an URL such as |
| TraderBean | TraderBean is a stateless Session Bean. |
| TradeResult | This class reflects the results of a buy/sell transaction. |
This example illustrates interoperability between WebLogic 5.1 and WebLogic 6.1 Servers.
examples/iiop/wls2wls.
The WebLogic 6.1 files are in your WebLogic 6.1 home directory under samples/examples/iiop/wls2wls. Interoperability
between 5.1 and 6.1 WebLogic Servers requires Service Packs 11 and 2 respectively. This example has two parts:
See our Interoperability Guide for further information and posting on interoperability between 5.1 and 6.1 WebLogic Servers. As you go through the example, the following are the key points to notice:
-clientJar ejbc option run on the EJB) which contains certain bean classes and must be referenced by the 5.1 Server
in the CLASSPATH.
weblogic.properties file.
setEnv script provided in the WebLogic 5.1 home directory.
WL_HOME/examples/iiop/wls2wls directory there is a build script called
build_client.cmd.
Edit this file changing the following JAVA_HOME and WL_HOME to respectively match the location of your 1.3.1 JDK and
WebLogic 5.1 home directory:
JAVA_HOME=c:\jdk1.3.1_home
if "" == "%WL_HOME%" set WL_HOME=c:\WL_HOME
c:/WL_HOME/examples/iiop/wls2wls>build_client.cmd
weblogic.properties file, register the servlet that was just built with the following line:
weblogic.httpd.register.InteropServlet=examples.iiop.wls2wls.InteropServlet
Note: If you had previously run the example in the other direction (Calling a 5.1 Server from a 6.1 Server) make sure that you have undeployed the 5.1 EJB used in that example. You can do this by simply adding a # character in front of the EJB in your properties file. This comments the line with the EJB out--preventing it from being deployed.
weblogic.properties file to register the same credentials in your 5.1 WebLogic Server:
weblogic.password.iiop=password
iiop_wlsw2wls_client.jar that
was created in your WebLogic CLASSPATH for the WebLogic 5.1 Server. Do so by adding the
following to your WebLogic 5.1 startup script at the end of the WEBLOGIC_CLASSPATH:
;.\myserver\clientclasses\iiop_wls2wls_client.jar
setExamplesEnv script in your WebLogic 6.1
WL_HOME/config/examples directory.
WL_HOME/samples/examples/iiop/wls2wls>ant -f build_ejb.xml
http://5.1server_machinename:5.1server_port/InteropServlet?hostname=6.1server_machinename&port=6.1server_port
In other words, if your WebLogic 5.1 server and servlet is running on gotham:7001 and your WebLogic 6.1 is on brooklyn:7003, your URL would look like the following:
http://gotham:7001//InteropServlet?hostname=brooklyn&port=7003
From the servlet:
WebLogic 5.1 <-> 6.1 Interoperability Beginning examples.iiop.wls2wls example... Looking up TraderHome on iiop://brooklyn:7003... Got TraderBean. Performing stock transactions... Buying shares... Selling shares... Removing TraderBean... Done. From the WebLogic 5.1 Server: init Buying 100 shares of BEAS. Buying 200 shares of MSFT. Buying 300 shares of AMZN. Buying 400 shares of HWP. Selling 100 shares of BEAS. Selling 200 shares of MSFT. Selling 300 shares of AMZN. Selling 400 shares of HWP. Removing the trader From the WebLogic 6.1 Server: setSessionContext called ejbCreate called Buying 100 shares of BEAS Buying 200 shares of MSFT Buying 300 shares of AMZN Buying 400 shares of HWP Selling 100 shares of BEAS Selling 200 shares of MSFT Selling 300 shares of AMZN Selling 400 shares of HWP
Beginning examples.iiop.wls2wls example...
Looking up TraderHome on iiop://<hostname>:<port>...
Error occurred while looking up TraderHome.
If you see the following:
Beginning examples.iiop.wls2wls example...
Looking up TraderHome on iiop://<hostname>:<port>...
Error occurred while trying to get the InitialContext.
Error occurred while looking up TraderHome.
Read more about interoperability at, WebLogic Server 5.1 and WebLogic Server 6.1 Interoperability Guide.
Read more about RMI-IIOP at, WebLogic Server 6.1 RMI-IIOP Guide.
See our Interoperability Guide for further information and new postings on interoperability between 5.1 and 6.1 WebLogic Servers. As you go through the example, the following are the key points to notice.
build_client.xml script builds a client jar from these classes
(adding <ejb-client-jar>iiop_wls2wls_client.jar</ejb-client-jar>
to your ejb-jar.xml causes this jar file for the client to be created). This jar must be referenced by the 6.1 WebLogic Server
in the CLASSPATH.
setExamplesEnv script provided in your WebLogic 6.1 WL_HOME/config/examples directory.
WL_HOME/examples/iiop/wls2wls>ant -f build_client.xml
web.xml file which configures your servlet and the examples web application is located in
the C:\WL_HOME\config\examples\applications\examplesWebApp\WEB-INF directory.
In your web.xml file, add the following lines to configure the URL and location of the servlet:
:
<servlet>
<servlet-name>InteropServlet</servlet-name>
<servlet-class>examples.iiop.wls2wls.InteropServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>InteropServlet</servlet-name>
<url-pattern>/InteropServlet/*</url-pattern>
</servlet-mapping>
</code>
;.\config\examples\clientclasses\iiop_wls2wls_client.jar
iiop with the password: password.
The changes you have made must be saved to the realm implementation.
Click on this link in order to save the new user and have this change be a part of your running 6.1 WebLogic Server.
setEnv script provided in the WebLogic 5.1 home directory.
WL_HOME/examples/iiop/wls2wls directory there is a build script called
build_ejb.cmd. Edit the first lines of this file to make sure that your JAVA_HOME points to your JDK 1.3.1
installation and that your WL_HOME point to the home directory of your WebLogic 5.1 installation.
For example, you may change it to look like the following: set JAVA_HOME=c:\jdk1.3.1
set WL_HOME=c:\weblogic
WL_HOME/examples/iiop/wls2wls>build_ejb.cmd
weblogic.properties file to have the bean deployed. You must add the path to the EJB
jar file to the weblogic.ejb.deploy section of the properties file. For example:
weblogic.ejb.deploy=
c:/weblogic/myserver/iiop_wls2wls.jar
http://6.1server_machinename:6.1server_port/InteropServlet?hostname=5.1server_machinename&port=
5.1server_port
In other words, if your WebLogic 6.1 server and servlet is running on bronx:7006 and your WebLogic 6.1 is on flatbush:7008, your URL would look like the following:
http://bronx:7006/examplesWebApp/InteropServlet?hostname=flatbush&port=7008
From the servlet:
Beginning examples.iiop.wls2wls example... Looking up TraderHome on iiop://bronx:7006... Got TraderBean. Performing stock transactions... Buying shares... Selling shares... Removing TraderBean... Done.From the 6.1 server:
init Buying 100 shares of BEAS. Buying 200 shares of MSFT. Buying 300 shares of AMZN. Buying 400 shares of HWP. Selling 100 shares of BEAS. Selling 200 shares of MSFT. Selling 300 shares of AMZN. Selling 400 shares of HWP. Removing the traderFrom the 5.1 server:
setSessionContext called ejbCreate called Buying 100 shares of BEAS Buying 200 shares of MSFT Buying 300 shares of AMZN Buying 400 shares of HWP Selling 100 shares of BEAS Selling 200 shares of MSFT Selling 300 shares of AMZN Selling 400 shares of HWP
Beginning examples.iiop.wls2wls example...
Looking up TraderHome on iiop://<hostname>:<port>...
Error occurred while looking up TraderHome.
If you see this error:
If you see the following message:
Beginning examples.iiop.wls2wls example...
Looking up TraderHome on iiop://<hostname>:<port>...
Error occurred while trying to get the InitialContext.
Error occurred while looking up TraderHome.
Read more about interoperability at, WebLogic Server 5.1 and WebLogic Server 6.1 Interoperability Guide.
Read more about RMI-IIOP at, WebLogic Server 6.1 RMI-IIOP Guide.
|
Documentation is available at http://e-docs.bea.com/wls/docs61 |
|||||