2012年5月2日		  
	#
		
			
			
			                                   Javascript端加密java服务端解密
   
  通常我们会通过htts来保证传输安全,但如果我们不用https,如何通过javascript来保证浏览器端发送的参数进行加密,并且通过RSA算法来处理。
   
  这里我们可以利用jquery的一个加密插件jcryption来处理,可以参考
  http://jcryption.org/#examples
  现在版本是3.0 但是没有java端的实现,下次有时间再研究。现在这个用的是1.1的版本
  这个可以在
  http://linkwithweb.googlecode.com/svn/trunk/Utilities/jCryptionTutorial 获取
   
  不过他的服务端有个缺陷我修改了。
  接来大致介绍如下:
   
  1.     首先服务端有产生publicKey的servlet:
  package com.gsh.oauth.auth.servlet;
   
  import java.io.IOException;
  import java.security.KeyPair;
   
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
   
  import com.gsh.oauth.auth.util.JCryptionUtil;
   
  /**
   * Servlet implementation class EncryptionServlet
   */
  public class EncryptionServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
   
         /**
          * Default constructor.
          */
         public EncryptionServlet() {
                 // TODO Auto-generated constructor stub
         }
   
         /**
          * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
          */
         protected void service(HttpServletRequest request,
                        HttpServletResponse response) throws ServletException, IOException {
                 int KEY_SIZE = 1024;
                 if (request.getParameter("generateKeypair") != null) {
   
                        JCryptionUtil jCryptionUtil = new JCryptionUtil();
   
                        KeyPair keys = null;
                        //if (request.getSession().getAttribute("keys") == null) { //这里注释掉 否则第二次请求会500
                               keys = jCryptionUtil.generateKeypair(KEY_SIZE);
                               request.getSession().setAttribute("keys", keys);
                        //}
   
                        StringBuffer output = new StringBuffer();
   
                        String e = JCryptionUtil.getPublicKeyExponent(keys);
                        String n = JCryptionUtil.getPublicKeyModulus(keys);
                        String md = String.valueOf(JCryptionUtil.getMaxDigits(KEY_SIZE));
   
                        output.append("{\"e\":\"");
                        output.append(e);/Files/linugb118/bcprov-jdk15-1.46.jar.zip
                        output.append("\",\"n\":\"");
                        output.append(n);
                        output.append("\",\"maxdigits\":\"");
                        output.append(md);
                        output.append("\"}");
   
                        output.toString();
                        response.getOutputStream().print(
                                      output.toString().replaceAll("\r", "").replaceAll("\n", "")
                                                     .trim());
                 } else {
                        response.getOutputStream().print(String.valueOf(false));
                 }
         }
   
  }
   
  2. Client例子 
  <html>
  <head>
  <title>Login form</title>
  </head>
  <meta http-equiv="Content-Type"
      content="text/html; charset=utf-8">
   
  <script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
  <script src="../js/jquery-ui-1.8.2.custom.min.js"
      type="text/javascript"></script>
  <script type="text/javascript"
      src="../js/security/jquery.jcryption-1.1.min.js"></script>    
      
  <script type="text/javascript">
      $(document).ready(function() {
          var $statusText = $('<span id="status"></span>').hide();
          $("#status_container").append($statusText);
          $("#lf").jCryption({ 
              getKeysURL:"/gsh/oauth/encryption?generateKeypair=true",
                                          beforeEncryption : function() {
                                              $statusText
                                                     .text("Test Code")
                                                     .show();
                                              return true;
                                          },
                                          encryptionFinished : function(
                                                 encryptedString,
                                                 objectLength) {
                                              $statusText
                                                     .text(encryptedString);
                                              return true;
                                          }
                                      });
                    });
  </script>
  <body>
   
  <form id="lf" action="/gsh/oauth/authorization"
      method="post">
  <fieldset><legend>login</legend>
  <div>
  <div>client_id:<br>
  <input type="text" size="45" name="client_id" value=""></div>
  <div>redirect_uri:<br>
  <input type="text" size="45" name="redirect_uri" value=""></div>
  </div>
  <div>loginid:<br>
  <input type="text" size="45" name="loginid" value=""></div>
  </div>
  <div>password:<br>
  <input type="password" size="45" name="password" value=""></div>
  </div>
  <div>
  <p><input type="submit" /><span id="status_container"></span></p>
  </div>
  </fieldset>
  </form>
  </body>
  </html>
   
  上面看代码可以看出 他通过/gsh/oauth/encryption?generateKeypair=true来先请求获取public 然后通过jcryption进行加密 然后post到服务端。Encryption就是上面的EncryptionServlet。
  通过浏览器工具可以看到表单里面的数据加密为
   
  jCryption=95f1589502288050e08b4bd8b1a360341cf616d9054531b85a6ef85783c1723b46686ec454ee81f1304fa2370ce24c4d9c06f84d47aa4bdf99310ae12b514db19bfcc325f3a39a584c23b1546550f4e0635c12486f2fd84dec137e1c61cfa775dfa3057a1f0154712aaba0af0cc61810282780f15bed909c24a184e66ab39f2e
  3. 目标servlet(authorization)的解密 
   
  public class Authorization extends HttpServlet {
   
      protected void doGet(HttpServletRequest httpServletRequest,
             HttpServletResponse httpServletResponse) throws ServletException,
             IOException {
         
  PrintWriter out = httpServletResponse.getWriter();
          
          KeyPair keys = (KeyPair) httpServletRequest.getSession().getAttribute("keys");
          String encrypted = httpServletRequest.getParameter("epCryption");
          
          String client_id = null;
      String redirect_uri = null;
      String loginid = null;
      String password = null;
   
         try {
                 String data = JCryptionUtil.decrypt(encrypted, keys);
                 httpServletRequest.getSession().removeAttribute("keys");
                 Map params = JCryptionUtil.parse(data, "UTF-8");
                 client_id = (String) params.get("client_id");
                 redirect_uri = (String) params.get("redirect_uri");
                 loginid = (String) params.get("loginid");
                 password = (String) params.get("password");
   
             } catch (Throwable e) {
                 e.printStackTrace();
             }
  }
   
      }
   
  上面至少片段,需要相关的js和java问题,请在svn上面获取。另外还需要bcprov-jdk15-1.46.jar
  可以在http://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15/1.46
  获取。
   
   
   
   
			
			
		 
	
		
			
			
			在使用cas3的时候,往往有这样的需求,希望每个应用有个独立的登录页面
这块cas 官方文档有一些说明
https://wiki.jasig.org/display/CAS/Using+CAS+without+the+Login+Screen
首先从官方的角度,不建议使用多个登录页面,这样对安全会形成短板。但是
用户需求之上,如果我们要实现,有下面几种方式
1.通过参数来判断css来改变布局甚至一些图片,典型cas里面的default-view中
casLoginView.jsp 里面就有这样的描述,通过描述可以看出他通过不同css来区分
weblogin和mobilelogin。
比如片段
<c:if
	test="${not empty requestScope['isMobile'] and not empty mobileCss}">
	<meta name="viewport"
		content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
	<!--<link type="text/css" rel="stylesheet" media="screen" href="<c:url value="/css/fss-framework-1.1.2.css" />" />
             <link type="text/css" rel="stylesheet" href="<c:url value="/css/fss-mobile-${requestScope['browserType']}-layout.css" />" />
             <link type="text/css" rel="stylesheet" href="${mobileCss}" />-->
</c:if>
2.cas服务端(或者各种应用中)建立一个独立的form页面
参考:https://wiki.jasig.org/display/CAS/Using+CAS+from+external+link+or+custom+external+form
比如:
在cas(或者各种的应用页面) web-inf/ 页面添加testlogin.html
代码:
<html>
<head />
<body>
    <form method="GET" action="http://192.168.2.109:8080/cas/login">
        <p>Username : <input type="text" name="username" /></p>
        <p>Password : <input type="password" name="password" /></p>
        <p>Remember me : <input type="checkbox" name="rememberMe" value="true" /></p>
        <p><input type="submit" value="Login !" /></p>
        <input type="hidden" name="auto" value="true" />
        <input type="hidden" name="service" value="http://localhost/user/checklogintocas.php" />
    </form>
</body>
</html>
casLoginView.jsp
实现自动提交功能:
...
<%@ page contentType="text/html; charset=UTF-8" %>
<%
String auto = request.getParameter("auto");
if (auto != null && auto.equals("true")) {
%>
<html>
    <head>
        <script language="javascript">
            function doAutoLogin() {
                document.forms[0].submit();
            }
        </script>
    </head>
    <body onload="doAutoLogin();">
        <form id="credentials" method="POST" action="<%= request.getContextPath() %>/login?service=<%= request.getParameter("service") %>"> 
            <input type="hidden" name="lt" value="${loginTicket}" />
            <input type="hidden" name="execution" value="${flowExecutionKey}" />
            <input type="hidden" name="_eventId" value="submit" />
            <input type="hidden" name="username" value="<%= request.getParameter("username") %>" />
            <input type="hidden" name="password" value="<%= request.getParameter("password") %>" />
            <% if ("true".equals(request.getParameter("rememberMe"))) {%>
                <input type="hidden" name="rememberMe" value="true" />
            <% } %>
             
            <input type="submit" value="Submit" style="visibility: hidden;" />
        </form>
    </body>
</html>
<%
} else {
%>
<jsp:directive.include file="includes/top.jsp" />
...
<jsp:directive.include file="includes/bottom.jsp" />
<%
}
%>
3.第三种方法 其实是第二种方法的启发,直接把用if-else 把多个页面组合在一起,通过参数来判断显示。(最好能可以支持多套casLoginView.jsp 不过研究下来好像比较难,也许cas开发者也是为了怕再次开放的人用太多灵活的多套casLoginView.jsp 页面跳来跳去把项目搞混吧。)
			
			
		 
	
		
			
			
			之前在
安装memcache时有提到memcached客户端是叫memcache,其实还有一个基于libmemcached的客户端叫memcached,据说性能更好,功能也更多。
memcache的官方主页:
http://pecl.php.net/package/memcachememcached的官方主页:
http://pecl.php.net/package/memcached以下是我安装Memcached版本的PHP模块的过程记录:
wget
http://download.tangent.org/libmemcached-0.48.tar.gztar zxf libmemcached-0.48.tar.gz
cd libmemcached-0.48
./configure --prefix=/usr/local/libmemcached --with-memcached
make
make install
wget 
http://pecl.php.net/get/memcached-1.0.2.tgztar zxf memcached-1.0.2.tgz
cd memcached-1.0.2
/usr/local/webserver/php/bin/phpize 
./configure --enable-memcached --with-php-config=/usr/local/webserver/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached
make
make install
在php.ini中加入
extension=memcached.so
完成
另:
在安装libmemcached时,如果只用./configure,可能会提示:
checking for memcached… no
configure: error: “could not find memcached binary”
两者使用起来几乎一模一样。
    $mem = new Memcache;
    $mem->addServer($memcachehost, '11211');    
    $mem->addServer($memcachehost, '11212');
    $mem->set('hx','9enjoy');
    echo $mem->get('hx');
    $md = new Memcached;
    $servers = array(
        array($memcachehost, '11211'),
        array($memcachehost, '11212')
    );
    $md->addServers($servers);
    $md->set('hx','9enjoy');
    echo $md->get('hx');
memcached的方法比memcache多不少,比如getMulti,getByKey,addServers等。
memcached没有memcache的connect方法,目前也还不支持长连接。
memcached 支持 Binary Protocol,而 memcache 不支持,意味着 memcached 会有更高的性能。
Memcache是原生实现的,支持OO和非OO两套接口并存,memcached是使用libmemcached,只支持OO接口。
更详细的区别:
http://code.google.com/p/memcached/wiki/PHPClientComparisonmemcached服务端是集中式的缓存系统,分布式实现方法是由客户端决定的。
memcached的分布算法一般有两种选择:
1、根据hash(key)的结果,模连接数的余数决定存储到哪个节点,也就是hash(key)% sessions.size(),这个算法简单快速,表现良好。然而这个算法有个缺点,就是在memcached节点增加或者删除的时候,原有的缓存数据将大规模失效,命中率大受影响,如果节点数多,缓存数据多,重建缓存的代价太高,因此有了第二个算法。
2、Consistent Hashing,一致性哈希算法,他的查找节点过程如下:
    首先求出memcached服务器(节点)的哈希值,并将其配置到0~232的圆(continuum)上。然后用同样的方法求出存储数据的键的哈希值,并映射到圆上。然后从数据映射到的位置开始顺时针查找,将数据保存到找到的第一个服务器上。如果超过2的32次方后仍然找不到服务器,就会保存到第一台memcached服务器上。
memcache在没有任何配置的情况下,是使用第一种方法。memcached要实现第一种方法,似乎是使用(未确认):
$md->setOption(Memcached::OPT_HASH, Memcached::HASH_CRC);   
第二种一致性哈希算法:
memcache在php.ini中加
Memcache.hash_strategy =consistent
Memcache.hash_function =crc32
memcached在程序中加(未确认)
$md->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);
$md->setOption(Memcached::OPT_HASH, Memcached::HASH_CRC);   
或
$mem->setOption(Memcached::OPT_DISTRIBUTION,Memcached::DISTRIBUTION_CONSISTENT);
$mem->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE,true);
一些参考文档:
memcached分布测试报告(一致性哈希情况下的散列函数选择):
http://www.iteye.com/topic/346682php模块memcache和memcached区别:
http://hi.baidu.com/dong_love_yan/blog/item/afbe1e12d22e7512203f2e21.htmlPHP模块:Memcached > Memcache:
http://hi.baidu.com/thinkinginlamp/blog/item/717cd42a11f6e491023bf67a.html20110509@@UPDATE:
如果安装libmemcached有如下出错提示:
make[2]: *** [clients/ms_conn.o] Error 1
make[2]: Leaving directory `/www/soft/libmemcached-0.48'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/www/soft/libmemcached-0.48'
make: *** [all] Error 2
可在configure时增加--disable-64bit CFLAGS="-O3 -march=i686"
即:./configure --prefix=/usr/local/libmemcached --with-memcached --disable-64bit CFLAGS="-O3 -march=i686"
 
	
		
			
			
			1. windows里面出现“拒绝访问”, 那需要通过管理员身份运行cmd
2. 安装服务时候指定的ini路径需要注意,应该指定你现在mysql目录现有的ini文件
如mysqld --install mysql --defaults-file="C:\MySQL5\my.ini"
			
			
		 
	
		
			
			
			现象: 执行demo,比如helloexample ,点击“run as mule application”,弹出框“Could not find the main class.Program will exit”
控制台出现:
java.lang.NoClassDefFoundError: org/mule/tooling/server/application/ApplicationDeployer
Exception in thread "main" 
解决方法: 是因为jdk 有问题,在mule官网上要求
Before installing Mule Studio, ensure that the host machine has one of the following Java Development Kit versions installed on it:
- Standard Edition 1.6.0_26 (also known as JDK SE 6 Update 26) or more recent
- Enterprise Edition 1.6u3 (JDK EE 6 Update 3) or more recent
- Any version (SE or EE) of JDK 7
 在java build path--》libraries 选择jre system library 为jdk1.7就可以。
 
	
		
			
			
			1.     serviceMix 特点:
  支持的协议有:
  File;FTP;Http/s;jms;smtp;soap;tcp;xmpp
  与其他引擎的支持:
  Apache Camel;apache cxf;apache ode;drools;os workflow;pojos;quartz;scripting;saxon Xquery and xslt;ws-notification
  支持的安全:
  JAAS,WS-Security
  与web 容器的集成
  JBoss,Geronimo,jetty,tomcat,weblogic,websphere
   
  2.     eclipse IDE tooling for serviceMix
  http://eclipse.org/stp
  http://spagic.com
  http://sopera.de/en/products/sopera-servicemixtools
   
  3.     安装:
    - 官方下载http://servicemix.apache.org/downloads.html.并解压
- 进入bin目录执行servicemix.bat或者shell script
- Sericemix是osgi结构的,
通过osgi:list 命令可以查看所有有效的osgi bundles
  通过osgi:list | grep camel 命令 查看camel相关的bundles
  通过log:display命令 来显示日志
  通过log:display-exception  显示最近的异常日志
  通过log:set DEBUG  设置日志的级别
  通过log:display | grep DEBUG 显示只是debug级别的日志
            通过features:list 来查看所有的特性,并从而可以分析当前特性是否安装
            若没有安装 可以通过 features:install来安装,比如:features:install webconsole
  4.     与Camel 集成
  先查看是否存在camel相关features,没有则按照相应的bundles
  接下来我们做一个例子:分别设置两个目录input和output,在input放入文件后则被传送到output中。而这个过程就是通过serviceMix调用camel router来完成
    - Blueprint      xml file
下面是一个配置的router文件描述,你可以通过自己写文件,当然最好还是用可视化工具,后面我们再花时间聊聊这东东,这个时候就绕不开Enterprise Integration pattern 又是标准,老外厉害。
   我们这里直接先贴上文件:
  <?xml version="1.0" encoding="UTF-8"?>
  <blueprint
      xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
      xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
   
      <camelContext xmlns="http://camel.apache.org/schema/blueprint">
          <route>
              <from uri="file:bgao/input" />
              <log message="happy day!!!" />
              <to uri="file:bgao/output" />
          </route>
      </camelContext>
  </blueprint>
  并命名为firstCamelRouter.xml
   
    - 配置到serviceMix
将文件放入到serviceMix的deploy中,这个时候后再serviceMix目录下发现bgao的目录并下面有个input文件夹,这时候如果在input文件夹放入一个文件,这bgao目录下会出现output目录并且将input目录的文件移到output上。通过log:display  可以查看到当前这个动作的日志。
   
  通过karaf@root> osgi:list | grep xml
  [  43] [Active     ] [GracePeriod ] [       ] [   60] activemq-broker.xml (0.0.0
  )
  [ 129] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundl
  es :: xmlsec (1.4.5.1)
  [ 138] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundl
  es :: xmlbeans (2.4.0.4)
  [ 142] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundl
  es :: xmlresolver (1.2.0.3)
  [ 163] [Active     ] [Created     ] [       ] [   60] firstCamelRouter.xml (0.0.
  0)
  得到当前ID为163;通过osgi:stop 163或者  osgi:start 163 来启动或者关闭当前bundle
   
  5.     与ActiveMQ集成
  先查看是否存在camel相关features, 没有则按照相应的bundles
  我们做一个例子:
  对两个文件进行文件移动,同时对MQ队列产生一个event 消息并捕获消息打出到日志。
  第一个文件:firstMq.xml
  <?xml version="1.0" encoding="UTF-8"?>
  <blueprint
      xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
      xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
   
      <camelContext xmlns="http://camel.apache.org/schema/blueprint">
          <route>
              <from uri="file:bgao/mq/input" />
              <to uri="file:bgao/mq/output" />          
                  <setBody>
                  <simple>
                  File Move Event (${file:name},${date:now:hh:MM:ss.SSS})
                  </simple>
                  </setBody>
                  <to uri="activemq://event" />
          </route>          
      </camelContext>
  </blueprint>
  这时候,文件已经移到output,现在是event message都在队列里面,但还没有人去处理他,现在通过secondeMq里处理她。
  设置第二个文件 secondMq.xml 放入deloy文件夹中
  <?xml version="1.0" encoding="UTF-8"?>
  <blueprint
      xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
      xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
   
      <camelContext xmlns="http://camel.apache.org/schema/blueprint">
          <route>
          <from uri="activemq://event" />
              <from uri="file:bgao/mq/input" />
              <to uri="log:events" />          
          </route>          
      </camelContext>
  </blueprint>
  启动当前这个bundle 然后打日志就发现有
  2012-06-11 16:01:43,751 | INFO  | sConsumer[event] | events
        | ?                                   ? | 91 - org.apache.camel.camel-core
   - 2.8.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:
                          File Move Event (address list20120130.xls,04:06:08.272)
                          ]
  2012-06-11 16:01:43,751 | INFO  | sConsumer[event] | events
        | ?                                   ? | 91 - org.apache.camel.camel-core
   - 2.8.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:
                          File Move Event (jms-1_1-fr-spec.pdf,04:06:08.469)
                          ]
  2012-06-11 16:01:43,752 | INFO  | sConsumer[event] | events
        | ?                                   ? | 91 - org.apache.camel.camel-core
   - 2.8.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:
                          File Move Event (新建文本文档 (3).txt,04:06:08.765)
   
  6.     Webconsole
  通过安装features:install webconsole后,可以通过访问http://localhost:8181/system/console
  用户名:smx
  密码:smx
  当前webconsole 是karaf框架提供的一个web页面系统。
			
			
		 
	
		
			
			
			从weblogic 10.3.4开始支持maven deploy部署
步骤如下:
1.构建weblogic-maven-plugin jar
在D:\oracle\Middleware\wlserver_12.1\server\lib
找到 WebLogic JarBuilder Tool (wljarbuilder),执行:
java -jar wljarbuilder.jar -profile weblogic-maven-plugin
2.将weblogic-maven-plugin jar中的pom.xml 解压出放入到在
D:\oracle\Middleware\wlserver_12.1\server\lib
可以使用命令:
jar xvf D:/oracle/Middleware/wlserver_12.1/server/lib/weblogic-maven-plugin.jar 
META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml
cp D:/oracle/Middleware/wlserver_12.1/server/lib/META-INF/maven/com.oracle.weblogic/
weblogic-maven-plugin/pom.xml D:/oracle/Middleware/wlserver_12.1/server/lib
3.安装插件:
一种将weblogic-maven-plugin.jar 和pom.xml上传到nexus的第三方库中
另一种执行mvn install:install-file -Dfile=weblogic-maven-plugin.jar -DpomFile=pom.xml
进行安装。这个时候在你的本地仓库能到找.m2\repository\com\oracle\weblogic
4.在当前需要上传的应用的pom中配置weblogic的相关配置
比如:
 <!--auto deploy war to weblogic by maven-->
   
   <plugin> 
		  <groupId>com.oracle.weblogic</groupId>
		  <artifactId>weblogic-maven-plugin</artifactId>
		  <version>10.3.6.0</version>
      <configuration> 
          <adminurl>t3://192.168.2.141:9001</adminurl>
          <user>weblogic</user> 
          <password>123456</password> 
          <upload>true</upload> 
          <action>deploy</action> 
          <remote>false</remote> 
          <verbose>true</verbose> 
		<source>target/demo.war</source> 
         <name>demo</name> 
      </configuration> 
      <!-- 
      <executions> 
         <execution> 
            <phase>install</phase> 
              <goals> 
                <goal>deploy</goal> 
              </goals> 
         </execution> 
       </executions> 
       --> 
  </plugin> 
   <!-- end-->
先打包生成demo.war,然后执行>mvn com.oracle.weblogic:weblogic-maven-plugin:deploy
主要官方提供的命令是:mvn weblogic:deploy; 其实你敲这个命令你会发现,他用的不是oracle的plugin
而是用的 org.codehaus.mojo的
此外如果需要提前命令,可以用help来查看,查看结果:
『
---
The following are the goals available currently in Maven
deploy
list-apps
redeploy
start-app
stop-app
undeploy
update-app
』
执行成功后,回到weblogic的console台,你能发现你的war包,同时可以访问看是否部署成功。
如果想直接一个命令部署怎么办? 直接在mvn命令后面加上package
mvn package com.oracle.weblogic:weblogic-maven-plugin:deploy
但是他报错:
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.oracle.weblogic:weblogic-maven-plugin:10.3.6.
0:deploy (default-cli) on project ep-easyui-webapp: weblogic.deploy.api.tools.de
ployer.DeployerException: Java heap space -> [Help 1]
[ERROR]
原因是jdk 内存不够
为mvn设置内存,在maven.bat上加上
set MAVEN_OPTS=-Xdebug -Xnoagent -Xms256m -Xmx512m -Djava.compiler=NONE
这句话本身是@rem有。
然后直接
mvn package com.oracle.weblogic:weblogic-maven-plugin:deploy
就是能成功。
参考文献:
http://docs.oracle.com/cd/E24329_01/web.1211/e24443/maven_deployer.htm
主要10.3以后好像才有这个支持,另外12g和11g也有区别。
			
			
		 
	
		
			
			
			调试maven时候,报错
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ep-easyui-webapp: Could not resolve de
pendencies for project ep-easyui-webapp:ep-easyui-webapp:war:1.0-SNAPSHOT: The f
ollowing artifacts could not be resolved: javax.persistence:ejb:jar:3.0-public_r
eview, maven-plugins:maven-cobertura-plugin:plugin:1.3, maven-plugins:maven-find
bugs-plugin:plugin:1.3.1, persistence:persistence:jar:1: Failure to find javax.p
ersistence:ejb:jar:3.0-public_review in http://localhost:8081/nexus/content/grou
ps/EpPublic/ was cached in the local repository, resolution will not be reattemp
ted until the update interval of EpPublic has elapsed or updates are forced -> [
Help 1]
我在pom.xml 文件中添加
<dependency>
  <groupId>javax.persistence</groupId>
  <artifactId>ejb</artifactId>
  <version>3.0-public_review</version>
</dependency>
仍然抱这个错,解决方法
1) Manually install this artifact into your local repo cache
2) Add an excludes and a corresponding dependency so you get a proper artifact
3) Stop depending on outdated Hibernate artifacts, I'd suggest
upgrading to this one:
http://repo2.maven.org/maven2/org/hibernate/hibernate-annotations/3.4.0.GA/
改成<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
同时把
<dependency>
  <groupId>javax.persistence</groupId>
  <artifactId>ejb</artifactId>
  <version>3.0-public_review</version>
</dependency>
去掉
			
			
		 
	
		
			
			
			通过mvn调用ant 的build.xml 文件
  Mvn 命令出错,出错信息:
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 1.013s
  [INFO] Finished at: Wed May 02 13:36:28 CST 2012
  [INFO] Final Memory: 3M/7M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:
  run (compile) on project ep-cas-client: An Ant BuildException has occured: The f
  ollowing error occurred while executing this line:
  [ERROR] E:\casClient\build.xml:28: Unable to find a javac compiler;
  [ERROR] com.sun.tools.javac.Main is not on the classpath.
  [ERROR] Perhaps JAVA_HOME does not point to the JDK.
  [ERROR] It is currently set to "D:\Java\jdk1.6.0_01\jre"
  [ERROR] -> [Help 1]
  [ERROR]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
  ch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR]
  [ERROR] For more information about the errors and possible solutions, please rea
  d the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
  Xception
   
  而直接 echo  %Java_Home%
  得到:
  D:\Java\jdk1.6.0_01
   
  再直接mvn –version:
  Apache Maven 3.0.4 (r1232337; 2012-01-17 16:44:56+0800)
  Maven home: D:\Java\apache-maven-3.0.4
  Java version: 1.6.0_01, vendor: Sun Microsystems Inc.
  Java home: D:\Java\jdk1.6.0_01\jre
  Default locale: zh_CN, platform encoding: GBK
  OS name: "windows vista", version: "6.1", arch: "x86", family: "windows"
   
  发现 的确 mvn 指向的java home 是D:\Java\jdk1.6.0_01\jre
  解决方法:
   
  在build.xml 文件中添加
  <property name="build.compiler" value="extJavac"/>