Jboss eap 7 configuration - java

I have downloaded the Jboss eap 7 to my system. I want to deploy my war/ ear file or configure my application source in the server. Can anyone help me with the steps for doing the same

You can deploy your ear/war using the JBoss Command Line Interface (CLI):
$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=127.0.0.1:9999 --user=manager --password=password deploy path/to/your.ear
This can be scripted if required. Undeploying is the same:
$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=127.0.0.1:9999 --user=manager --password=password undeploy your.ear

To stop, start, restart & status check the JBOSS service, use following commands :
• systemctl stop jboss-eap-rhel.service
• systemctl start jboss-eap-rhel.service
• systemctl restart jboss-eap-rhel.service
• systemctl status jboss-eap-rhel.service
To add management console user, use following steps :
• cd /data/jboss-eap-7.0/binlssh ./add-user.sh
• what type of user do you wish to add?
a. Management User (mgmt-users.properties)
b. Application User (application-users.properties)
• Enter a and go to next (i.e. (a) :a)
• Enter the details of the new user to add.
Using realm ‘ManagementRealm’ as discovered from the existing property files.
Username : xyz
• If user already exists, it shows update option otherwise it shows create option.
• User ‘xyz’ already exists and is enabled, would you like to…
a. Update the existing user password and roles
b. Disable the existing user
c. Type a new username
• Enter a and go to next (i.e. (a) :a)
• Password : ******
• What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none) [ManagementRealm] :
• Just leave as blank and enter
• Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a remoting connection for server to server EJB calls.
yes/no? yes
To add environment variable, use following steps :
• Go to following path i.e. ../jboss-eap-7.0/bin/ and open the file standalone.conf and add Denvironment=prod
Example:
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true -Denvironment=prod"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
If JBOSS 8080 and 9990 ports are unable to access from remote, use following steps :
Go to following path i.e. ../jboss-eap-7.0/standalone/configuration and open the file standalone.xml and point actual IP address as mentioned in example.
Example :
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:172.16.26.68}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:172.16.26.68}"/>
</interface>
</interfaces>

After configured above mentioned steps, hit this URL http://localhost:9990/console/App.html and then it shows authentication prompt window for management username and password. After that tap start link in Deployments tab. Choose the war file and deploy.

Related

Use Environment Variables in Standalone.xml for WildFly application on Linux VM

I am having trouble getting environment variables to resolve On a Linux VM when I start up a WildFly java application.
<system-properties>
<property name="java.util.logging.manager" value="org.jboss.logmanager.LogManager"/>
<property name="appname.url" value="https://${env.Environment}/appname"/>
</system-properties>
When I echo that environment variable (defined in /etc/environment) I get the following:
[ ~ ]$ echo $Environment
tst
I've tried updating the standalone.xml to have this these two properties set to true:
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
Also tried updating bin/jboss-cli.xml with this setting set to true:
<resolve-parameter-values>true</resolve-parameter-values>
Starting the application using it's service (i.e., systemctl restart appname) throws errors in the logs like this:
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("system-property" => "appname.url")]) - failure description: "WFLYCTL0211: Cannot resolve expression 'https://${env.Environment}/appname'"
Unfortunately, this does not resolve my issue. Any ideas?
Solution for this involved a few steps to get environment variables recognized by the WildFly app's service. It isn't exactly an environment variable, it's the closest you can get. Per this thread on stackexchange, service strips all environment variables, so they cannot be referenced. Therefore, you must create a file that stores those variables and then source it in startup.
Here they are:
Update bin/standalone.conf with a new line to include JAVA_OPTS="$JAVA_OPTS -Denv.Environment=$Environment"
Create /etc/default/appname file so it can be sourced later on. That file only contains the line Environment=tst
Update /etc/init.d/appname file with
[ -f /etc/default/appname ] && . /etc/default/appname
export Environment
reload systemctl's daemon systemctl daemon-reload
restart the service systemctl restart appname

Wildcard Subdomain In SpringBoot For my Mac

I am creating a web application in which there will be multiple subdomain. Each client will be having its own subdomain. Each subdomain will have individual database. For example I am having a client abc, then it will have subdomain as abc.mydomain.com and its database name will be abc.
Now this application is created in spring boot. Here I want to configure wildcard subdomain. So how can I configure it in spring boot. For this, I had tried few solution.
I had changed my /etc/hosts and added an domain name entry in it as below
127.0.0.1 www.mydomain.com
But now I want subdomain in this. How can I do it.
I had seen somewhere that I need to configure server.xml of tomcat. In server.xml I had added below line.
<Host name="www.mydomain.com" appBase="webapps" unpackWARs="true"
autoDeploy="true">
<Alias>*.mydomain.com</Alias>
</Host>
Can you please help me with this. Also let me know incase you need more details in this.
After been working for multiple days I came to a solution for this question. As I was working for wildcard subdomain in localhost. Thus for this I need to use an external software called dnsmasq, I had executed following commands to install dnsmasq in my laptop.
brew install dnsmasq
After installing dnsmasq in my laptop I need to to configure it. For this I have to update the dnsmasq. For my case it is located at
/usr/local/etc/dnsmasq.conf
In this file I have to add few lines to configure wildcard subdomain. Lines are as below.
# Route all *.mydomain.com addresses to localhost
address=/mydomain.com/127.0.0.1
# Don't read /etc/resolv.conf or any other configuration files.
no-resolv
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv
Next I need to restart my dnsmasq service. Command for it is as below.
sudo brew services start dnsmasq
Finally you need to create a file mydomain.com at /etc/resolver (Create folder resolver if not exists). Add below line in mydomain.com file.
nameserver 127.0.0.1
This is the complete configuration for setting up swildcard subdomain in your mac os.
For reference you can follow this link

Brooklyn Starting Blueprint: VMs created but Brooklyn can't SSH in

I have just started using Brooklyn and I am trying to get the example from the deploying blueprints page working fully through my AWS account.
The Maven build completed successfully and I can successfully launch the Brooklyn Web UI from ~/apache-brooklyn-0.7.0-M2-incubating/usage/dist/target/brooklyn-dist using the steps on the running Brooklyn page.
When I launch the blueprint, I can see all the VMs launching in my AWS Console UI. I can also see the key pairs and security groups created. But the blueprint eventually fails because (I believe) Brooklyn cannot ssh into the VMs, see the first log output below. I assume Brooklyn attempts to login to the VMs using the created key pairs somehow?
Based on the info in the locations page, I created a ~/.brooklyn/brooklyn.properties file and added the following configuration:
brooklyn.location.jclouds.aws-ec2.identity = MyAwsAccessKeyID
brooklyn.location.jclouds.aws-ec2.credential = MyAwsSecretAccessKey
brooklyn.location.jclouds.aws-ec2.privateKeyFile = /home/username/key4brooklyn.pem
I created the key4brooklyn.pemfile from the AWS Console UI and restarted Brooklyn however the blueprint still does not work, it creates the VMs but cannot access the VMs, see log output below.
2015-03-02 23:31:27,295 INFO Starting MySqlNodeImpl{id=lzJhHxwD}, obtaining a new location instance in JcloudsLocation[aws-ec2:MyAwsAccessKeyID/aws-ec2] with ports [22, 3306]
2015-03-02 23:31:27,369 INFO Starting NginxControllerImpl{id=QYRLgQPh}, obtaining a new location instance in JcloudsLocation[aws-ec2:MyAwsAccessKeyID/aws-ec2] with ports [22, 8000]
2015-03-02 23:31:27,612 INFO Resize DynamicWebAppClusterImpl{id=iJNs2ltC} from 0 to 1
2015-03-02 23:31:28,830 INFO Starting JBoss7ServerImpl{id=MWMGwHXx}, obtaining a new location instance in JcloudsLocation[aws-ec2:MyAwsAccessKeyID/aws-ec2] with ports [22, 9443, 10999, 8443, 8080, 9990]
2015-03-02 23:31:37,870 INFO Creating VM aws-ec2#MySqlNodeImpl{id=lzJhHxwD} in JcloudsLocation[aws-ec2:MyAwsAccessKeyID/aws-ec2]
2015-03-02 23:31:38,508 INFO Creating VM aws-ec2#JBoss7ServerImpl{id=MWMGwHXx} in JcloudsLocation[aws-ec2:MyAwsAccessKeyID/aws-ec2]
2015-03-02 23:31:38,983 INFO Creating VM aws-ec2#NginxControllerImpl{id=QYRLgQPh} in JcloudsLocation[aws-ec2:MyAwsAccessKeyID/aws-ec2]
2015-03-02 23:34:55,349 INFO Not able to load publicKeyData from inferred files, based on privateKeyFile: tried [/home/username/key4brooklyn.pem.pub] for aws-ec2#MySqlNodeImpl {id=lzJhHxwD}
2015-03-02 23:34:55,353 INFO Not able to load publicKeyData from inferred files, based on privateKeyFile: tried [/home/username/key4brooklyn.pem.pub] for aws-ec2#JBoss7ServerImpl {id=MWMGwHXx}
2015-03-02 23:34:55,351 INFO Not able to load publicKeyData from inferred files, based on privateKeyFile: tried [/home/username/key4brooklyn.pem.pub] for aws-ec2#NginxControllerImpl {id=QYRLgQPh}
I am using Ubuntu 14.04 with Oracle Java 7 installed, it is a VirtualBox VM.
Looking at the log output, the problem is here:
2015-03-02 23:34:55,349 INFO Not able to load publicKeyData from inferred files, based on privateKeyFile: tried [/home/username/key4brooklyn.pem.pub] for aws-ec2#MySqlNodeImpl {id=lzJhHxwD}
The privateKeyFile configuration key needs to specify an id_rsa or id_dsa style key pair in two files. The corresponding *.pub file will be auto-detected if publicKeyFile is not configured. There are better instructions for creating an ssh key available. It is confusing and better error reporting around keys (including fail-fast) is in the latest SNAPSHOT builds and will be included in the M3 milestone release. Also note that the id_rsa file must have one and only one private key and must not contain the public key. Tedious that there are so many formats!
The ~/.ssh/id_rsa or other configured key-pair is just used by Brooklyn for setting up ssh access to the VM after it is provisioned. By default, jclouds (which we use under the covers) will create a temporary AWS key-pair to get initial access to the VM. We'll then automatically add the ~/.ssh/id_rsa.pub to the VM's ~/.ssh/authorized_keys (creating a user on the VM that by default has the same name as the user who is running the Brooklyn process).
The key4brooklyn.pem file you downloaded is the private part of the AWS key-pair. By default, this will not be used because jclouds will create its own key-pair.
If you wanted jclouds to use your pre-existing key pair then you'd have to use the following configuration setting:
brooklyn.location.jclouds.aws-ec2.keyPair = MyKeypairName
Where MyKeypairName is the name of the key-pair according to AWS.

How to check if JMX agent is working in Tomcat?

I have a Tomcat 8 instance. I'm trying to connect to it from JColsole. In order to do so I have added to the setenv.bat the following line:
CATALINA_OPTS=%CATALINA_OPTS% -Dcom.sun.management.jmxremote.password.file=D:\Utils\Apache\Tomcat\conf\remote.users -Dcom.sun.management.jmxremote.access.file=D:\Utils\Apache\Tomcat\conf\remote.acl -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7777 -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost
and in those two files -- remote.users and remote.acl i have defined user test with password test and the role readwrite.
However I cannot connect via JConsole (I tried using url localhost:7777 and service:jmx:rmi://localhost:7777).
Further investigation showed, that I cannot even telnet to 7777.
What am I doing wrong?
As it happens, when Tomcat is running as a service on Windows, I don't need setenv.bat, I need to use tomcat8w.exe -- GUI toll for adding options

Hudson fails to use unix user/group to do authentication

I'm trying to use unix user/group database as security realm of hudson. The linux server is using NIS for user management. My account could login the hudson server via ssh.
And the hudson server is running by user 'hudson' that is also a member of group 'shadow', so hudson could read /etc/shadow. And I tested the configuration using 'test' button, hudson tells me it works well.
But I can't use my unix account and password to login the hudson sever.
And I found below java exception in the log of hudson,
Jan 12, 2011 8:23:42 AM hudson.security.AuthenticationProcessingFilter2 onUnsuccessfulAuthentication
INFO: Login attempt failed
org.acegisecurity.BadCredentialsException: pam_authenticate failed : Authentication failure; nested exception is org.jvnet.libpam.PAMException: pam_authenticate failed : Authentication failure
at hudson.security.PAMSecurityRealm$PAMAuthenticationProvider.authenticate(PAMSecurityRealm.java:100)
at org.acegisecurity.providers.ProviderManager.doAuthentication(ProviderManager.java:195)
at org.acegisecurity.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:45)
at org.acegisecurity.ui.webapp.AuthenticationProcessingFilter.attemptAuthentication(AuthenticationProcessingFilter.java:71)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:252)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:173)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:66)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
at winstone.FilterConfiguration.execute(FilterConfiguration.java:195)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368)
at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)
at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:244)
at winstone.RequestHandlerThread.run(RequestHandlerThread.java:150)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.jvnet.libpam.PAMException: pam_authenticate failed : Authentication failure
at org.jvnet.libpam.PAM.check(PAM.java:105)
at org.jvnet.libpam.PAM.authenticate(PAM.java:123)
at hudson.security.PAMSecurityRealm$PAMAuthenticationProvider.authenticate(PAMSecurityRealm.java:90)
... 18 more
Update on Jan. 17,
The host is RHEL 4.5, and I created user and group shadow, then add hudson into group shadow.
-bash-3.00$ cat /etc/redhat-release
Red Hat Enterprise Linux WS release 4 (Nahant Update 5)
-bash-3.00$ ll /etc/shadow
-r--r----- 1 root shadow 1114 Jan 4 11:37 /etc/shadow
-bash-3.00$ cat /etc/group |grep shadow
shadow:x:44:hudson
I also tried to setup hudson on another RHEL 4.8 host. This time I ran the hudson by root,
kzhu0#pek-wb-rhws4_32:~$ ps -ef|grep hudson
root 18764 29161 0 Jan14 pts/5 00:00:33 /usr/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DHUDSON_HOME=/var/lib/hudson -jar /usr/lib/hudson/hudson.war --logfile=/var/log/hudson/hudson.log --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
kzhu0 22404 18833 0 10:52 pts/2 00:00:00 grep hudson
kzhu0#pek-wb-rhws4_32:~$ cat /etc/redhat-release
But I still don't have luck to get unix user/password group work. And I can't find any pam error message in /var/log/messages and /var/log/secure. It looks like hudson throws the exception before actually using pam to get authentication.
Red Hat Enterprise Linux WS release 4 (Nahant Update 8)
I find the solution after debugging the code of libpam4j that is used by hudson for PAM security realm.
the service name must be 'sshd' in my case, because I want to use NIS to do authentication. RHEL 4.x uses the pam 0.77, it strictly depends on the service name specified by hudson. However my Ubuntu 10.04 accepts any meaningless service name, which uses pam 1.1.1.
the user who runs the hudson must have the permission to read the service file of pam, /etc/pam.d/sshd is the file in my case
In my case, ubuntu 10.04 Ihad to use ssh instead of sshd for the Service Name
I have struggled with this problem for many hours. At the end what worked for me:
1. Add 'hudson' user to root and shadow groups
2. Install sshd (missing in /etc/pam.d).
3. Set PAM service to login.
Then I could login to Hudson with Unix account and execute build as Unix user.
I think point 1 is the one which fixed issue.

Categories