Java中使用Jolt访问Tuxedo服务 – Tomcat环境部署测试

Java中使用Jolt访问Tuxedo服务 – Tomcat环境部署测试

最近在学习基于Tuxedo的系统架构,网上讨论最多的,比较流行的3层架构是基于Weglogic+Tuxedo+DB的模式,关于这类模式的文章也比较多,可以参见链接:

http://blog.csdn.net/liwei_cmg/article/details/769150

一般来说,Java可用使用3种联机方式访问Tuxedo的服务:

1.WTC          用于Weblogic与Tuxedo的互访,可以实现双向的调用。

2.JOLT          用于Tomcat, Weblogic, Websphere 和其他应用服务器访问Tuxedo,为单向调用。

3.CORBA        (网上有介绍,自己没实践过)

作为学习了解Java如何通过Jolt调用Tuxedo服务,以及如何使用Jolt的链接池技术,本文没有使用Weblogic作为应用服务器,而是直接在Tomcat应用服务器中配置部署了Html+ Servlet来调用Tuxedo的服务。

实现环境:

服务端:       GUN/Linux 2.6.32   +Tuxedo 11gR1

应用服务器:   Apache-tomcat-6.0.29 for Windows

开发工具:     Myeclipse 8.5

实现步骤如下:

1)准备Tuxedo服务程序

2)修改配置ubbconfig

3)修改Jolt访问服务的jrepository文件

4)启动Tuxedo服务

5)创建Web project

6)准备Servlet 和 html程序

7)准备Jolt 连接池配置文件

8)配置web.xml文件

9)部署Web项目simpapp

10)Linux服务器防火墙设置

1. 准备Tuxedo服务程序

这里我们还是用examples中的simpserv.c程序,以及TOUPPER服务,比较容易。

//simpserv.c

#include

#include

#include     /* TUXEDO Header File */

#include /* TUXEDO Header File */

#if defined(__STDC__) || defined(__cplusplus)

tpsvrinit(int argc, char *argv[])

#else

tpsvrinit(argc, argv)

int argc;

char **argv;

#endif

{

/* Some compilers warn if argc and argv aren't used. */

argc = argc;

argv = argv;

/* userlog writes to the central TUXEDO message log */

userlog("Welcome to the simple server 2");

return(0);

}

#ifdef __cplusplus

extern "C"

#endif

void

#if defined(__STDC__) || defined(__cplusplus)

TOUPPER(TPSVCINFO *rqst)

#else

TOUPPER(rqst)

TPSVCINFO *rqst;

#endif

{

int i;

for(i = 0; i < rqst->len-1; i++)

rqst->data[i] = toupper(rqst->data[i]);

/* Return the transformed buffer to the requestor. */

tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);

}

编译服务程序,

buildserver -f simpserv.c -o simpserv -s TOUPPER

2.修改配置ubbconfig, 加入如下的组和服务

*GROUPS

JSLGRP          LMID=simpapp1   GRPNO=101

JREPGRP         LMID=simpapp1   GRPNO=102

*SERVERS

JSL             SRVGRP=JSLGRP SRVID=1

CLOPT="-A -- -n //192.168.1.100:8850 -m 5 -M 5 -x 10"

JREPSVR         SRVGRP=JREPGRP SRVID=1

CLOPT="-A -- -W –P /home/tuxedo/udataobj/jolt/repository/jrepository"

JSL 为Java通过Jolt访问Tuxedo的监听服务,

//192.168.1.100:8850为Tuxedo服务器的地址和端口,在Java客户端要用。

(注意:Jolt不通过WSL来访问Tuxedo服务。)

编译ubbconfig配置文件,

tmloadcf –y ubbconfig

3.修改Jolt访问服务的jrepository文件,加入TOUPPER服务的定义如下(也可以采用RE.html配置):

add SVC/TOUPPER:vs=1:ex=1:bt=STRING:\

bp:pn=STRING:pt=string:pf=167772161:pa=rw:ep:

4.启动Tuxedo服务

服务端配置完毕。

5. 在Myeclipse下创建Web project,项目名为simpapp,位于 d:\worksapce\simpapp

创建新的 src包,  my.jolt.servlet,位于d:\worksapce\simpapp\src

6.准备Servlet 和 html程序

程序来自Tuxedo的examples,调试的时候进行了修改。

网页程序 simp.html,  d:\worksapce\simpapp\WebRoot\simp.html

Jolt SimpApp Example

Jolt SimpApp Example

This examples demonstrates how a Java HTTP Servlet running in the

Weblogic Server services a POST request from a

<FORM> in

this HTML file. The simpapp

servlet invokes a service on the BEA TUXEDO Server that converts the

text you enter here into uppercase. The result is posted back inside

a servlet-generated html file.

Type some text here and click the Post button:

Click here for session pools statistics

原程序中一行如下,调试的时候报错,删掉了。

错误如下:

严重: Servlet.service() for servlet SimpAppServlet threw exception

java.lang.NoSuchFieldError: SVCNAME

Servlet程序,SimpAppServlet.java,位于  d:\worksapce\simpapp\src\my\jolt\servlet

package my.jolt.servlet;

import bea.jolt.pool.servlet.*;

import bea.jolt.pool.ApplicationException;

import bea.jolt.pool.SessionPoolException;

import bea.jolt.pool.ServiceException;

import java.util.Properties;

import java.util.Hashtable;

import java.io.IOException;

import javax.servlet.*;

import javax.servlet.http.*;

/**

* This example demonstrates how a Servlet may connect to Tuxedo

* and call upon one of its services; it should be invoked from the

* simpapp.html file. The servlet creates a session pool

* manager at initialization, which is used to obtain a session when the

* doPost() method is invoked. This session is used to connect to a service

* in Tuxedo with a name described by the posted "SVCNAME" argument. In this

* example the service is called "TOUPPER", which transposes the posted

* "STRING" argument text into uppercase, and returns the result. This is

* returned to the client browser within some generated HTML.

* THIS IS SOURCE CODE PUBLISHED FOR DEMONSTRATION PURPOSES

*

* @author Copyright (c) 1999 BEA Systems, Inc.  All rights reserved.

*/

public class SimpAppServlet extends HttpServlet {

/**

* Private variable to hold the pool manager object.

*/

private ServletSessionPoolManager b_mgr;

/**

* Initializes the servlet.  The session pool manager and the

* simpapp session pool is established here.  The properties of

* the session pool is specified through an external property

* file whose path comes from the servlet initial parameter "properties".

*

* @param config            Servlet configuration

* @exception               ServletException if the servlet fails

*/

public void init(ServletConfig config) throws ServletException {

super.init(config);

try {

// Create a session pool and get the session pool manager through

// a property file.

String path = config.getServletContext().getRealPath("/") +

"simpapp.properties";

Properties prop = ServletPoolManagerConfig.load(path);

if (prop == null)

throw new ServletException(path + " not found");

ServletPoolManagerConfig.startup(prop);

b_mgr = ServletPoolManagerConfig.getSessionPoolManager();

}

catch (Exception e) {

throw new ServletException(e.toString());

}

}

/**

* Destroys this servlet. The ServletSessionPoolManager

* resource is deallocated.

*/

public void destroy() {

b_mgr = null;

}

/**

* Implements the HttpServlet doPost() method.

* This method expects POSTed arguments for:

*

*

"SVCNAME"The name of the service to be invoked in Tuxedo.

*

"STRING"The text to be transposed to uppercase.

*

*

*

See the provided simpapp.html for the HTML form

* used to submit the data.

*/

public void doPost(HttpServletRequest req, HttpServletResponse resp)

throws ServletException, IOException

{

ServletResult result;

ServletOutputStream out = resp.getOutputStream();

out.println("

Jolt SimpApp Example Response");

out.println("

" +

"

" +

"This is the response from the SimpAppServlet:" +

"

");

// Get the "simpapp" session pool

ServletSessionPool session = (ServletSessionPool)

b_mgr.getSessionPool("simpapp");

if (session == null) {

out.println("The servlet failed to obtain a SessionPool for simpapp. "+

"
"+

"Possibly the Tuxedo server is not running, "+

"or there is a configuration problem."+

"

");

out.close();

return;

}

//String svcnm[] = req.getParameterValues("SVCNAME");

// Invoke a service and get the result.  Process the

// template with input and result if there is no error.

try {

//result = session.call(svcnm[0], req);

Result = session.call("TOUPPER");

// No error; present the result page.

out.println("The simpapp sevice was successfully called, and "+

"responded with the output string: ");

out.println("

"+

result.getValue("STRING", "")+

"


");

}

catch (SessionPoolException e) {

// All sessions are busy.

out.println("Your request cannot be completed at this moment.\n"+

"

Diagnostic Message is: "+e.getMessage()+"

\n"+

"Possible reasons:

  • \n"+

"

No sessions are available\n"+

"

The session pool is suspended\n"+

"

The session pool is shutdown\n"+

"

Please resubmit your request later.");

}

catch (ServiceException e) {

// There is a Service Exception.

out.println("

Service exception

"

Error message:"+e.getMessage()+

"

Error number:"+e.getErrno()+

"

");

}

catch (ApplicationException e) {

// There is an application error.

result = (ServletResult) e.getResult();

out.println("

Application error

\n"+

"

Application code is "+result.getApplicationCode());

}

catch (Exception e) {

out.println("

Unexpected exception

"+

"

Exception is "+

"");

}

out.println("

java jolt tuxedo_Java中使用Jolt访问Tuxedo服务 – Tomcat环境部署测试相关推荐

  1. 在java.library.path中找不到允许在生产环境中实现最佳性能的基于APR的Apache Tom.....

    在java.library.path中找不到允许在生产环境中实现最佳性能的基于APR的Apache Tom- 2021-6-2 19:55:17 org.apache.catalina.core.Ap ...

  2. JQuery中ajax方法访问web服务

      1 $.ajax({     2    3 02    type: "POST",     4    5 03    //注明 返回Json     6    7 04     ...

  3. java jolt tuxedo_Java通过Jolt调用Tuxedo服务

    Java通过Jolt调用Tuxedo服务 一.简介 ------------------------ 外部应用访问Tuxedo服务是很经常的事,一般有两种方法WTC和Jolt,网上很多关于Jolt调用 ...

  4. java jolt调用tuxedo_Java通过Jolt调用Tuxedo服务 zz

    http://blog.csdn.net/liwei_cmg/archive/2006/06/02/769150.aspx http://blog.csdn.net/liwei_cmg/archive ...

  5. java jolt tuxedo_Java 通过Jolt与Tuxedo连接 (1)

    一.简介 ------------------------ 外部应用访问Tuxedo服务是很经常的事,一般有两种方法WTC和Jolt,网上很多关于Jolt调用Tuxedo服务 文章,描述的太多笼统,其 ...

  6. Java通过Jolt调用Tuxedo服务

    Java通过Jolt调用Tuxedo服务 草木瓜 2006-6-1 ------------------------ 一.简介 ------------------------ 外部应用访问Tuxed ...

  7. 如何在ORACLE CLOUD中创建和访问容器集群丨内附官方文档链接

    墨墨导读:本文描述如何在Oracle Cloud中创建并访问容器服务.为了简单,所有的操作都是针对root隔离区. 创建允许容器运行的政策官方文档链接 这一步是必须的,否则可以增加容器容器. 官方文档 ...

  8. 读取项目的根目录 部署tomcat后_tomcat配置根目录访问后,部署后第一次访问会出现tomcat的默认界面而非项目首页...

    tomcat配置根目录访问后,部署后第一次访问会出现tomcat的默认界面而非项目首页,而重启后会正常,这个原因是因为在配置文件中有如下配置,造成项目加载两次 unpackWARs="tru ...

  9. 悟空crm环境部署-Java的war包方式

    适用场景 本文档适用于所有war包与Tomcat环境部署 1. 文件准备 新建一个属于自己的文件夹,并将apache-tomcat-8.5.39.tar和ROOT.war复制到这个文件夹里 说明 (1 ...

最新文章

  1. Creating a LINQ Enabled ASP.NET Web application template using C#.[转]
  2. python语言入门m-Python -m参数原理及使用方法解析
  3. python3精要(3)-python对象类型,数字,序列
  4. MemSQL初体验 - (2)初始化测试环境
  5. JDK1.6历史版本的下载
  6. scala hashmap_如何在Scala中将Hashmap转换为Map?
  7. 初学者指南:服务器基本技术名词
  8. java 选中指定文件_Java如何打开一个文件夹并选中指定文件
  9. [导入] 用java把页面日期控件写出来
  10. Flink时间属性和窗口
  11. 侯捷 C++11/14 笔记
  12. 使用Python调整图片尺寸(大小)
  13. 如何添加计算机硬盘分区,怎么给电脑硬盘增加设置分区
  14. linux who命令功能,Linux who命令详解
  15. VC中CList用法
  16. 编译原理课堂笔记(1)编译概述
  17. 【数字设计】联发科技_笔试面试题目分享
  18. CNN经典算法GoogleNet介绍(论文详细解读)
  19. matlab:寻找峰值(波峰,波谷)
  20. realsense相机内参如何获得+python pipeline+如何通过python script获取realsense相机内参(windows下可用)

热门文章

  1. linux无线wps连接wifi,通过Wi-Fi保护的设置(WPS)设置无线连接在RV系列路由器
  2. Android 开发文档doc下载 ,怎么找到它
  3. SpringBoot电脑商城-购物车
  4. mysql数据库表设计理论原则实践
  5. Java编程那些事儿103——网络编程技术2
  6. PX4中文维基——光流部分
  7. 设计模式之禅-命令模式
  8. Ubuntu18.04登录输密码时出现“抱歉,登录失败,请再试一次”解决方法
  9. 字幕编辑软件 SrtEdit 2012
  10. 2014年什么行业是最赚钱的