开发中,往往发布的应用与开发环境的环境有差异,测试环境报的问题在开发环境很难重现,也很难定位问题,如果报错,是程序问题还是环境问题,常常是让开发头痛的事。

拿我们项目来说,测试环境用的服务器是JBOSS,而开发环境是Jetty或者Tomcat,既然这样,而测试的服务器我们都没有权限访问,甚至看日志的权限都没有,所以我一般在自已机器上也装一个同样版本的JBOSS。

原因一:重现问题,排除环境差异

原因二:便于调试,定位问题(当然这里指远程调试)

方法:

1. 我们把项目的war包放到JBOSS的deploy目录下

2. 打开Jboss安装目录下的bin目录,找到run.bat文件(Windowx环境,Linux请看文章最后),搜索8787,找到如下一行:

rem set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%

改为如下,即去掉红色部分,即注释即可

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%

然后运行Jboss的run.bat启动Jboss,这里Jboss启动画面如下:


3.这里Jboss的配置已完全结束,下面请打开Eclipse,连接到Jboss的远程端口,菜单路径

Run-->Debug Configrations-->Remote Java Application  然后双击该菜单Remote Java Application,在弹出的界面做如下配置:


按上图配置完后,单击Apply保存配置,然后单击Debug按钮,此时已连接到Jboss监听端口8787,Jboss监听到该端口后也开始启动。

到此OK,然后在你的代码里打断点,开始爽歪歪的调试吧,定位问题从此不再难。


注意:上面是在windows环境下,如果是Linux也很简单,只需修改run.conf 文件,找到如下一行:

#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

去掉前面的#号注释,改为如下即可:

JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"


JBOSS 项目部署的两种方式

1:直接放war包

直接将项目打成example.war包放在${JBOSS_HOME}standalone/deployments下,直接运行jboss就可以了

2:放项目文件

在${JBOSS_HOME}standalone/deployments下新建目录example.war和example.war.dodeploy。将项目的文件放在example.war目录下就可以了。

在JBOSS自带的说明文件README.txt文件里说的很详细,英文的,文件在 ${JBOSS_HOME}standalone/deployments下


修改JBOSS 中sessionid 中有为undefined  值,则要配置instance-id="hellnode01"(stone.xml文件中)

Hi All

 

On Jboss 7.1.1 AS we have problem with session id. I have deployed simple webapplciation on 7 AS, when i get to get session id its give improper data, similar app works fine on 7.0 AS.

 

 

index.jsp

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

         <%=session.getId() %>

</body>

</html>

 

session id i am getting as : ResnIPq5zE8E4Q1+mNWpHDEg.undefined

 

is there any configuration we need to change, can anyone suggest me on this.

 

Thanks

- See more at: https://developer.jboss.org/thread/201760?tstart=0#sthash.axeisnGW.dpuf


we could find a bug case #  JBPAPP-8451 for the about issue.

 

as a workaround, you have to set instance-id. and this worked for me.

 

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false" instance-id="hellnode01">

 

but i see this case status is closed. do i need to add any path my AS 7.1.1.

- See more at: https://developer.jboss.org/thread/201760?tstart=0#sthash.axeisnGW.dpuf