Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
hofmann
Active Contributor

Yes!

It may sound easy, but, actually, Sonar is not a pure Java application. It makes extensive use of Ruby. To be able to run sonar under Neo, it needs be converted to run under Java / JRuby on Tomcat and be able to connect to the Neo database => increasing the complexity.

How to deploy Sonar?

Sonar comes with a script to transform it into a WAR file, enabling a deploy to a Java application server:

Running the script produces a WAR that you can deploy.

The problem is that because of how sonar is configured, the application won’t start. The log shows why:

java.lang.IllegalStateException: SONAR_HOME is not valid: C:/sonar-3.3.1. Please fix the environment variable/system property SONAR_HOME or the file WEB-INF/classes/sonar-war.properties
        at org.sonar.server.platform.SonarHome.locate(SonarHome.java:77)

Sonar expects a specific folder structure under the SONAR_HOME location. By default, SONAR_HOME is expected to be the same location at the time the WAR file was created. This is a directory local to your computer and on Neo you cannot create the same directory. Now, you cannot simply define a location and expect Neo’s Tomcat to do the rest. The workaround is to simply point SONAR_HOME to a folder included in the WAR before creating the war build script. I gave it the name home:

Now point SONAR_HOME to that location. Change the file sonar-war.properties


# Path to Sonar installation directory, if the environment variable/system property SONAR_HOME is not defined

SONAR_HOME=/usr/sap/ljs/./webapps/sonar/home

Sonar stores it information into a database, so the database also needs to be configured. There is not direct DB access, you have to use the configured data source. Not sure where exactly to put the reference to the data source, so I inserted it in two locations.

1st, the location where sonar WAR builder is putting it is META-INF/context.xml


<Context antiJARLocking="true" antiResourceLocking="true">
<ResourceLink name="jdbc/DefaultDB" global="jdbc/sonar" type="javax.sql.DataSource" />
</Context>

2nd, location is web.xml:

Now everything is ready to deploy the WAR.

This takes some time as the WAR is 50MB, but it works. After a successful deploy and start, Neo shows in the log that sonar is up and running:

Deploying file with path [/usr/sap/ljs/./pickup/sonar.war]|
#sonar#web#null#null#JRuby limited openssl loaded. http://jruby.org/openssl|
#sonar#web#null#null#gem install jruby-openssl for full support.|
#sonar#web#null#null#Deployment of file with path [/usr/sap/ljs/./pickup/sonar.war] is successful.|

Sonar works, the configured NW Cloud DB is working without a problem too. You can create users and configure Sonar:

To see more information about the JVM sonar runs, just go the system information page.

Remark

Surprisingly, the only issue creator here is how Sonar is expecting to be configured: by using a directory on the server. All the rest someone may expect to cause troubles caused nothing at all: database and JRuby.

6 Comments
Labels in this area