最近做项目要用到weblogic,版本是10。在linux系统上安装。
这2天就赶紧对这个研究了下怎么用,文章写得比较简单,主要是为了记录一些问题,也为了共享知识。
先说我遇到的问题:
1,weblogic已经安装好了,这个安装过程很好做,就不说了,在启动weblogic的时候,有一部需要输入账号和密码。
我在输入完账号后回车就报错:-bash : xxx:command not found.
很奇怪,我输得是账号,但是就报这个错误。
2,发布应用是也遇到问题,这个和websphere不一样,需要注意一些地方,下面细说。
针对上面2个问题,下面就说说我解决的过程。
在liunux下启动weblogic
在启动后会有提示输入用户的那行,输入后回车就显示
-bash : xxx;command not found
无论输什么都当成了命令而不是在验证账号和密码。
查了下网上的资料,需要在以下目录下
/home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer
创建目录security,在security下创建boot.properties,里面写好账号和密码:
password=xxx
username=xxx
保存文件,并修改文件属性是可读可执行。
然后再启动weblogic就正常启动了。
我再去看这个文件的内容时,发现已经被加密了。
相关命令,mkdir security
view
编辑内容后,保存为 boot.properties
:x boot.properties
或者使用vi命令,总之会编辑就行。
chmod 755 boot.properties
注意启动weblogic时注意后台启动,加上 & 符号
[weblogic@callcenter base_domain]$ ./startWebLogic.sh &
[weblogic@callcenter AdminServer]$ pwd
/home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer
[weblogic@callcenter AdminServer]$
[weblogic@callcenter AdminServer]$
[weblogic@callcenter security]$ pwd
/home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/security
[weblogic@callcenter security]$
[weblogic@callcenter security]$ ls
boot.properties
[weblogic@callcenter security]$
[weblogic@callcenter security]$
[weblogic@callcenter security]$ ls -l
total 4
-rwxr-xr-x. 1 weblogic weblogic 150 Nov 10 14:24 boot.properties
[weblogic@callcenter security]$
[weblogic@callcenter security]$ cat boot.properties
#Mon Nov 10 14:24:11 CST 2014
password={AES}sssVSvBRe3mZN7g6Qavrl+SyY2SrMAITc4i0GJGxhGc\=
username={AES}8dN5ZYmeLq8DQhSzdhb8g04yiMhHmhhjXXdwWiKdv2c\=
[weblogic@callcenter security]$
[weblogic@callcenter security]$
[weblogic@callcenter security]$
[weblogic@callcenter security]$
[weblogic@callcenter security]$
启动后可以使用netstat命令查看是否启动成功,查看7001的端口,如下。
可以看到线程ID为3201的线程在监听7001端口,那就是weblogic。
[weblogic@callcenter base_domain]$
[weblogic@callcenter base_domain]$ netstat -tnlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:28191 0.0.0.0:* LISTEN -
tcp 0 0 :::22 :::* LISTEN -
tcp 0 0 ::ffff:11.0.251.23:7001 :::* LISTEN 3201/java
tcp 0 0 ::1:7001 :::* LISTEN 3201/java
tcp 0 0 fe80::8411:13ff:fe70:1:7001 :::* LISTEN 3201/java
tcp 0 0 ::ffff:127.0.0.1:7001 :::* LISTEN 3201/java
tcp 0 0 ::1:25 :::* LISTEN -
tcp 0 0 :::5500 :::* LISTEN -
tcp 0 0 :::8800 :::* LISTEN 3201/java
[weblogic@callcenter base_domain]$
[weblogic@callcenter base_domain]$
[weblogic@callcenter base_domain]$
[weblogic@callcenter base_domain]$
[weblogic@callcenter base_domain]$
在浏览器访问weblogic控制台
http://11.0.251.23:7001/console
关于打包和发布应用:
在windows上打包war,一般可以使用eclipse的打包。
也可以使用jar命令。
#############################################
开始注意事项:因为我们的工程路径下都有svn信息,所以先用eclipse把代码导出
File System到随便一个路径。然后再这个路径下进行打包。
例如D:\toETP23
#############################################
cmd进入需要打包的目录下,
d:
cd D:\toETP23\newagent
jar -cvf newAgent.war *
一个正常工程路径:
newAgent
|
|--src
|--WebRoot
|--META-INF
|--WEB-INF
|
|--文件夹或者文件
|--js
|--css
|--jsp
对于weblogic有点特殊,它在发布应用的时候直接认目录而不是压缩包,而且是直接认WebRoot目录的,
例如一个weblogic认可的工程结构如下:
newAgent
|
|--META-INF
|--WEB-INF
|
|--文件夹或者文件(原来在下WebRoot)
|--js(原来在下WebRoot)
|--css(原来在下WebRoot)
|--jsp(原来在下WebRoot)
这个结构并没有java源码,我猜想它是直接认WEB-INF下面的classes编译好的java代码。
而且这个路径其实就是WebRoot的路径,但是WebRoot这个文件夹不需要了。
所以按照这个结构,我们应该直接到WebRoot下打包,而不是到WebRoot的上级目录newAgent打包。
所以对于weblogic,直接进入
cd D:\toETP23\newagent\WebRoot
jar -cvf newAgent.war *
-------------------------------------------------------------------------------------------------------------------
#############################################
关于解压,我们在哪个路径下打的包,对应就要到哪个路径下解包。
对于weblogic有点特殊,我们最后解压的东西一定要在工程名newAgent下,因为里面
的文件结构就是这样子。所以在服务器上,找到代码将要解压的路径。
如果没有newAgent这个目录,就自己动手建一个,进入这个路径进行解压。
jar -xvf newAgent.war
#############################################
1,按照weblogic打包方式进行打包,这个不说了,请看文章weblogic使用jar命令打包成war.
2,登陆weblogic控制台,停止应用。
3,登陆linux服务器,切换账号weblogic(这个账号根据实际情况,一定切换成你的weblogic账户)
[root@callcenter ~]#
[root@callcenter ~]# su - weblogic
[weblogic@callcenter ~]$
4,进入你的weblogic工程发布的路径下,这个你可以去控制台--部署里面看到,如果你知道那直接进入
到这个路径下,我的是:
[weblogic@callcenter upload]$
[weblogic@callcenter upload]$ pwd
/home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/upload
[weblogic@callcenter upload]$
这个路径下已经有5个可以发布的工程了,如下:
[weblogic@callcenter upload]$ ls
am monitor newAgent qlflow sdbzj
[weblogic@callcenter upload]$
我们要发布的应用是newAgent,所以先把这个路径下的东西全删了,只留newAgent这个路径。
(一定要注意你删的是什么,我要把newAgent这个路径里面的东西全删掉)
[weblogic@callcenter upload]$ pwd
/home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/upload
[weblogic@callcenter upload]$
[weblogic@callcenter upload]$
[weblogic@callcenter upload]$
[weblogic@callcenter upload]$ ls
am monitor newAgent qlflow sdbzj
[weblogic@callcenter upload]$
[weblogic@callcenter upload]$ rm -rf newAgent/*
[weblogic@callcenter upload]$
[weblogic@callcenter upload]$
[weblogic@callcenter upload]$ ls newAgent
[weblogic@callcenter upload]$
5,使用ftp工具吧你打好的包传到你需要发布的应用的路径下面,
这里是/home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/upload/newAgent
[weblogic@callcenter upload]$
[weblogic@callcenter upload]$ ls newAgent
newAgent.war
[weblogic@callcenter upload]$
6,进行解包
[weblogic@callcenter newAgent]$
[weblogic@callcenter newAgent]$ pwd
/home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/upload/newAgent
[weblogic@callcenter newAgent]$
命令是jar不是tar。
jar -xvf newAgent.war
解压完成后看到有文件了。
[weblogic@callcenter newAgent]$
[weblogic@callcenter newAgent]$ ls
chgpass.jsp creditcard_FQFKSS.jsp css files images index.jsp log META-INF portal WEB-INF
creditcard3026.jsp cs extjs grlc inbound js login.jsp newAgent.war portalAdmin.jsp
creditcard3026.jsp.bak csrjs fckeditor illegalAccess.jsp index.html loader ly_demo outbound tldCache.ser
[weblogic@callcenter newAgent]$
7,这时候就可以重启应用了,进入控制台,启动应用。
####################一些注意事项####################################
1,在启动应用的时候,可能会报错,找不到哪个类,80%的原因是你的web.xml里面定义了servlet,但是没写那个servlet类.
这个在tomcat下是没问题的,只是在访问那个servlet才会报错,但是weblogic会在启动应用的时候就检查这个类是不是存在。
2,在应用启动成功后,可以发现自己的系统里面页面会报一些错,可能是引用文件路径的问题。
引入文件的时候都不要使用相对路径,例如../../xxx.js
最好都使用绝对路径,例如/newAgent/xxx/xxx.js
3,我的项目中使用到dwr框架,这个也很容易出问题。
在web.xml里配置dwr的时候,一定注意servlet-class,可能有些人会使用
uk.ltd.getahead.dwr.DWRServlet,这个在tomcat下能正常跑,在weblogic下
就要改成org.directwebremoting.servlet.DwrServlet。详细的我也没研究。
dwr官网现在用的就是org.directwebremoting.servlet.DwrServlet。
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>
<!-- uk.ltd.getahead.dwr.DWRServlet-->
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>