javaee


javaee and spring and websphere11 二 2010 01:52 下午

环境
IBMWAS6.1.0.29
spring2.5.6
hibernate3.3.1GA
jconn3驱动
Sybase15

java.sql.SQLException: JZ0PA: The query has been cancelled and the response discarded. The cancel was probably issued by another statement on the connection.
java.sql.SQLException: JZ0PA: 已取消查询,响应被放弃。取消指令可能由连接上的另一语句发出。
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.getUpdateCount(Unknown Source)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.closeWrapper(WSJdbcPreparedStatement.java:445)
at com.ibm.ws.rsadapter.jdbc.WSJdbcObject.close(WSJdbcObject.java:185)
at com.ibm.ws.rsadapter.jdbc.WSJdbcObject.close(WSJdbcObject.java:144)
at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:563)
at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:291)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:307)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:234)
at org.hibernate.loader.Loader.doQuery(Loader.java:749)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)
at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

原因是由于刚更新了WAS6.1.0.29,回滚到WAS6.1.0.21,问题消失。29解决办法还未找到。

javaee and spring05 二 2010 11:10 上午

<bean id=”myMessageSource” class=”org.springframework.context.support.ResourceBundleMessageSource”>
<property name=”basenames”>
<list><value>mymessage</value></list>
</property>
</bean>

默认
mymessage.properties
中文
mymessage_zh_CN.properties
英文
mymessage_en_US.properties

首先要把中文的配置给native2ascii化
使用sunjdk的native2ascii
native2ascii mymessage.properties mymessage_zh_CN.properties
执行后发现是乱码,由于我的编译环境是utf-8,加传一个encoding参数如下
native2ascii -encoding UTF-8 mymessage.properties mymessage_zh_CN.properties
乱码没了

javaee and spring01 二 2010 10:58 上午

使用场景
spring2.5.6
hibernate3.3.1GA
Sybase15
jconn3驱动
使用spring的jdbctemplate调用Sybase15的存储过程报错
ERROR: ConnectionCallback; uncategorized SQLException for SQL []; SQL state [ZZZZZ]; error code [7713]; Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.;
nested exception is com.sybase.jdbc3.jdbc.SybSQLException: Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.
org.springframework.jdbc.UncategorizedSQLException: ConnectionCallback; uncategorized SQLException for SQL []; SQL state [ZZZZZ]; error code [7713]; Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.;
nested exception is com.sybase.jdbc3.jdbc.SybSQLException: Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:349)
Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.
at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.executeLoop(Unknown Source)
at com.sybase.jdbc3.jdbc.SybCallableStatement.execute(Unknown Source)
at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:70)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:342)
… 48 more

解决办法
1)在调用存储过程的代码
conn.setAutoCommit(true);//SET CHAINED OFF
CallableStatement cstmt = conn.prepareCall(“{call proc_xxx(?) }”);
//
conn.setAutoCommit(false);//SET CHAINED ON
2)或者在数据库中执行如下sql语句
sp_procxmode proc_xxx, “chained”

参考资料

http://forum.springsource.org/showthread.php?t=49398

http://manuals.sybase.com/onlinebook…iew/55096;hf=0

http://manuals.sybase.com/onlinebook…w/53740;hf=0#X

javaee and websphere30 一 2010 08:37 下午

IBM Websphere是IBM的JEE中间件产品,简称WAS。
IBM HTTP Server是IBM的http服务器产品,简称IHS。
IHS具有链接映射到WAS的功能,即是路由转发,如http://192.168.11.1/app可以转发到http://192.168.11.2:9080/app,要达到转发需要为IHS安装WAS的plugin。
安装WAS分两个步骤,一个安装WAS的本体,一个是安装概要,
安装概要有4钟模式。
1)DM+appserver
2)DM
3)应用服务器
4)自定义server
概要文件是一个逻辑上的WAS服务器,一个概要文件对应一个节点,这个概要上可包含一个节点控制器和一个nodeagent和多个appserver。其中最简单的是3)应用服务器,也是WAS默认的安装概要的选项,此概要是不基于nodeagent的,是将was控制台和was应用server全部托付给一个java进程的安装方式。
其余三种安装方式2)和4)是需要组合安装的,1)是在单硬件server上2)和4)安装的简单组合。
1)2)4)的安装概要方式是基于多java进程的,DM单独一个进程,nodeagent单独一个进程,appserver单独一个进程。DM通过nodeagent向网络上的本概要文件发送指令。
安装的默认的控制台端口为9043和9060,访问地址为https://127.0.0.1:9043/ibm/console和http://127.0.0.1:9060/ibm/console。appserver的默认端口为9080。

DM+nodeagent使我们创建基于多硬件的集群appserver变得非常的简单,并且应用的发布也可以达到一键式的操作。

javaee and websphere30 一 2010 08:08 下午

使用场景
WAS6.1.0.21
数据库为Sybase15
数据源为WAS的jtds的sybase,数据源最大数50
使用spring2.5.6和hibernate3.3.1
是用spring的jdbctemplate调用Sybase的存储过程。
用loadrunner进行压力测试
报错如下
ERROR: ConnectionCallback; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; DSRA9110E: 关闭 Connection。; nested exception is com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: 关闭 Connection。
org.springframework.jdbc.UncategorizedSQLException: ConnectionCallback; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; DSRA9110E: 关闭 Connection。; nested exception is com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: 关闭 Connection。
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:349)

Caused by: com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: 关闭 Connection。
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.runtimeXIfNotClosed(WSJdbcConnection.java:2657)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareCall(WSJdbcConnection.java:2022)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareCall(WSJdbcConnection.java:1914)
at sun.reflect.GeneratedMethodAccessor247.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.hibernate.jdbc.BorrowedConnectionProxy.invoke(BorrowedConnectionProxy.java:74)
at $Proxy41.prepareCall(Unknown Source)
at sun.reflect.GeneratedMethodAccessor246.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.springframework.jdbc.core.JdbcTemplate$CloseSuppressingInvocationHandler.invoke(JdbcTemplate.java:1292)
at $Proxy42.prepareCall(Unknown Source)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:342)

解决办法,由于是多线程并发访问,在调用存储过程的方法上加上synchronized,避免多线程并发。

javaee21 一 2010 01:01 下午

1)拷贝最新的jtds到was概要的机器上,例如E:/jdbcdriver/jtds-1.2.5.jar
2)进入WAS控制台–> 资源–>jdbc–>JDBC 提供程序
选中作用域然后新建
步骤 1: 创建新的 JDBC 提供程序

数据库类型 用户定义的
实现类名 net.sourceforge.jtds.jdbcx.JtdsDataSource
名称 jtds JDBC Provider
步骤 2: 输入数据库类路径信息
E:/jdbcdriver/jtds-1.2.5.jar
步骤 3: 总结

3)创建数据源
进入WAS控制台–>资源–>jdbc–>数据源
选中作用域然后新建
步骤 1: 输入基本数据源信息
数据源名 sybase_jtds
jndi名称 jdbc/db_jtds
组件管理的认证别名和 XA 恢复认证别名
选择无
步骤 2: 选择 JDBC 提供程序
选择现有的 JDBC 提供程序–>选择jtds JDBC Provider
步骤 3: 输入数据源的特定于数据库的属性
直接下一步
步骤 4: 总结

数据源—>sybase_jtds–>其他属性–>定制属性
添加或者修改如下属性,没用的属性可以直接删除掉
serverName 192.168.11.11
databaseName mydatabase
user testuser
password ******
portNumber 5000
serverType 2
charset cp936
数据源—>sybase_jtds–>其他属性–>连接池属性
最大连接数 50

javaee and spring05 一 2010 09:36 下午

契约式开发webservice实践之spring-ws+Xmlbeans
1、开发环境
JDK1.4.2.*
Tomcat6.0.*
Spring-2.5.5
Spring-ws-1.5.4
XmlBeans-2.3

2、确定需要请求和应答的xml实例
Request.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<wl_request  xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns=”http://footmarktech.com/samples”>
<flights>
<flight><segment>PEK-CAN<segment><ticketNo>7841234656</ticketNo></flight>
<flight><segment>PEK-CAN<segment><ticketNo>7841234656</ticketNo></flight>
</flights>
</wl_request>

Response.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<wl_response  xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns=”http://footmarktech.com/samples”>
<flights>
<flight><segment>PEK-CAN<segment><ticketNo>7841234656</ticketNo></flight>
<flight><segment>PEK-CAN<segment><ticketNo>7841234656</ticketNo></flight>
</flights>
</wl_response>

3、设置XmlBeans环境
设置XMLBEANS_HOME
并将 %XMLBEANS_HOME%/bin增加到path路径中

4、使用xmlbeans tool准备数据契约xsd
根据上一步骤请求和应答的实例xml执行如下命令
inst2xsd -enumerations never Request.xml Response.xml
将生成的schema0.xsd文件命名为 Airline.xsd

将 Airline.xsd放在 ${web-context}/WEB-INF目录下
5、使用xmlbeans tool生成OXM数据映射对象
需要说明的是这些对象是跟Xmlbeans耦合比较紧的,不是POJO
执行如下命令
scomp -out Airline.jar Airline.xsd

6、准备运行时和编译时jar包

<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/acegi-security-1.0.7.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/activation-1.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/antlr-2.7.7.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/aopalliance-1.0.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/axiom-api-1.2.6.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/axiom-dom-1.2.6.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/axiom-impl-1.2.6.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/backport-util-concurrent-3.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/bsf-2.3.0.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/cglib-nodep-2.1_3.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-beanutils-1.7.0.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-codec-1.3.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-collections-3.2.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-configuration-1.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-digester-1.8.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-discovery-0.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-el-1.0.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-fileupload-1.2.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-httpclient-3.0.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-io-1.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-lang-2.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-logging-1.1.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-net-1.2.2.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-pool-1.3.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/commons-validator-1.3.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/concurrent-1.3.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/dom4j-1.6.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/ehcache-1.2.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/ezmorph-1.0.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/groovy-all-1.5.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/hibernate-3.2.6.ga.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/hsqldb-1.8.0.7.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/icu4j-3.4.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/jasypt-1.4.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/javassist-3.6.ga.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/jaxen-1.1.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/jaxrpc-1.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/jcaptcha-all-1.0-RC6.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/jcr-1.0.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/jdom-1.0.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/json-lib-2.2.1-jdk13.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/jta-spec1_0_1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/log4j-1.2.15.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/lucene-core-2.2.0.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/mail-1.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/mysql-connector-java-5.1.5-bin.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/ognl-2.7.2.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/oro-2.0.8.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/oscache-2.4.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/pdfbox-0.6.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/poi-3.0.1-FINAL-20070705.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/poi-contrib-3.0.1-FINAL-20070705.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/poi-scratchpad-3.0.1-FINAL-20070705.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/proxool-0.9.0RC3.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/serializer-2.7.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/slf4j-api-1.4.3.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/slf4j-log4j12-1.4.3.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/spring-2.5.5.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/stax-api-1.0.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/wsdl4j-1.6.2.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/wstx-asl-3.2.3.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xalan-2.7.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xercesImpl-2.8.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xfire-all-1.2.6.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xml-apis-1.3.04.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xom-1.1.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xpp3_min-1.1.3.4.0.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xstream-1.2.2.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/axis-saaj-1.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/axis-1.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/spring-oxm-1.5.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/spring-webmvc-2.5.5.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/spring-ws-core-1.5.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/spring-ws-security-1.5.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/spring-ws-support-1.5.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/spring-xml-1.5.4.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/jsr173_1.0_api.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/resolver.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xbean_xpath.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xbean.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xmlbeans-qname.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/xmlpublic.jar”/>
<classpathentry kind=”lib” path=”web/src/context/WEB-INF/lib/Airline.jar”/>
<classpathentry kind=”output” path=”web/src/context/WEB-INF/classes”/>

Spring-ws1.5.4必须使用springframework2.5版本以上
其对org.springframework.core.io.Resource版本要求较高
必须加入spring-webmvc-2.5.5.jar
org.springframework.web.servlet.FrameworkServlet从2.5版本后被分到spring- webmvc.jar包,并不包含于主spring包内

注,可能有些jar包没有用到
7、书写web.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN” “http://java.sun.com/dtd/web-app_2_3.dtd”>
<web-app>
<display-name>Web</display-name>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>ws-spring-ws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>ws-spring-ws</servlet-name>
<url-pattern>/spring-ws/*</url-pattern>
</servlet-mapping>

</web-app>

8、书写业务实现

package demo1;

public class Order {
private String id;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}
}

package demo1;

public interface OrderService {
Order getOrder(String id);
}

package demo1;

public class OrderServiceImpl implements OrderService{
public Order getOrder(String id) {
Order order = new Order();
order.setId(id);
return order;
}

}

书写spring配置放在classpath下
applicationContext.xml

<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE beans PUBLIC
“-//SPRING//DTD BEAN//EN”
“http://www.springframework.org/dtd/spring-beans.dtd”>

<beans default-autowire=”no” default-lazy-init=”false” default-dependency-check=”none”>
<bean id=”orderService”/>
</beans>

9、书写Spring-ws EndPoint

package demo1;

import org.springframework.oxm.Marshaller;
import org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint;

import com.footmarktech.samples.WlRequestDocument;
import com.footmarktech.samples.WlResponseDocument;

public class SampleMarshallingEndpoint extends
AbstractMarshallingPayloadEndpoint {

private final OrderService orderService;

public SampleMarshallingEndpoint(OrderService orderService,
Marshaller marshaller) {
super(marshaller);
this.orderService = orderService;
}

protected Object invokeInternal(Object request) throws Exception {
com.footmarktech.samples.WlRequestDocument ab = null;
ab = (WlRequestDocument)request;

//TODO invoke orderService

WlResponseDocument rs = (WlResponseDocument) WlResponseDocument.Factory.newInstance();
rs.addNewWlResponse().addNewFlights().addNewFlight().setTicketNo(ab.getWlRequest().getFlights().getFlightArray(0).getTicketNo());
return rs;
}
}

10、书写ws-spring-ws-servlet.xml
放置于${web-context}/WEB-INF目录下

<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”http://www.springframework.org/schema/beans” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd”>

<bean id=”messageFactory”>
<property name=”payloadCaching” value=”true”/>
</bean>
<bean id=”xmlBeansMarshaller” />
<bean id=”orderEndPoint”>
<constructor-arg><ref bean=”orderService”/></constructor-arg>
<constructor-arg><ref bean=”xmlBeansMarshaller”/></constructor-arg>
</bean>
<bean id=”payloadMapping”>
<property name=”defaultEndpoint” ref=”orderEndPoint”/>
</bean>
<bean id=”echo”>
<property name=”schema”>
<bean>
<property name=”xsd” value=”/WEB-INF/Airline.xsd”/>
</bean>
</property>
<property name=”portTypeName” value=”Echo”/>
<property name=”locationUri” value=”http://localhost:8080/ss1/spring-ws/echo/services”/>
</bean>

</beans>

11、开发客户端

配置applicationContext1.xml放置于 classpath demo1.client包内

<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”http://www.springframework.org/schema/beans” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd”>

<bean id=”xmlBeansMarshaller” />

<bean id=”messageFactory”>
<property name=”payloadCaching” value=”true”/>
</bean>

<bean id=”webServiceTemplate1″>
<constructor-arg ref=”messageFactory” />
<property name=”marshaller” ref=”xmlBeansMarshaller” />
<property name=”unmarshaller” ref=”xmlBeansMarshaller” />
<property name=”messageSender”>
<bean>
<property name=”readTimeout” value=”0″ />
</bean>
</property>
<property name=”defaultUri” value=”http://localhost:8080/ss1/spring-ws/echo/services” />
</bean>
</beans>

package demo1.client;

import java.io.File;
import java.io.IOException;

import javax.xml.transform.Source;

import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.jdom.JDOMException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.Resource;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.xml.transform.ResourceSource;
import org.springframework.xml.transform.StringResult;

import com.footmarktech.smscenter.webservice.SendSMDocument;
import com.footmarktech.smscenter.webservice.SendSMResponseDocument;
import com.footmarktech.samples.WlRequestDocument;
import com.footmarktech.samples.WlResponseDocument;

public class EchoClient {
public static void RequestSpring() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(“applicationContext1.xml”, EchoClient.class);
WebServiceTemplate webServiceTemplate = (WebServiceTemplate) applicationContext
.getBean(“webServiceTemplate1″);
WlRequestDocument request = WlRequestDocument.Factory.newInstance();
request.addNewWlRequest().addNewFlights().addNewFlight().setTicketNo(new Long(1231235555).longValue());

WlResponseDocument response = (WlResponseDocument)webServiceTemplate.marshalSendAndReceive(request);
System.out.println(response.getWlResponse().getFlights().getFlightArray(0).getTicketNo());
}

public static void main(String[] args) throws IOException, JDOMException {
RequestSpring();

}

}

12、参考资料

http://xmlbeans.apache.org/

http://static.springframework.org/spring-ws/sites/1.5/reference/html/index.html

http://mdasgin.blogspot.com/2008/06/web-servisleri-bir-makinede-sunulan.html

http://www.infoq.com/cn/articles/arjen-poutsma-spring-ws

http://www.infoq.com/cn/articles/sosnoski-code-first

http://www.developer.com/design/article.php/10925_3745701_1

http://www.infoq.com/articles/os-ws-stacks-background

javaee05 一 2010 09:28 下午

1、下载

http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91

2、解压缩到
D:\svn-win32-1.5.4

3、设置SVN_HOME,添加%SVN_HOME%\bin; 到Path路径

4、创建D:/svn-work/projects目录

5、cmd命令 下执行 svnadmin create D:\svn-work\projects

6、修改D:\svn-work\projects\conf\svnserve.conf

# anon-access = read
# auth-access = write

anon-access = read
auth-access = write

# password-db = passwd
password-db = passwd

注意不要留空格

passwd 文件中 添加一个用户

admin=amdin

7、cmd命令 下执行 svnserve -d -r D:\svn-work

8、使用http://subclipse.tigris.org/ 插件

javaee and websphere30 十二 2009 01:55 下午

NSTCONFFAILED: 无法创建概要文件。ADMU0026I: 联合期间发生错误

环境

两台硬件PC

WAS61

pc1(ip=192.168.10.1 主机名PC1)安装 IHS和DM

pc2(ip=192.168.11.1 主机名PC2)安装 一个概要,节点托管给pc1

将pc2概要节点联合pc1的DM时候,总是联合不上。

删除了几次pc2上的WAS应用程序也不管用,于是决定使用手动联合进行,即创建完概要的时候选择稍后联合,正常创建完后,使用cmd命令进入创建的概要目录的bin,

敲入命令 addNode 192.168.10.1 8879

D:\IBM\WebSphere\AppServer\bin>addNode 192.168.10.1 8879

ADMU0116I: 正在文件

D:\IBM\WebSphere\AppServer\profiles\Custom01\logs\addNode.log

中记录工具信息

ADMU0128I: 正在启动具有 Custom01 概要文件的工具

CWPKI0308I: 正在使用以下 SHA

摘要将签署者别名“CN=PC1,

O=IBM,

C=US”添加至本地密钥库“ClientDefaultTrustStore”:FC:E1:E2:44:9A:22:

61:94:EF:C9:80:26:8E:0B:9F:72:70:9A:05:1F

CWPKI0308I: 正在使用以下 SHA

摘要将签署者别名“dummyclientsigner”添加至本地密钥库“ClientDefaultT

rustStore”:0B:3F:C9:E0:70:54:58:F7:FD:81:80:70:83:A6:D0:92:38:7A:54:CD

CWPKI0308I: 正在使用以下 SHA

摘要将签署者别名“dummyserversigner”添加至本地密钥库“ClientDefaultT

rustStore”:FB:38:FE:E6:CF:89:BA:01:67:8F:C2:30:74:84:E2:40:2C:B4:B5:65

ADMU0001I: 在 192.168.10.1:8879 上开始节点

PC2Node01 与 Deployment

Manager 的联合。

ADMU0001I: 在 192.168.10.1:8879 上开始节点

PC2Node01 与 Deployment

Manager 的联合。

ADMU0009I: 成功连接到 Deployment Manager

服务器:192.168.10.1:8879

ADMU0507I: 在

D:\IBM\WebSphere\AppServer\profiles\Custom01\config/cells/PC2Node01Cell/nodes/PC2Node01/servers

下的配置中未找到服务器。

ADMU2010I: 正在停止节点 PC2Node01

的所有服务器进程

ADMU0024I: 正在删除旧的备份目录。

ADMU0015I: 备份原始单元存储库。

ADMU0012I: 创建节点 PC2Node01 的 Node

Agent 配置

ADMU0027E: 联合 ADMU0036E: Deployment

Manager 不能根据名称主机 PC2

在地址 192.168.11.1 查找

期间发生错误;回滚到原始配置。

ADMU0211I: 在文件

D:\IBM\WebSphere\AppServer\profiles\Custom01\logs\addNode.log

中可看到错误的详细信息

ADMU0026I: 联合期间发生错误;回滚到原始配置。

ADMU0111E: 由于错误

com.ibm.websphere.management.exception.AdminException:

ADMU0036E: Deployment

Manager 不能根据名称主机 PC2

在地址 192.168.11.1 查找,程序退出

ADMU1211I: 要获取故障的全部跟踪,使用 -trace 选项。

ADMU0211I: 在文件

D:\IBM\WebSphere\AppServer\profiles\Custom01\logs\addNode.log

中可看到错误的详细信息

关键信息是

由于错误 com.ibm.websphere.management.exception.AdminException: ADMU0036E: Deployment Manager 不能根据名称主机 PC2 在地址192.168.11.1

于是分别修改了两台机器的hosts文件

在C:\windows\system32\drivers\etc\hosts文件中增加如下配置

192.168.10.1    PC1

192.168.11.1    PC2

然后再手工联合DM成功!

javaee and websphere30 十二 2009 01:53 下午

WAS的安装根据硬件的网络结构而定,一般一个硬件PC安装一个概要,DM装在任一个PC上或者单独的PC上,IHS安装在一个PC。
一个概要对 应一个nodeagent,nodeagent本质上是概要中的一个特殊的server,nodeagent是概要的代理,受管于DM,所以 nodeagent是必须要事先启动的,启动后DM就能通过nodeagent向此概要发送指令,创建server,启动server,终止server 等等。

假如有两台PC,可这样装
192.168.0.1 PC1
192.168.0.2 PC2

PC1 安装IHS+一个WAS概要,,此概要上不安装任何server
PC2安装DM+一个WAS概要,此概要上可创建多个server

具体安装步骤
1)PC1上 安装IHS,PC1上安装WAS,安装时不安装任何概要
升级IHS,升级WAS,创建概要,选择自定义概要,选择稍后联合。over
2)PC2 上安装WAS,安装时不安装任何概要
升级WAS,创建概要,选择DM,安装完后,启动。
创建概要,选择自定义概要,选择稍后联合。 over
3)PC2上启动DM
4)DM联合概要
PC1上进入 概要Custom01/bin目录下敲入 addNode 192.168.0.2 8879 将PC1概要节点联合到PC2DM上
PC2上进入 概要Custom01/bin目录下敲入 addNode 192.168.0.2 8879 将PC2概要节点联合到PC2DM上
5)启动节点nodeagent,确认两台受控节点的 nodeagent已启动
PC1上进入 概要Custom01/bin目录下敲入 startNode
PC2上进入 概要Custom01/bin目录下敲入 startNode

将PC1的nodeagent和PC2的nodeagent通过 WASService加入到Windows服务中,随机启动
进入PC1 D:\IBM\WebSphere\AppServer\bin目录中执行如下命令

WASService -add NodeAgent -serverName nodeagent -profilePath “D:\IBM\WebSphere\AppServer\profiles\Custom01″ -wasHome “D:\IBM\WebSphere\AppServer” -logRoot “D:\IBM\WebSphere\AppServer\profiles\Custom01\logs\nodeagent” -LogFile “D:\IBM\WebSphere\AppServer\profiles\Custom01\logs\nodeagent\startServer.log” -restart true

6)进入DM控制台

https://192.168.0.2:9043/ibm/console

通 过控制台
服务器–>应用服务器在PC2上添加应用服务器server1
服务器–>WEB服务器在PC2节点上添加 httpserver

安装完毕

7)通过DM控制台配置PC2的server1参数
在WAS Console -> Application Servers
-> -> Web Container Settings -> Web Container
-> Custom Properties里,增加一个custom
property, 名字为 com.ibm.ws.webcontainer.invokefilterscompatibility,值为true。

修改 PC2的server1的虚拟机最大最小堆栈

应用程序服务器 > server1 > 进程定义 > Java 虚拟机

最小512
最大1024

8)通过DM控制台增加虚拟机映射端口
环境–>虚拟主机 –>default_host
新增* 9081

以下内容为转载
WAS配置概要

描述 参数 缺省值 设置原则
JVM堆栈 服务器 > 应用程序服务器 > server1 > Java 虚拟机 最小值为总内存1/8,最大值为总内存1/2至3/4
连接池 资源 > JDBC提供程序 > (JDBC提供程序名) > 数据源> (数据源名)
> 连接池属*
最小连接数:10
最大连接数:50
通过TPV监控连接池的大小变化曲线设置
语 句高速缓存 资源 > JDBC提供程序 > (JDBC提供程序名) > 数据源> (数据源名)
>
WebSphere Application Server 数据源属* > 语句高速缓存大小
10 比如实际情况下CPU利用率很高,并且表明有瓶颈,performance advisors报警提示prepare
statement缓存丢弃 率较高,这说明默认的值(10)太小,需要增加该值大小以提高吞吐
JMS 池 资源JMS提供程序缺省消息传递JMS激活规范激活规范名 最大批次大小:无
最大并发端点数:无
根据实际情况分析
Web容器线程池 服务器 > 应用程序服务器 > (服务器名) >
线程池 > WebContainer
最小大小:10
最大大小:50
通过TPV监控Web容器线程池最大值(在可接受的相应时间范围内),根据此值进行设置
EJB缓存 服务器 > 应用程序服务器 > (服务器名) > EJB告诉缓存设置 > EJB缓存设置
>
高速缓存大小
高速缓存大小:2053
清除时间间隔:3000
比如通过TPV监控发现ejbStore()有很高的调用率并且CPU利用率很低,可以基于期望的最大的活动的EJB实
例 设置该值

http://wangbaoaiboy.blog.163.com/blog/static/5211191020091032651189/

« 上一页下一页 »