Session Clustering Tomcat + terracotta on single server - session

I want to make session clustering with terracotta and 2 tomcat on single server.
i following instruction from :
http://artur.ejsmont.org/blog/content/how-to-setup-terracotta-session-clustering-and-replication-for-apache-tomcat-6
This is my tc-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<tc:tc-config xmlns:tc="http://www.terracotta.org/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-4.xsd">
<servers>
<server name="nodea" host="localhost">
<data>/home/meruvian/mydatafolder</data>
<logs>/home/meruvian/mylogsfolder</logs>
<l2-group-port>9530</l2-group-port>
</server>
<server name="nodeb" host="localhost">
<data>/home/meruvian/mydatafolder</data>
<logs>/home/meruvian/mylogsfolder</logs>
<l2-group-port>9530</l2-group-port>
</server>
</servers>
<clients>
<logs>/var/log/myclientlogsfolder</logs>
<modules>
<module name="tim-tomcat-6.0" version="2.2.0"/>
</modules>
</clients>
<application>
<dso>
<instrumented-classes>
<include>
<class-expression>*..*</class-expression>
</include>
<exclude>org.apache.coyote..*</exclude>
<exclude>org.apache.catalina..*</exclude>
<exclude>org.apache.jasper..*</exclude>
<exclude>org.apache.tomcat..*</exclude>
</instrumented-classes>
<web-applications>
<web-application>sessionapp</web-application>
</web-applications>
</dso>
</application>
</tc:tc-config>
Then when i try to execute command :
/start-tc-server.sh -f ~/Terracotta/terracotta-3.6.2/tc-config.xml
But i get error message like bellow :
Fatal Terracotta startup exception:
*******************************************************************************
You have not specified a name for your Terracotta server, and there are 2 servers defined in the Terracotta configuration file. The script can not automatically choose between the following server names: nodea, nodeb. Pass the desired server name to the script using the -n flag.
*******************************************************************************
What the meaning of
<web-application>sessionapp</web-application>
Is it my contex path of my app ?
Anyone can help me to solve this, to cluster session with tomcat + terracotta ?
Thanks

I am by no means an authority on Terracotta, but according to me,
there are 2 problems here:
You have specified 2 servers running on localhost, with no port specifications. Both will try to take up port 9510 (dso port) which will cause a problem. You need to specify different dso ports.
Assuming you do fix the port configuration, you have both your servers running on localhost, so terracotta needs to know the server you are trying to start.
Use this command to start nodea:
/start-tc-server.sh -f ~/Terracotta/terracotta-3.6.2/tc-config.xml -n nodea
Similarly for nodeb.
See if that helps.

Related

How do you join a Liberty collective on Linux?

I am trying to set up a Liberty collective using Docker hosts running linux. The videos they have about setting up Liberty collectives at the moment use Windows and are all on the same machine.
To join the collective so it appears on adminCenter isn't too hard it is just a matter of collective join --host=...
The problem is the administration part i.e. changing the configuration file or stopping and starting the servers is not working.
I tried various ways of passing in hostInfo in server.xml or --sshPrivateKey Hard coding root passwords and none of them work.
According to the instructions all you needed was an openssh-server which I have already enabled and running I have already exposed the ports and verify I can connect to them using a certificate from the controller container as well.
In addition based on the REST API it uses a stringified SSH Private Key itself rather than a file and that should be sent through the collective registerHost but it does not appear to work and there is nothing in the command line logs even with .level=ALL and ...consolelogger...=ALL that show what the hostAuthInfo is.
The one of the commands I ran for collective join is
collective join defaultServer \
--host=controller \
--port=9443 \
--user=adminUser \
--password=adminPassword \
--autoAcceptCertificates \
--rpcUser=root \
--sshPrivateKey=$HOME/.ssh/id_rsa \
--keystorePassword=$PASSWORD \
--createConfigFile=/config/collective-join-include.xml
I say one of because I tried various combinations where I removed or changed --rpcuser, --sshPrivateKey and other authInfo related items.
server.xml of member is at this point ...
<?xml version="1.0" encoding="UTF-8"?>
<server description="Application Server">
<featureManager>
<feature>javaee-7.0</feature>
<feature>clusterMember-1.0</feature>
<!--<feature>scalingMember-1.0</feature>-->
</featureManager>
<remoteFileAccess>
<writeDir>${server.config.dir}</writeDir>
</remoteFileAccess>
<httpEndpoint id="defaultHttpEndpoint" httpPort="9080" httpsPort="9443" host="*"/>
<!--<hostSingleton name="ScalingMemberSingletonService" port="5164" />-->
<applicationManager autoExpand="true"/>
<!--<hostAuthInfo rpcUser="root" sshPublicKeyPath="/root/.ssh/id_rsa.pub" sshPrivateKeyPath="/root/.ssh/id_rsa"/>-->
<include location="${server.config.dir}/collective-join-include.xml"/>
<dataSource id="myds" jndiName="jdbc/sample" type="javax.sql.XADataSource">
<jdbcDriver javax.sql.ConnectionPoolDataSource="org.mariadb.jdbc.MariaDbDataSource" javax.sql.DataSource="org.mariadb.jdbc.MariaDbDataSource" javax.sql.XADataSource="org.mariadb.jdbc.MariaDbDataSource">
<library>
<file name="${server.config.dir}/mariadb-java-client-1.5.9.jar"/>
</library>
</jdbcDriver>
<properties databaseName="jeesample" password="password" serverName="database" user="jeeuser"/>
</dataSource>
<basicRegistry id="basic" realm="BasicRealm">
<user name="websphere" password="{xor}KDo9LC83Oi06"/>
</basicRegistry>
<ejbContainer>
<timerService>
<persistentExecutor taskStoreRef="mystore"/>
</timerService>
</ejbContainer>
<databaseStore dataSourceRef="myds" id="mystore"/>
</server>
Controller side
<?xml version="1.0" encoding="UTF-8"?>
<server description="Collective Controller">
<variable name="defaultHostName" value="controller"/>
<httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080" httpsPort="9443"/>
<featureManager>
<!--<feature>scalingController-1.0</feature>-->
<feature>adminCenter-1.0</feature>
<feature>dynamicRouting-1.0</feature>
</featureManager>
<remoteFileAccess>
<writeDir>${server.config.dir}</writeDir>
</remoteFileAccess>
<!--<scalingDefinitions>
<defaultScalingPolicy enabled="true" min="2" max="2"/>
</scalingDefinitions>-->
<include location="${server.config.dir}/resources/collective/collective-create-include.xml"/>
<collectiveController user="adminUser" password="adminPassword"/>
</server>
By default, when ssh is properly configured and running on the linux machines (controller's and member's host machine), you only need to run the 'collective join' command from the member's wlp/bin dir. You should not need to specify hostInfo nor --sshPrivateKey via server.xml nor the collective updateHost/registHost commands. This flow will use the ssh keys generated by the collective.
The useHostCredentials flag is generally meant to be used with rpcUser and rpcUserPassword (provided via registerHost, updateHost, or server.xml) instead of ssh, especially useful for systems that do not have ssh configured (like windows by default). However, it can also be used to specify custom ssh keys.
If you're still having trouble, provide the collective join command that was ran from the member's wlp/bin, as well as the server.xml of the controller and member.

How do I get the Tomcat 7 Embedded container to use another port?

I have Arquillian setup in Gradle to spin up a REST server and run some tests against a REST client. Everything works fine, except for the fact that the server hosting the CI already uses port 8080.
I have added the following settings to my build.gradle file
arquillian {
containers {
tomcat {
version = '7'
config = ['bindHttpPort': 18080]
type = 'embedded'
}
}
}
But it has no effect. How can I change the port used by the embedded tomcat 7 container?
EDIT
There is a workaround, which is to have the following in a file called arquillian.xml. Still, it would be nice to have the option of defining the port in the build.gradle file.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="tomcat" default="true">
<configuration>
<!-- We need to change the port from the default of 8080 because 8080 is quite commonly not available -->
<property name="bindHttpPort">18080</property>
</configuration>
</container>
</arquillian>

IBM Websphere Liberty Profile:How to map Public IP Address in Websphere

I am trying to map my server public ip addresss in Websphere LP server.xml file but when i tried to access it from outside i am getting a connection error. I tried giving host="localhost" and tried to access from server itself,it is working fine.
Is there anything i need to configure in Websphere LP to access it from outside.
Server.xml file
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.2</feature>
<feature>localConnector-1.0</feature>
</featureManager>
<httpEndpoint host="*" httpPort="8007" httpsPort="9443" id="defaultHttpEndpoint"/>
<applicationMonitor updateTrigger="mbean"/>
<library id="worklight-6.0.0">
<fileset dir="C:\IBM\Liberty\usr\shared\resources" includes="worklight-jee-library-6.0.0.jar"/>
</library>
<library id="apps-common">
<fileset dir="C:\IBM\Liberty\usr\shared\resources" includes="org.hsqldb.hsqldb_2.2.5.jar"/>
</library>
<application context-root="/DemoApp" id="DemoApplication" location="DemoApplication.war" name="DemoApplication" type="war">
<classloader commonLibraryRef="worklight-6.0.0,apps-common"/>
</application>
</server>
Any help is appreciated.
As per the InfoCenter document for the httpEndpoint configuration element, here: http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/topic/com.ibm.websphere.wlp.doc/autodita/rwlp_metatype_4ic.html?resultof=%22%68%74%74%70%65%6e%64%70%6f%69%6e%74%22%20#mtFile121
A hostname of * will bind to all available network interfaces - you do not need to do anything extra on the Liberty side, which I believe answers your question.
Setting the hostname to 'localhost' will mean the http endpoint is only accessible from your machine.
Using the configuration as supplied (hostName of *), this should work remotely - so it is likely a firewall issue.
You can check the /servers/yourServer/logs/messages.log file to verify which interfaces your endpoint is binding to - look for a message of the form
WWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host localhost (IPv4: 127.0.0.1) port 9080.

Spring deployment-level configuration

When I wrote Java EE apps, I used JBoss Datasources to control which databases the deployment used. E.g. the dev versions would use a throwaway hibernate db, the ref and ops would use stable MySQL deployments. I also used MBeans to configure various other services and rules.
Now that I'm using Spring, I'd like the same functionality - deploy the same code, but with different configuration. Crucially, I'd also like Unit Tests to still run with stub services. My question is this - is there a way, in JBoss, to inject configuration with files which live outside of the WAR/EAR, and also include these files in test resources.
It is possible to add objects into the JNDI context by placing a file named xxx-service.xml into jboss's deploy directory. The app could then lookup the values via JNDI. In the example below the string "development" is added at java:/modes/deployment. To use JNDI in your unit tests use the org.springframework.mock.jndi package.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server PUBLIC "-//JBoss//DTD MBean Service 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd">
<server>
<mbean code="org.jboss.naming.JNDIBindingServiceMgr"
name="c3po.naming:service=jndi-bindings">
<attribute name="BindingsConfig" serialDataType="jbxb">
<jndi:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jndi="urn:jboss:jndi-binding-service:1.0"
xs:schemaLocation="urn:jboss:jndi-binding-service:1.0 resource:jndi-binding-service_1_0.xsd"
>
<jndi:binding name="java:/modes/deployment">
<jndi:value type="java.lang.String">development</jndi:value>
</jndi:binding>
<jndi:binding name="java:/sites/abc">
<jndi:value type="java.lang.String">dev.site.example.com</jndi:value>
</jndi:binding>
<!-- Examples:
<jndi:binding name="urls/jboss-home">
<jndi:value type="java.net.URL">http://www.jboss.org</jndi:value>
</jndi:binding>
<jndi:binding name="hosts/localhost">
<jndi:value editor="org.jboss.util.propertyeditor.InetAddressEditor">
127.0.0.1
</jndi:value>
</jndi:binding>
<jndi:binding name="maps/testProps">
<java:properties xmlns:java="urn:jboss:java-properties"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="urn:jboss:java-properties resource:java-properties_1_0.xsd">
<java:property>
<java:key>key1</java:key>
<java:value>value1</java:value>
</java:property>
<java:property>
<java:key>key2</java:key>
<java:value>value2</java:value>
</java:property>
</java:properties>
</jndi:binding>
-->
</jndi:bindings>
</attribute>
<depends>jboss:service=Naming</depends>
</mbean>
</server>

Oracle Coherence Cache Clustering

We have two web-application that use two different version of Embedded Coherence Cache:
Application 1 with Coherence 3.7.1 (run in JDK7 environment with Weblogic Server 12.1.2)
Application 2 with Coherence 12.2.1 (run in JDK8 environment with Weblogic Server 12.2.1)
each application deployed in different weblogic server. we try tangosol-override.xml with following configuration for cluster cache of this applications:
Application 1 config:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-operational-config coherence-operational-config.xsd">
<cluster-config>
<unicast-listener>
<well-known-addresses>
<socket-address id="1">
<address>10.7.17.31</address>
<port>8088</port>
</socket-address>
<socket-address id="2">
<address>10.7.17.31</address>
<port>9099</port>
</socket-address>
</well-known-addresses>
<address system-property="tangosol.coherence.localhost">localhost</address>
<port system-property="tangosol.coherence.localport">8088</port>
<port-auto-adjust system-property="tangosol.coherence.localport.adjust">true</port-auto-adjust>
</unicast-listener>
</cluster-config>
<license-config>
<edition-name system-property="tangosol.coherence.edition">GE</edition-name>
<license-mode system-property="tangosol.coherence.mode">prod</license-mode>
</license-config>
</coherence>
Application 2 config:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-operational-config coherence-operational-config.xsd">
<cluster-config>
<unicast-listener>
<well-known-addresses>
<socket-address id="1">
<address>10.7.17.31</address>
<port>8088</port>
</socket-address>
<socket-address id="2">
<address>10.7.17.31</address>
<port>9099</port>
</socket-address>
</well-known-addresses>
<address system-property="tangosol.coherence.localhost">localhost</address>
<port system-property="tangosol.coherence.localport">9099</port>
<port-auto-adjust system-property="tangosol.coherence.localport.adjust">true</port-auto-adjust>
</unicast-listener>
</cluster-config>
<license-config>
<edition-name system-property="tangosol.coherence.edition">GE</edition-name>
<license-mode system-property="tangosol.coherence.mode">prod</license-mode>
</license-config>
</coherence>
but all caches are not reachable from another application.
What is the problem?
After some research the following solution works for me. I set tangosol-override.xml in startup script of two Weblogic servers and remove other parameters related to coherence cache (-Dtangosol.coherence.override=C:\root\tangosol-coherence-override.xml).
tangosol-coherence-override.xml config File :
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-operational-config coherence-operational-config.xsd">
<cluster-config>
<member-identity>
<cluster-name>appclustername</cluster-name>
</member-identity>
<multicast-listener>
<address>224.1.1.1</address>
<port>12345</port>
</multicast-listener>
</cluster-config>
<license-config>
<edition-name system-property="tangosol.coherence.edition">GE</edition-name>
<license-mode system-property="tangosol.coherence.mode">prod</license-mode>
</license-config>
</coherence>

Resources