Sonar doesn't follow or supply space option from checkstyle - checkstyle

I am using Sonar to present state of our code. We have a checkstyle xml document with our rule. In it, we have the "Method param pad" rule:
<module name="MethodParamPad">
<property name="tokens" value="METHOD_DEF"/>
<property name="option" value="space"/>
<property name="allowLineBreaks" value="true"/>
</module>
However, the result in sonar is filled with violations against this rule, concerning spaces between the method name and the first parentheses, which I feel should be allowed with the "option".
In the Sonar UI, there is no way of entering a value for the option, doesn't Sonar support it?

Sonar uses the maven checkstyle plugin to perform the analysis. The latest version of the plugin (2.5) uses checkstyle 5.0, but the documentation for the 'option' property wasn't added until checkstyle 5.1. This could be why it was missed in the Sonar rules.
Looks like you posted a JIRA issue that has been fixed, so this problem should go away in 2.3. (It would be nice if it were possible to update the standard plugins independently, but I don't see them listed anywhere)

Related

Can log4jdbc be used with spring boot?

I have a Spring boot app I'm trying to add database logging to which is better than
spring.jpa.properties.hibernate.show_sql=true
log4jdbc, from
https://github.com/marcosemiao/log4jdbc
seems to be the most up to date fork around, seems to format nicely, fills in parameters and adds timing, exactly what I want.
But when I configure it as stated in the readme, changing
spring.datasource.url=jdbc:mysql://localhost:3306/coindatabase?useSSL=false
to
spring.datasource.url=jdbc:log4jdbc:mysql://localhost:3306/coindatabase?useSSL=false
something seems to not like my reference to mysql and seems to try to fall back to H2:
Caused by: java.lang.RuntimeException: Driver org.h2.Driver claims to not accept jdbcUrl, jdbc:log4jdbc:mysql://localhost:3306/coindatabase?useSSL=false
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:106)
Is there some easy way to make this work together?
log4jdbc for spring boot wrapper:
<groupId>com.integralblue</groupId>
<artifactId>log4jdbc-spring-boot-starter</artifactId>
which seems to pull in the implementation from:
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
Additional info:
Don't modify the spring.datasource.url property in your Spring Boot application.properties file; leave the URL as previously defined to access your MYSQL instance.
Instead, after grabbing the com.integralblue maven target, simply set the logging level of choice (ex logging.level.jdbc.sqltiming=info) and your previously defined log4j log will have the DB stuff in it.
See here as was well
You need to use this library in your build.gradle:
// https://mvnrepository.com/artifact/com.integralblue/log4jdbc-spring-boot-starter
compile group: 'com.integralblue', name: 'log4jdbc-spring-boot-starter', version: '2.0.0'
If you get the warning:
"Loading class 'com.mysql.jdbc.Driver'. This is deprecated. The new driver class is 'com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary."
you can set the correct Driver yourself via properties:
log4jdbc.drivers=com.mysql.cj.jdbc.Driver
log4jdbc.auto.load.popular.drivers=false
The documentation for configuration can be found on Github

wildfly10 and slf4j and logback do not work

I followed the following configuration for wildfly10:
https://developer.jboss.org/thread/237094
So to be able to use slf4j and logback in my application I disabled the logging subsystem:
<jboss-deployment-structure>
<deployment>
<!-- exclude-subsystem prevents a subsystems deployment unit processors running on a deployment -->
<!-- which gives basically the same effect as removing the subsystem, but it only affects single deployment -->
<exclude-subsystems>
<subsystem name="logging" />
</exclude-subsystems>
</jboss-deployment-structure>
With this configuration my application uses correctly my logback configuration: the problem is that the server does not use anymore its own logging, so the general information are not written anymore to server.log, but they are written to my application appender.
This sounds very strange to me: I tried a lot of other configurations like excluding directly the modules (i.e. org.slf4j and org.slf4j.impl) on my jboss-deployment-structure.xml file but with no effect.

How to configure custom main class using YAML in wildfly swarm application

I am trying to build a Wildfly Swarm application using custom main class specified in plugin configuration ( as shown below )
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>2018.3.3</version>
<configuration>
<mainClass>rnd.web.service.rest.App</mainClass>
</configuration>
</plugin>
But during build/run is show deprecation warning/information (see below) with reference to documentation. But the documentation does not provide any details on how to implement it.
Custom main() usage is intended to be deprecated in a future release
and is no longer supported, please refer to
http://docs.wildfly-swarm.io for YAML configuration that replaces it.
If someone has encountered and implemented it. Please share the approach and correct reference.
As the deprecation warning says, it's not the <mainClass> setting that's deprecated, it's the entire usage of custom main method. All the configuration you do in your main method, you should be able to do with the YAML configuration. If you find something missing, then that's a bug.

confluence install cause 500 exception HibernateException

I currently use confluence and mysql to make personal wiki. However I have in 500 exception HibernateException.
The log of confluence:
Caused by: com.atlassian.confluence.tenant.VacantException: Confluence is vacant, a call to tenanted [public abstract net.sf.hibernate.Session net.sf.hibernate.SessionFactory.openSession() throws net.sf.hibernate.HibernateException] is not allowed.
at com.atlassian.confluence.tenant.TenantGate$1.lambda$create$306(TenantGate.java:45)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
What I have done:
confirm that the mysql connecter work correct. Details are in Test mysql connerctor.
Reinstall serveral times, but the error appears too.
Google the problem and find it, but no anwse. See openSession() throws net.sf.hibernate.HibernateException
Any helps are welcome!
Download the latest mysql-connector jar file and place it under /confluence/WEB-INF/lib/ with all the other libraries. Do a stop and restart your confluence instance.
I had the exact same exception openSession() failed, I upgraded my confluence instance from 5.1.3 to 5.10 then got into this exception, but after I use mysql-connector-java-5.1.40-bin.jar, it WORKED.
There are several things that can go wrong and cause this to fail.
First, make sure you have the mysql-connector jar in the proper place.
Second, go to your HOME directory for confluence and check confluence.cfg.xml. Look at these settings:
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.isolation">2</property>
<property name="hibernate.connection.password">[PASSWORD]</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/confluence?sessionVariables=storage_engine%3DInnoDB</property>
<property name="hibernate.connection.username">confluenceuser</property>
Make sure the user and password for mysql are right. You can test in mysql using mysql -u confluenceuser -p. Make sure the url is also right. In particular, the hostname localhost.

EF6 and MySQL Generate Database from Model

I've tried every solution I've found on the web with no success. I continually get the error:
Running transformation: System.InvalidOperationException: The SSDL generated by the activity
called 'CsdlToSsdlAndMslActivity' is not valid and has the following errors:
No Entity Framework provider found for the ADO.NET provider with invariant name
'MySql.Data.MySqlClient'. Make sure the provider is registered in the 'entityFramework'
section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for
more information.
I have an empty Console project and a very basic model to test this with. Through the NuGet Package Console I'd executed: Install-Package MySQL.Data.Entities which installed EF6, MySQL.Data and MySQL.Data.Entities and hooked up all the references and copied the relevant DLL's into the bin/Debug folder.
I wired up the provider in the following (entire config file listed)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"></provider>
</providers>
</entityFramework>
</configuration>
As far as I can tell I have the provider registered. I have the latest MySQL connector updated as well. Where am I going wrong?
To support full functionality EF Designer requires 3 things:
EF runtime provider (you seem to have it)
DDEX provider for your database - DDEX is the way VS abstracts databases and as a result can talk to any database. Note that this is not something that is EF specific but EF Designer relies on it (again you seem to have it otherwise you would not be able to select MySQL connection)
Additional components (T4 templates/Workflow activities) required to support Model First flow - these are EF specific but typically installed as part of the DDEX provider - you seem to be missing this or you did not select the T4 template/workflow specific to your provider (open the edmx file and go to the properties window there are two options there that are interesting from DDL generation perspective - the "Database Generation Workflow" and the "DDL Generation Template". Click the dropdowns to see if you can select something that is MySQL specific)
Because you don't seem to have or use the workflow/T4 for MySQL (note I don't know if this is because you did not select the correct T4/workflow (see above) or MySQL DDEX does not support this or the installation is for whatever reason broken) EF Designer is using the default workflow which is for Sql Server. The default workflow relies on being able to find EF providers (for SqlServer and SqlServerCe) in the default path but the provider for MySQL is not there - hence the error. Note that the workflow and T4 templates for creating DDL are provider specific so even if you copied the MySQL provider to the default path it would not really work - you would get a peculiar result of SQL Server specific SQL Script using MySQL types.
We have a bug on improving this a little bit by providing a better guidance instead of just invoking the default DDL generation which we know will not work. You can also find some details in this bug.
I would suggest checking if MySQL components you are using do support Model First. An alternative would be just to move to Code First which only requires the EF runtime provider you already have to generate the DDL.
The other answer already kind of says this, but it's buried in his long post.
Notice that the error message refers to SSDLToSQL10.tt. You don't want that .tt file, you want the MySQL one. In the EF designer properties window, find the DDL Generation Template property and change it from SSDLToSQL10.tt to SSDLToMySQL.tt.