JBoss学习

来源:互联网 发布:求数组平均值 编辑:程序博客网 时间:2024/06/05 19:30

最近项目要开发一个基于H5的点对点聊天界面,通过websocket技术实现。但是服务器使用Jboss eap 6.3, 网上资料不多,jboss也是第一次学习遇到很多困难,现针对遇到的问题进行整理。

环境:需要jdk1.7+

jboss 下载:Jboss下载地址

修改配置支持websocket:  修改文件jboss_home/standalone/configuration/standalone.xml

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">    <connector name="http" protocol="<span style="color:#FF0000;"><strong>org.apache.coyote.http11.Http11NioProtocol</strong></span>" scheme="http" socket-binding="http"/>    <virtual-server name="default-host" enable-welcome-root="true">    <alias name="localhost"/>        <alias name="example.com"/>    </virtual-server></subsystem>

添加websocket支持jar包:

<dependency>    <groupId>javax.websocket</groupId>    <artifactId>javax.websocket-api</artifactId>    <version>1.1</version></dependency>



<dependency>    <groupId>org.jboss.spec.javax.websocket</groupId>    <artifactId>jboss-websocket-api_1.0_spec</artifactId>    <version>1.0.0.Final</version></dependency>


应用程序添加jboss-web.xml:

在WEB-INF目录创建jboss-web.xml,内容如下:

<?xml version="1.0" encoding="UTF-8"?><!--    JBoss, Home of Professional Open Source    Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual    contributors by the @authors tag. See the copyright.txt in the    distribution for a full listing of individual contributors.    Licensed under the Apache License, Version 2.0 (the "License");    you may not use this file except in compliance with the License.    You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0    Unless required by applicable law or agreed to in writing, software    distributed under the License is distributed on an "AS IS" BASIS,    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    See the License for the specific language governing permissions and    limitations under the License.--><!DOCTYPE jboss-web><jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://www.jboss.org/schema/jbossas     http://www.jboss.org/schema/jbossas/jboss-web_7_2.xsd">    <!-- Configure to enable WebSockets -->    <enable-websockets>true</enable-websockets></jboss-web>


部署应用程序: 将war包放到jboss_home/standalone/deployments目录下即可

启动服务: jboss_home/bin/standalone.bat

访问应用:http://localhost:8080/websocket

项目示例源代码:

示例应用源代码

项目示例war包:



1 0
原创粉丝点击