一、安装部署和配置weblogic 12c
1.现在下载的为wls_dev版本,没有安装界面,需要执行命令行进行安装
这个版本很小,只有179MB
http://www.oracle.com/technetwork/middleware/fusion-middleware/downloads/index.html
注: 有安装界面的weblogic,无特殊配置一般一直下一步就可以完成安装,完成安装后创建域也很简单,这里不详细说明,网上安装手册有很多
2.解压wls1211_dev.zip 可以看到README.txt文件
主要安装步骤内容如下:
步骤很简单,但是执行到configure.cmd时系统找不到指定路径,
解决方法:检查JAVA_HOME ,把Program Files改为短文件名:Progra~1
安装成功后建立weblogic域,这里我执行了GUI安装,见下面的红字。一直下一步,中间会有设置域的用户名密码 ,域建好之后,目录里有了user_projects,到这个目录下(mydomain为你设置的域名称) user_projects\domains\mydomain 然后 startWebLogic.cmd
域就启动了,http://localhost:7001/console可以进入控制台对程序进行部署
1. Extract the contents of the zip to a directory. This directory is referred
to as MW_HOME (eg: /home/myhome/mywls).
2. Setup JAVA_HOME, JAVA_VENDOR, MW_HOME variables in the current shell as required
for the target platform.
Linux
$ export JAVA_HOME=/home/myhome/myjavahome
$ export MW_HOME=/home/myhome/mywls
Mac
$ export JAVA_HOME=
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
$ export USER_MEM_ARGS="-Xmx1024m -XX:MaxPermSize=256m"
$ export MW_HOME=/home/myhome/mywls
Windows
> set JAVA_HOME=C:\home\myhome\myjavahome
> set MW_HOME=C:\home\myhome\mywls
> set JAVA_VENDOR=[Sun|Oracle]
On Windows you must set JAVA_VENDOR to the JVM being used:
If using HotSpot, use "Sun"
If using JRockit, use "Oracle"
3. Run the installation configuration script in the MW_HOME directory.
This step is required to be run only once. If you move the installation to
another location/machine, you need to rerun this step.
Linux/Mac
$ . ./configure.sh
Windows
> configure.cmd
On Windows, this step retains the WLS environment settings for the current shell.
So, the next step can be omitted.
4. Setup WLS environment in the current shell.
Linux
$ . $MW_HOME/wlserver/server/bin/setWLSEnv.sh
Mac
$ . $MW_HOME/wlserver/server/bin/setWLSEnv.sh
Windows
> %MW_HOME%\wlserver\server\bin\setWLSEnv.cmd
5. Create a new WLS domain and start WLS.
It is recommended that you create domains outside the MW_HOME.
Linux
$ mkdir /home/myhome/mydomain
$ cd /home/myhome/mydomain
$ $JAVA_HOME/bin/java $JAVA_OPTIONS -Xmx1024m -XX:MaxPermSize=128m weblogic.Server
Mac
$ mkdir /home/myhome/mydomain
$ cd /home/myhome/mydomain
$ $JAVA_HOME/bin/java $JAVA_OPTIONS -Xmx1024m -XX:MaxPermSize=256m weblogic.Server
Windows
> mkdir C:\home\myhome\mydomain
> cd C:\home\myhome\mydomain
> %JAVA_HOME%\bin\java.exe %JAVA_OPTIONS% -Xmx1024m -XX:MaxPermSize=128m weblogic.Server
Once the domain is created, you can shutdown WLS and restart it with the
scripts provided in the newly created domain.
Note: You can also create the domain by invoking the GUI configuration
wizard (Run MW_HOME/wlserver/common/bin/config.[sh|cmd]).
6. If you already have an existing domain that you want to run with this
installation, edit the DOMAIN_HOME/bin/setDomainEnv.sh script and change the
WL_HOME to point to the new installation - ${MW_HOME}/wlserver/
Note: If the existing domain has samples configured, the server will issue
failures during startup as samples are not included in the zip distribution.
7. Start a browser and open up url - 'http://localhost:7001/console' to
administer the server.
8. If you need samples, evaluation database (Derby) or console help files for
for non-english locales, you can download the supplemental zip and extract
it under MW_HOME. Follow instructions in README_SUPP.txt to properly setup
Samples.
二、安装部署war包
进入weblogic 控制台后在部署功能中对程序进行安装,如无其他配置,直接下一步
安装成功后,访问,报错 ——!! 发现是hibernate错误,原来是jar包冲突
如下解决:将lib下的antlr-2.7.6.jar拷贝到wlserver\server\lib下,修改user_projects\domains\mydomain\bin下的startWeblogic.cmd ,找到
set CLASSPATH=%SAVE_CLASSPATH%
改为(上下各加入了一个命令):
set PRE_CLASSPATH=%WL_HOME%\server\lib\antlr-2.7.6.jar;
set CLASSPATH=%SAVE_CLASSPATH%
set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%
再次启动,访问成功!
三、weblogic12 的安全领域配置
之前在tomcat-user.xml里配置了安全域,为webservice访问提供了basic authentication认证
现在移植到weblogic下,需要配置用户和组,并且需要在web-inf下面添加一个weblogic.xml文件
Web.xml下的配置为:
<security-role>
<description>DictWebService operator user</description>
<role-name>operator</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>Operator Roles Security</web-resource-name>
<url-pattern>/services/dictservice</url-pattern>
<url-pattern>/services/uploadservice</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>operator</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
Weblogic.xml文件的配置为:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<session-descriptor></session-descriptor>
<jsp-descriptor>
</jsp-descriptor>
<container-descriptor></container-descriptor>
<servlet-descriptor>
<servlet-name>action</servlet-name>
</servlet-descriptor>
<charset-params>
<input-charset>
<resource-path>/*</resource-path>
<java-charset-name>UTF-8</java-charset-name>
</input-charset>
</charset-params>
<context-root>/</context-root>
<security-role-assignment>
<role-name>operator</role-name>
<principal-name>GspWebService</principal-name>
</security-role-assignment>
</weblogic-web-app>
其中role-name 对应web.xml中的role-name
Principal-name对应weblogic里设置的用户组
这样在weblogic控制台的安全领域里设置相应的用户和组,并且讲用户和组关联,就可以实现basic authentication了