How to use IntelliJ IDEA to run CableMES?
- 1 Install intellij IDEA
- 2 Checkout CableMES from GIT
- 3 Project settings
- 4 Settings other than IntelliJ
- 5 Maven: clean and install (then reload)
- 6 Clean artefacts in the settings after Maven
- 7 IntelliJ tomcat configuration
- 8 Add properties file to the server
- 9 Get database and update it by running latest scripts
- 10 Run the server
Usually we use Eclipse in Cimteq, if you have intellij Ultimate version, you can use it without any issues.
Suppose you have installed java8, tomcat and MES database(MSSQL server). Check here about MES database set up.
Make sure you have an updated database matching trunk version, errors like 'could not extract ResultSet' usually means the database connection error or it maybe is outdated.
Install intellij IDEA
It’s better to use Toolbox to install as it’s easier to update/roll back.
Install SVN command-line client, IntelliJ IDEA currently supports integration with Subversion 1.7 and later, and it is required to download and install a command-line svn client. For windows you can download subversion here.
Checkout CableMES from GIT
Open intellij, select File/New/Project from Version Control, select Subversion, click '+' button and enter URL(my is http://192.168.10.104/svn-dev),
Choose the local path you want:
Then select subversion 1.8 format and you have successfully checked out the project
Project settings
Open File/Project Structure, in Project Settings/Project, set project SDK to java 8 and project language level to 8. Click apply.
Project Settings/Artifacts, there are two existed artifacts, they are imported from Maven and any changes made in its configuration may be lost after reimporting. So we could delete them and create our own artifact , click '+' button, choose Web Application: Exploded/From Modules, then select CableMES.
There are two auto-generated artifacts. Delete
CableMES:war
and renameCableMES:war exploded
toCableMES
.
Settings other than IntelliJ
I’m not very sure the settings here, according to my memory of chat with Jonathan.
In your tomcat folder(the one you selected as output directory, 8.5.51 in my case), open conf/context.xml, add 3 resource tags. You can refer to the database setting page here. Make sure the first one jdbc/CableMES has correct url, username and password to connect to your database.
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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. --> <!-- The contents of this file will be loaded for each web application --> <Context> <!-- Default set of monitored resources. If one of these changes, the --> <!-- web application will be reloaded. --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <Resource auth="Container" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/CableMES" password="mes_taylor" type="javax.sql.DataSource" url="jdbc:sqlserver://localhost:1434" username="mes_taylor" /> </Context>
Download attachments, paste these 3 xml files to your home/.m2 folder.
If there are errors further through the process which complains that Maven is blocking the Cimteq repository, you can add a dummy mirror, into the mirrors section in the settings.xml, to rectify this(, or use and older version of Maven), as below:
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>dummy</mirrorOf>
<name>Dummy mirror to override default blocking mirror that blocks http</name>
<url>http://0.0.0.0/</url>
</mirror>
There are some other suggestions mentioned in the comments below.
Maven: clean and install (then reload)
Make sure you are in the cimteq network or connected to cimteq company VPN. Open you MES project maven window, in CableMES/lifecycle, double click clean, then double click install. You should get a ‘BUILD SUCCESS’ info in the console.
Once you get the ‘BUILD SUCCESS’ message, click the ‘Reload All Maven Projects’ button to refresh the project dependencies, bringing in the newly generated files from the ‘target\generated-sources’ directory.
Clean artefacts in the settings after Maven
After running maven: clean & install command you may end up with 3 different artefacts. Thus you need to clean them up. Go to File → Project Structure → Project Settings → Artifacts. Ensure that only 2 artifacts generated by maven are left: CableMES:war & CableMES:war exploded. If you have 3 you can leave CableMES in here as long as you will not re-generate it in the next step.
IntelliJ tomcat configuration
Click Add configuration, then click “+” button in the top left, choose tomcat server/local
Click Configure… , choose your local tomcat path, choose the zip version tomcat to download and unzip it. (Don’t use the exe version of tomcat)
intellij warning: No artifacts marked for deployment. Click Fix, choose the artifact we created (or in deployment tab, click '+' button), here we choose the artifact CableMES we just created. (It will automatically choose the only one artifact if you only have one.)
In Deployment tab, pick CbaleMES: war exploded as the artifact to deploy. Make sure the application context is set to /CableMES (and not something longer).
Back to Server tab, change “After lanuch”, “On ‘Update’ action”, “On frame deactivation” as you wish. Here I set it to ‘update classes and resources’ and ‘update resources’, so if we update code, usually we don’t need to restart server to update.
Click Apply and OK.
Add properties file to the server
Add the properties file to Cable MES as per: https://cimteq.atlassian.net/wiki/spaces/CD/pages/1176174593
Get database and update it by running latest scripts
Find the database in share point: Documents → CableMES Backups → Team Backups → Demo
Update that demo with the latest script changes: Updating MES Database in intellij
Run the server
In services, click the Run button in top left and here we go.
For example if I change msg.properties, and move my cursor out of intellij, click anywhere to make it 'On frame deactivation”, the login page will change accordingly.