# Marcus setup on Windows
For setting up Marcus on MAC, use [marcus-setup-guide.md](https://github.com/NexTraq/marcus/blob/develop/docs/marcus-setup-guide.md)
This instruction is [available](https://nextraq.atlassian.net/wiki/spaces/DOO/pages/2305196036/Marcus+setup+on+Windows) in Confluence
### Resources:
- [marcus-setup-quide.md](https://github.com/NexTraq/marcus/blob/develop/docs/marcus-setup-guide.md)
- [README.md - Jboss6](https://github.com/NexTraq/jboss-eap-6.4.19/blob/master/README.md )
- [apache-2.4-docker-setup-guide.md](https://github.com/NexTraq/jboss-eap-7/blob/master/apache-2.4.37-local-mac/apache-2.4-docker-setup-guide.md)
- [README.md - Jboss7](https://github.com/NexTraq/jboss-eap-7/blob/master/README.md)
- [intellij.md](https://github.com/NexTraq/marcus/blob/develop/docs/intellij.md)
## Preparation before marcus installation
### Edit hosts file
Add the following to your hosts file `C:\Windows\System32\drivers\etc\hosts`
```powershell
127.0.0.1 go.me.nextraq.com
127.0.0.1 m.me.nextraq.com
127.0.0.1 api.me.nextraq.com
```
#### In case you don’t have admin permissions with Symantec client installed
You can use powershell as administrator (request admin rights from your administrator)
1. Run Powershell as Administrator
```powershell
> cd C:\Windows\System32\drivers\etc
> notepad.exe .\hosts
```
2. Add to the end of the file
```powershell
127.0.0.1 go.me.nextraq.com
127.0.0.1 m.me.nextraq.com
127.0.0.1 api.me.nextraq.com
```
3. Save changes
### Connect VPN
Talk to your IT administrator to get access to the VPN. In general, you will need credentials (login and password).
1. VPN configuration:
- You can use the following link: <https://vpn.nextraq.com/+CSCOE+/logon.html#form_title_text>
- Another approach is Cisco Client
If it's not already installed, install the most recent version of the Cisco AnyConnect client from [https://vpn.nextraq.com](https://vpn.nextraq.com/) (Open in browser, not VPN client)
2. Connect to <vpn.nextraq.com> using the credentials provided by the administrator.
3. ALWAYS connect to the VPN before building Marcus because our maven repository (Artifactory) is in our datacenter.
### Setup Java
Install JDK 8 via [Oracle](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) (ask developers for jdk-8u152-windows-x64.exe as we have it already downloaded)
Use PowerShell as administrator:
```powershell
> cd C:\Users\$UserName\Downloads\
> .\jdk-8u152-windows-x64.exe
```
## Marcus installation
### Setup git and Marcus source code
Note: We [NexTraq] are in the middle of upgrading Jboss from 6 to 7. It is recommended to maintain 2 copies of the marcus repo to avoid confusing IntelliJ when changing the gradle.properties file to test the two versions. See Jboss 6 instructions below for link to Jboss 7 instructions.
1. Check out from git
```powershell
> cd C:\Users\$UserName>cd IdeaProjects
> git clone <https://github.com/NexTraq/marcus.git>
```
2. (Recommended) Create environment variable (use PowerShell for this)
```powershell
> [System.Environment]::SetEnvironmentVariable('MARCUS_HOME','C:\Users\$UserName\IdeaProjects\marcus')
```
### Install node.js
`marcus` uses node 12.18.3 and `marcus-web` uses node 16.16.0. To install both we should use `nvm`
1. Delete any existent nodes (to check type in terminal `node -v`)
2. Download nvm installer from the [reference](https://github.com/coreybutler/nvm-windows/releases)
3. Install using Powershell:
```powershell
> cd C:\Users\$UserName\the\path\where\installer\lies
> .\nvm-setup.exe
```
4. Install nodes
```powershell
nvm install 12.18.3
nvm install 16.16.0
```
5. Switch to 16.16.0 version and update `yarn`
```powershell
nvm use 16.16.0
npm install -g yarn
```
6. Check that everything is installed and switch between nodes
```powershell
nvm list
nvm use 12.18.3
nvm use 16.16.0
```
[Guide about nvm installation for personal familiarization](https://www.freecodecamp.org/news/nvm-for-windows-how-to-download-and-install-node-version-manager-in-windows-10/)
### (Optional) Cleanup `.gitignore`
Only if you are copying Marcus repo from a Windows machine.
```powershell
> cd $env:MARCUS_HOME
> git clean -fd web\src\main\webapp\resources\
```
### (Only for JBoss 7) Edit `gradle.properties`
1. Copy `gradle.properties.template` to root folder and rename it to `gradle.properties`.
2. Add or uncomment property `projectVersion=8.XX.XX-SNAPSHOT`.
> It’s not a big deal which version you define, I used 8.XX.XX-SNAPSHOT and it worked fine.
3. Add property `targetJboss7=whatever`.
> You can put something else instead of “whatever”, but you should define non empty value otherwise you will face the following problem:
> `{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"marcusadmin-DENIS-SNAPSHOT.war\".FIRST_MODULE_USE" => "WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"marcusadmin-DENIS-SNAPSHOT.war\"
Caused by: java.lang.IncompatibleClassChangeError: Failed to link org/hibernate/ejb/HibernatePersistence (Module \"deployment.marcusadmin-DENIS-SNAPSHOT.war\" from Service Module Loader): class org.hibernate.ejb.HibernatePersistence has interface org.hibernate.ejb.AvailableSettings as super class"}`
### Build marcus
(**Reminder**: you need the STG_MFA VPN turned on for this step)
1. Open file `$MARCUS_HOME\master\shared\base.gradle` and change 5-th line:
- from `def artifactoryContextUrl = http://rnh01vart01.prd.nextraq.com:8081/artifactory`
- to `def artifactoryContextUrl = https://artifactory.prd.nextraq.com/artifactory`
2. Build marcus
- If you're using command line:
`> cd $env:MARCUS_HOME`
`> .\gradlew buildAll`
- If you're using IntellijIDEA
*double tap CTRL* (Run Anything)
run `buildAll`
### Apache Server Setup
Setup (for static resources access) via Docker for both JBoss 6 and JBoss 7 approaches same instruction.
1. Install Docker Desktop.
2. Obtain the SSL cert files from your old apache install or another developer. Place `server.crt` and `server.key` in the `$JBOSS7_HOME\apache-2.4.37-local-mac` directory, same as the `Dockerfile`.
3. Determine the full path to your Marcus `static_resources` output directory. For example, `C:\Users\$UserName\IdeaProjects\marcus\static_resources\output`. Referred to as ``<MARCUS_SR_OUT>` for the rest of this document.
4. Open a Terminal in the `$JBOSS7_HOME\apache-2.4.37-local-mac` directory. Build the docker image via the `Dockerfile`, naming the image **me-nt-apache**:
```powershell
> docker build -t me-nt-apache .
```
5. Edit the following command to update `<MARCUS_SR_OUT>` as discussed above. Run the command to start the container
```powershell
> docker run -dit --name me-nt-apache1 -p 443:443 -p 80:80 -p 6666:6666 -v <MARCUS_SR_OUT>:/var/www/html me-nt-apache
```
### Set up JBoss EAP 6
#### Acquire Jboss 6
1. Check out JBoss from git wherever you keep your source code
```powershell
> git clone https://github.com/NexTraq/jboss-eap-6.4.19`
```
2. It is recommended to add an environment variable
```powershell
> [System.Environment]::SetEnvironmentVariable('JBOSS6_HOME','C:\Users\$UserName\IdeaProjects\jboss-eap-6.4.19')
```
#### Configure JBoss 6
1. Backup the files `$JBOSS6_HOME\standalone\configuration\standalone-*-ha.xml`
2. Copy the files
- from `$MARCUS_HOME\deploy\jboss\jboss-eap-6.4\host-template\opt\jboss\jboss-eap-6.4\standalone\configuration\standalone-*-ha.xml`
- to `$JBOSS6_HOME\standalone\configuration` directory
3. Copy the `standalone-properties` folder
- from `$MARCUS_HOME\deploy\jboss\jboss-eap-6.4\host-template\opt\jboss\jboss-eap-6.4\bin\standalone-properties`
- to `$JBOSS6_HOME\bin` directory
4. Copy generated WAR files to `$JBOSS6_HOME\standalone\deployments`
- `$MARCUS_HOME\web\build\libs\ROOT-*.war`
- `$MARCUS_HOME\web_admin\build\libs\marcusadmin-*.war`
5. Add the following properties to the `$JBOSS6_HOME\bin\standalone-properties\nextraq-standalone-local-overrides.properties` file:
```
com.nextraq.config.jboss.domain.modcluster.proxy1.host = rnh01vweb04.dev.nextraq.com
com.nextraq.config.jboss.domain.modcluster.proxy1.port = 6666
com.nextraq.config.jboss.domain.modcluster.proxy2.host = rnh03vweb04.dev.nextraq.com
com.nextraq.config.jboss.domain.modcluster.proxy2.port = 6666
com.nextraq.config.marcus.hoursofservice.url.att = <https://elogs.dev.nextraq.com>
```
6. Edit `standalone.conf.bat` file to avoid timezone exception:
```
2022-10-25 23:47:54,404 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/marcusadmin].[dispatcher]] (ajp-/127.0.0.1:8009-1) JBWEB000235: Allocate exception for servlet dispatcher: com.dw.marcus.exception.UnknownEnumerationException: No TimeZone exists for offset (in minutes): 60
at com.dw.marcus.domain.db.TimeZone.valueOf(TimeZone.java:417) [nt-core-DENIS2-SNAPSHOT.jar:DENIS2-SNAPSHOT-24e4c6f]
at com.dw.marcus.core.utils.DateUtils.utc(DateUtils.java:448) [nt-core-DENIS2-SNAPSHOT.jar:DENIS2-SNAPSHOT-24e4c6f]
```
The fix implies changing VM options
In `standalone.conf.bat` replace line 49 with the following line
```
set "JAVA_OPTS=-Xms1G -Xmx1G -XX:MaxPermSize=256M -Duser.timezone=UTC"
```
#### Start JBoss.
(**Reminder**: Use DEV VPN because it has access to DEV DB).
You can create a `start.bat` file which contains this script:
```powershell
> .\standalone.bat -c standalone-web-ha.xml -P standalone-properties/dev/nextraq-standalone-common.properties -P standalone-properties/dev/nextraq-standalone-web-1.properties -P standalone-properties/nextraq-standalone-local-overrides.properties
```
Put this file in the `$JBOSS6_HOME\bin` directory. Then execute script:
```powershell
> cd $JBOSS6_HOME\bin
> .\start.bat
```
#### Check if Jboss is working
- Open a browser to <http://localhost:9990/console/index.html>
Username: admin
Password: admin
> Password for Jboss7 isn't the same, this only goes with Jboss 6
- Another approach of starting JBoss server using IntelliIJ IDEA is described on the following page <https://github.com/NexTraq/marcus/blob/develop/docs/intellij.md>
### Set up JBoss EAP 7
#### Acquire Jboss
1. Check out JBoss from git wherever you keep your source code
```powershell
> git clone https://github.com/NexTraq/jboss-eap-7
```
2. It is recommended to add an environment variable
```powershell
> [System.Environment]::SetEnvironmentVariable('JBOSS7_HOME','C:\Users\$UserName\IdeaProjects\jboss-eap-7\jboss-eap-7.x-local')
```
#### Configure Jboss
1. **Important**: There is no need to copy any configuration (\*.xml) files as it is supposed to be done for JBoss 6 as it will cause build/startup problems.
2. Copy the `standalone-properties` folder
- from `$MARCUS_HOME\deploy\jboss\jboss-eap-6.4\host-template\opt\jboss\jboss-eap-6.4\bin\standalone-properties`
- to `$JBOSS7_HOME\ jboss-eap-7.x-local\bin` directory
3. Add the following properties to the `$JBOSS7_HOME\jboss-eap-7.x-local\bin\standalone-properties\nextraq-standalone-local-overrides.properties` file:
```
com.nextraq.config.jboss.domain.modcluster.proxy1.host = rnh01vweb04.dev.nextraq.com
com.nextraq.config.jboss.domain.modcluster.proxy1.port = 6666
com.nextraq.config.jboss.domain.modcluster.proxy2.host = rnh03vweb04.dev.nextraq.com
com.nextraq.config.jboss.domain.modcluster.proxy2.port = 6666
com.nextraq.config.marcus.hoursofservice.url.att = https://elogs.dev.nextraq.com
```
4. Copy the WAR files to the `$JBOSS7_HOME\standalone\deployments\` directory
- `$MARCUS_HOME\web\build\libs\ROOT-8.x.x.SNAPSHOT.war`
- `$MARCUS_HOME\web\admin\build\libs\marcusadmin-8.x.x.SNAPSHOT.war`
> Note: If you want Hawito to work in JBoss 7, you need to copy the Hawito war file to the `$JBOSS7_HOME\standalone\deployments\` directory from `$JBOSS6_HOME\standalone\deployments\` after successful deployment to JBoss 6
5. Edit `standalone.conf.bat` file. Why? Because you’ll get “`java.lang.OutOfMemoryError: Metaspace`” and timezone exception. We need to fix it by adjusting VM options.
In `standalone.conf.bat` replace line 49 with the following line
```
set "JAVA_OPTS=-Xms1G -Xmx1G -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=2048m -Duser.timezone=UTC"
```
#### Start JBoss.
**Use DEV VPN cause it has access to DEV DB**.
You can create a start.bat file which contains this script:
```powershell
> .\standalone.bat -c standalone-web-ha.xml -P standalone-properties/dev/nextraq-standalone-common.properties -P standalone-properties/dev/nextraq-standalone-web-1.properties -P standalone-properties/nextraq-standalone-local-overrides.properties
```
Put this file in the `$JBOSS7_HOME\bin` directory. Then execute script:
```powershell
> cd $JBOSS7_HOME\jboss-eap-7.x-local\bin
> .\start.bat
```
**To stop jboss, highlight the terminal window, hold CTRL + C to terminate JBoss.**
### Jboss Management Console
The JBoss Management Console is a web app that can be used to manage all aspects of the jboss server configuration at runtime; e.g. edit the values in the `standalone-web-ha.xml` file.
1. Start Jboss via command above.
2. Open a browser to <http://localhost:9990/console/index.html>
- Username: admin
- Password: nextraq1!
3. Another approach of starting JBoss server using IntelliIJ IDEA is described on the following page <https://github.com/NexTraq/marcus/blob/develop/docs/intellij.md>
## Verify
1. Connect to VPN.
2. Start apache Docker container
3. Start jboss/deploy app
4. Each of the following links should resolve http and https
5. JBoss
- JBoss admin console - <http://go.me.nextraq.com:9990>
JBoss 6 - user: **admin**; pass: **admin**
JBoss 7 – user: **admin**; pass: **nextraq1!**
- HawtIO console - <http://go.me.nextraq.com:8080/hawtio> (user/pass: admin)
6. web
- Confirm bundled link - <http://go.me.nextraq.com/assets/js/app-bundle.js>
- Confirm legacy link - <http://go.me.nextraq.com/resources/images/logo.nextraq.transbg.png>
7. web_admin
- Confirm bundled link - <http://go.me.nextraq.com/marcusadmin/assets/js/admin/app-bundle.js>
1. Confirm legacy link - <http://go.me.nextraq.com/marcusadmin/resources/images/logo.nextraq.transbg.png>
8. (Optional) confirm modcluster link - <http://go.me.nextraq.com:6666/mc>
## IDE
- If you're using IntelliJ, follow the setup instructions [here](https://github.com/NexTraq/marcus/blob/develop/docs/intellij.md#intellij-idea-installation) and [here](https://github.com/NexTraq/marcus/blob/develop/docs/intellij.md#importing-the-marcus-project).
- TODO: Eclipse
## Known Issues and Solutions On Windows
### Chrome cannot browse reference
#### Where
In Chrome app
#### What went wrong
Chrome responds with the following error when browsing to <http://go.me.nextraq.com:6666/mc>:
```
This site can’t be reached
The webpage at <http://go.me.nextraq.com:6666/mc> might be temporarily down or it may have moved permanently to a new web address.
ERR_UNSAFE_PORT
```
#### How to fix
Close all Chrome windows and then run the following command
- REM Right Click on Chrome shortcut >> Properties >> Then append
- `--explicitly-allowed-ports=xxx` to shortcut target `C:\Documents and Settings\User\Local Settings\Application Data\Google\Chrome\Application\chrome.exe \`
`--explicitly-allowed-ports=6666`
### Error when building marcus
#### Where:
Script `'D:\projects\nextraq\repo\marcus\master\shared\base.gradle' line: 185`
#### What went wrong:
```
A problem occurred evaluating script.
> Could not resolve all dependencies for configuration 'classpath'.
> Could not resolve org.tmatesoft.svnkit:svnkit:1.8.7.
Required by:
unspecified:unspecified:unspecified
> Could not resolve org.tmatesoft.svnkit:svnkit:1.8.7.
> Could not get resource '[https://artifactory.prd.nextraq.com/artifactory/repo/org/tmatesoft/svnkit/svnkit/1.8.7/svnkit-1.8.7.pom'.](https://artifactory.prd.nextraq.com/artifactory/repo/org/tmatesoft/svnkit/svnkit/1.8.7/svnkit-1.8.7.pom%27.)
> Could not GET '[https://artifactory.prd.nextraq.com/artifactory/repo/org/tmatesoft/svnkit/svnkit/1.8.7/svnkit-1.8.7.pom'.](https://artifactory.prd.nextraq.com/artifactory/repo/org/tmatesoft/svnkit/svnkit/1.8.7/svnkit-1.8.7.pom%27.)
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve org.ajoberstar:grgit:1.7.0.
Required by:
unspecified:unspecified:unspecified
> Could not resolve org.ajoberstar:grgit:1.7.0.
> Could not get resource '[https://artifactory.prd.nextraq.com/artifactory/repo/org/ajoberstar/grgit/1.7.0/grgit-1.7.0.pom'.](https://artifactory.prd.nextraq.com/artifactory/repo/org/ajoberstar/grgit/1.7.0/grgit-1.7.0.pom%27.)
> Could not GET '[https://artifactory.prd.nextraq.com/artifactory/repo/org/ajoberstar/grgit/1.7.0/grgit-1.7.0.pom'.](https://artifactory.prd.nextraq.com/artifactory/repo/org/ajoberstar/grgit/1.7.0/grgit-1.7.0.pom%27.)
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
```
#### How to fix
- Re-install java.
- In some cases the same problem is raised when cisco client was upgraded but there were no system reboot made. - reboot windows.
### Error 503
#### Where
Marcus web pages
#### What went wrong
503 error when trying to access web pages
#### How to fix
1. Make sure that you're logged in. In order to log in follow next steps:
- Go to Marcus [admin console](https://go.dev.nextraq.com/marcusadmin)
- Then go to Users tab
- Find user and log in using `proxy` option
2. If problem is still relevant, try to restart Docker Desktop
> In case when your Docker Desktop can't be restarted, you can reboot your machine
## Setting up debug mode
### Configure debug for Marcus
To configure debug mode for Marcus open `$JBOSS_HOME` directory and follow instruction below:
1. Open `bin\standalone.conf.bat` and add line
```powershell
JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n
```
2. Add new `Remote JVM debug` configuration in IDE
3. Make sure that ports specified in the first step (`address=5005`) and in configuration menu are the same
4. Make sure that `marcus` module is selected
5. Apply new configuration
### Verify that debug is working
In order to check the debug mode:
1. Start JBoss with Marcus war in it
2. Go to `org.springframework.web.servlet.DispatcherServlet.java` and create breakpoint on 1155 line
3. Create any request to Marcus web pages
- [Example](https://go.me.nextraq.com/marcusadmin/account/list.html)
Your IDE should be able to track app in debug mode now.