caizi
学习、交流java技术,让java fans 共享、共进
posts - 4,comments - 6,trackbacks - 0
注意:是客户端的ip,不是获取本机的ip

import javax.servlet.http.*;
import javax.xml.rpc.server.*;
import org.apache.axis.MessageContext;
import org.apache.axis.transport.http.HTTPConstants;
public class BaseService {
  public String getClientIp(){
    MessageContext  mc  =  MessageContext.getCurrentContext();
    HttpServletRequest  request  =  (HttpServletRequest)  mc.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
    System.out.println("remote  ip:  "  +  request.getRemoteAddr());
    return request.getRemoteAddr();
  }
}
posted @ 2006-09-21 14:28 菜籽 阅读(3703) | 评论 (5)编辑 收藏

1、配置%CATALINA_HOME%/conf/server.xml文件
   在<host>节点下的<context>节点中加
   <Resource
            name="jdbc/oradb"
            type="javax.sql.DataSource"
            password="123456"
            driverClassName="oracle.jdbc.driver.OracleDriver"
            maxIdle="20"
            maxWait="-1"
            username="test"
            url="jdbc:oracle:thin:@192.168.0.1:1521:oradb"
            maxActive="1000"/>
2、配置项目的WEB-INF目录下的web.xml文件,在<web-app>中加
 <resource-ref>
 <description>ORACLE DB Connection</description>
 <res-ref-name>jdbc/oradb</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
  </resource-ref>

3、连接
  Context  initCtx = new InitialContext();
   if (initCtx == null)
   {
    throw new Exception("没有匹配的环境!");
   }
   DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/oradb");   

   if (ds == null)
   {
    throw new Exception("没有匹配的数据库!");
   }

   con = ds.getConnection();

一般按照这几步配置,就能连接成功了!如果这样配置后还提示
java:comp is not bound in this Context
那就检查你的项目的WEB-INF目录下lib目录中是否加进了一些如
naming-java.jar,naming-common.jar , naming-resources.jar , naming-factory.jar 之类的包,把这些包从lib目录删除了,这些包不必放在这里

posted @ 2006-09-21 10:17 菜籽 阅读(2407) | 评论 (1)编辑 收藏
原来在tomcat5.0+axis 1.1下开发webservices,没有问题。部署的时候换成tomcat5.5,结果,EchoHeaders.jws?method=list老是报
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.lang.NullPointerException</faultstring>
赶紧上网查资料,原来是少 "xercesImpl.jar" and "xml-apis.jar"
解决:
   downloaded Xerces and put the "xercesImpl.jar" and "xml-apis.jar" files inside 项目的WEB-INF/lib/目录中,问题解决。
posted @ 2006-09-15 08:56 菜籽 阅读(3680) | 评论 (0)编辑 收藏