JBoss AS 7 with two webapps on different HTTP ports?

To replace the outdated service, I'm interested in having two different webapps on two different HTTP port numbers, for example 8080 → webapp1 (browser service), 8200 → webapp2 (REST, the new version uses RESTEasy). Each of these will be the "root context" on this port number.

The "standard" answer on this site refers to JBoss 5, which is the two major versions in history and has a zillion configuration format change.

I am using JBoss AS 7.0.2.Final and a "standalone" deployment. Has anyone done this and can use the configuration used? Thanks.

+8
web-applications configuration ports
source share
3 answers

Managed Domain

You might want to run an instance of a managed domain. This will allow you to support two server instances using a web application each, as well as the ease of supporting port and interface declarations from a single console view.

The goal will be one managed domain with two servers. Each server will belong to a different server group. Each server group will have its own interface or port declarations that you require.

This gives you a single management console with a set of relative server groups for assigning your current and future servers, with the ability to change, reassign, or shutdown on the fly.

Configuration

The files you need to know about are the host.xml and domain.xml configuration files in the following file path.

~/JBOSS_HOME/domain/configuration

From domain.xml we can see socket binding groups. The following example is a standard group called Standard Sockets, but you can create as many groups as you want, with as many or as few declarations as you need.

  <socket-binding-groups> <socket-binding-group name="standard-sockets" default-interface="public"> <socket-binding name="ajp" port="8009"/> <socket-binding name="http" port="8080"/> <socket-binding name="https" port="8443"/> <socket-binding name="osgi-http" interface="management" port="8090"/> <socket-binding name="remoting" port="4447"/> <socket-binding name="txn-recovery-environment" port="4712"/> <socket-binding name="txn-status-manager" port="4713"/> <outbound-socket-binding name="mail-smtp"> <remote-destination host="localhost" port="25"/> </outbound-socket-binding> </socket-binding-group> ... 

You can create two socket binding groups for your needs, serving two sets of ports that you may need. Once they exist, you want the server group to know about them. Let's look further in the domain.xml file.

In the following example, we see that the server group refers to the socket binding group. For bonus points, we see that some applications are used for them. This happened through the Management Console, but AS 7 does not support console and CLI configuration.

  <server-groups> <server-group name="main-server-group" profile="full"> <jvm name="default"> <heap size="1303m" max-size="1303m"/> <permgen max-size="256m"/> </jvm> <socket-binding-group ref="full-sockets"/> <deployments> <deployment name="your_application.jar" runtime-name="your_application.jar"/> <deployment name="your_application_02.ear" runtime-name="your_application_02.ear"/> <deployment name="test.war" runtime-name="test.war"/> </deployments> </server-group> <server-group name="other-server-group" profile="full-ha"> <jvm name="default"> <heap size="1303m" max-size="1303m"/> <permgen max-size="256m"/> </jvm> <socket-binding-group ref="full-ha-sockets"/> <deployments> <deployment name="your_application_02.ear" runtime-name="your_application_02.ear"/> <deployment name="test.war" runtime-name="test.war"/> </deployments> </server-group> </server-groups> 

The domain.xml file is the configuration of the domain controller, which is the "boss" of the managed domain. The actual server information is contained in the main controller, so let's look at the host.xml file.

 <servers> <server name="server-one" group="main-server-group"> </server> <server name="server-two" group="main-server-group" auto-start="true"> <!-- server-two avoids port conflicts by incrementing the ports in the default socket-group declared in the server-group --> <socket-bindings port-offset="150"/> </server> <server name="server-three" group="other-server-group" auto-start="false"> <!-- server-three avoids port conflicts by incrementing the ports in the default socket-group declared in the server-group --> <socket-bindings port-offset="250"/> </server> </servers> 

We can see three servers in the default domain. The third is a member of the other-server-group , and the first two are members of the main-server-group . Also pay attention to port binding declarations.

You can delete the third server and assign the server server and the second server to the first and second web applications, respectively. Each server can belong to a unique group. Each group can declare a unique port. After that, you are ready to deploy your applications in your respective groups, and you have left.

Using management tools

XML is displayed in the examples, but you must use the Management Console or Management CLI when setting up the installation. The console is quite simple, so some CLI operations will help you here.

To display server groups:

[domain@localhost:9999 /] /server-group=*:read-resource(include-runtime=true)

To show socket binding groups:

[domain@localhost:9999 /] /socket-binding-group=*:read-resource(include-runtime=true)

You want to show specific http attribute values ​​so that we can modify our CLI operation to work with this child node. Enabling the runtime parameter helps us catch something that happened at runtime that was not written or saved on the server model.

[domain@localhost:9999 /] /socket-binding-group=standard-sockets/socket-binding=http:read-resource(include-runtime=true)

And this is how you write.

[domain@localhost:9999 /] /socket-binding-group=standard-sockets/socket-binding=http:write-attribute(name=port,value=8081)

That should get you started. As you can understand, I am a fan of the managed domain ...

+6
source

Create two separate standalone configurations, then at startup specify the correct configuration file with the -c option.

For example, let's say you copied the default standalone.xml file as the starting point for the first instance to a file called standalone-server1.xml. Then you start this instance with the following command:

 $jboss_home/bin/standalone.sh -c standalone-server1.xml 

Make sure you edit the socket-binding-group options, if necessary, to avoid port conflicts. Consider using the port-offset property to have JBoss automatically hit your port numbers for you.

+3
source

Thanks @ddri, According to the steps pointed out by @ddri, I want to add a few things, I followed all the steps you mentioned @ddri, but my applications were not deployed to specific ports, I want to make a correction (which worked in my case)

Step 1 Open the domain.xml file and select any socket binding group that you want to use, by default we have

 1) standard-sockets 2) ha-sockets 3) full-sockets 4) full-ha-sockets 

I used 2,3. Here is my fragment

 <socket-binding-group name="ha-sockets" default-interface="public"> <socket-binding name="ajp" port="8009"/> <socket-binding name="http" port="8888"/> <socket-binding name="https" port="8443"/> <socket-binding name="jgroups-diagnostics" port="0" multicast-address="224.0.75.75" multicast-port="7500"/> <socket-binding name="jgroups-mping" port="0" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/> <socket-binding name="jgroups-tcp" port="7600"/> <socket-binding name="jgroups-tcp-fd" port="57600"/> <socket-binding name="jgroups-udp" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/> <socket-binding name="jgroups-udp-fd" port="54200"/> <socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/> <socket-binding name="osgi-http" interface="management" port="8090"/> <socket-binding name="remoting" port="4447"/> <socket-binding name="txn-recovery-environment" port="4712"/> <socket-binding name="txn-status-manager" port="4713"/> <outbound-socket-binding name="mail-smtp"> <remote-destination host="localhost" port="25"/> </outbound-socket-binding> 

Step 2 In the domain.xml find <server-groups> file, configure your <socket-binding-group> for each of them, here is my snippet

 <server-groups> <server-group name="1st-server-group" profile="ha"> <jvm name="default"> <heap size="64m" max-size="512m"/> </jvm> <socket-binding-group ref="ha-sockets"/> </server-group> <server-group name="2nd-server-group" profile="full-ha"> <jvm name="default"> <heap size="64m" max-size="512m"/> </jvm> <socket-binding-group ref="full-ha-sockets"/> </server-group> 

Step 3 Open host.xml and confirm your server using a server group

 <servers> <server name="server-one" group="1st-server-group"> </server> <server name="server-two" group="2nd-server-group"> </server> 

Step 4 Go to the {JBoss_Home}/bin and run the domain.bat file and make sure that there are no exceptions for the already bound port.

==================================================== ============================== Step 5 Open jboss-cli from {JBoss_Home}/bin and enter

 connect 

and make sure that you are using jboss in your domain configuration and not a standalone configuration

 [domain@localhost:9999 /] 

To deploy any type of application

 deploy FacebookTool.war --server-groups=1st-server-group 

and make sure that all applications that you use must have a </distributable> in their web.xml.

Now you can run two applications on different ports of the same jboss instance :)

+1
source

All Articles