java.lang.ClassNotFoundException: javax.annotation.PostConstruct

When upgrading to the latest tools and libraries in a Spring Boot application with OpenAPI code generator in place the OpenAPI Kotlin generator introduced jakarta.annotation:jakarta.annotation-api. But with this in place the application refused to start with something like org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat…Caused by: java.lang.IllegalStateException: …

java.lang.ClassNotFoundException: javax.annotation.PostConstruct Read More »

How to access BeanManager in a JEE application

There are different ways to get a reference to javax.enterprise.inject.spi.BeanManager in an JEE application: @Inject private BeanManager beanManager; private BeanManager bm = javax.enterprise.inject.spi.CDI.current().getBeanManager(); Especially the second one can be very handy if you hit a part that doesn’t support CDI already.

JBoss show JDBC Queries

Sometimes it is necessary to see which queries are executed and what the parameters of these queries have been. To get this data from a JBoss 7+ you have to follow these steps: Enable JDBC-Spy on Datasource: /subsystem=datasources/data-source=ExampleDS/:write-attribute(name=spy,value=true) Or just add spy=”true” as attribute in standalone.xml. Then you have to enable the spy by adding a …

JBoss show JDBC Queries Read More »

JBoss Maven Repository

To use the jboss maven repository under you have to add a profile in your settings.xml (~/.m2 or $M2_HOME/conf). <settings> … <profiles> … <profile> <id>jboss-public-repository</id> <repositories> <repository> <id>jboss-public-repository-group</id> <name>JBoss Public Maven Repository Group</name> <url></url> <layout>default</layout> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>jboss-public-repository-group</id> <name>JBoss Public Maven Repository Group</name> <url></url> <layout>default</layout> <releases> …

JBoss Maven Repository Read More »

Encrypted Database Passwords in JBoss

JBoss provides a simple mechanism to encrypt database passwords with blowfish. So the standalone.xml does not include our database passwords in plaintext anymore. First you have to encrypt your password with This class includes a main method so you can run it with a single argument which has to be your plaintext password. The result will look like …

Encrypted Database Passwords in JBoss Read More »

Disable Stacktrace in Response of JBoss

To disable the source body in a stacktrace you have to add the following configuration to your web subsystem in standalone.xml: <configuration> <jsp-configuration display-source-fragment=”false”/> </configuration> Or with cli: /subsystem=web/configuration=jsp-configuration:write-attribute(name=display-source-fragment, value=false)  

Disable Deployment-Scanner in JBoss

Look for the deployment-scanner config in your standalone.xml and configure the scan interval to -1 to allow deployment onyl from shell or at startup. Here is the relevant part: <subsystem xmlns=”urn:jboss:domain:deployment-scanner:1.1″> <deployment-scanner path=”deployments” relative-to=”jboss.server.base.dir” scan-interval=”-1″/> </subsystem> Or with cli: /subsystem=deployment-scanner/scanner=default:write-attribute(name=scan-interval, value=-1)  

Remove X_POWERED_BY Header in JBoss EAP6

First you have to disable it in standalone.xml by adding jsp-configuration x-powered-by=”false”. Here the relevant part of my config: <subsystem xmlns=”urn:jboss:domain:web:1.5″ default-virtual-server=”default-host” native=”false”> <connector name=”http” protocol=”HTTP/1.1″ scheme=”http” socket-binding=”http”/> <virtual-server name=”default-host” enable-welcome-root=”false”> <alias name=”localhost”/> </virtual-server> <configuration> <jsp-configuration x-powered-by=”false”/> </configuration> </subsystem> Or with cli: /subsystem=web/configuration=jsp-configuration:write-attribute(name=x-powered-by,value=false) In a JSF application you have to add the following context param: <context-param> …

Remove X_POWERED_BY Header in JBoss EAP6 Read More »

Make your webapplication log debug messages under jboss

I often catch myself writing info-messages because jboss is configured to info-mode by default. By adding the following few lines you can make your application use debug mode: <subsystem xmlns=”urn:jboss:domain:logging:2.0″> … <!– add begin –> <console-handler name=”DEBUGCONSOLE”> <level name=”DEBUG” /> <formatter> <pattern-formatter pattern=”%d{HH:mm:ss,SSS} %-5p [%c] (%F:%L) %s%E%n” /> </formatter> </console-handler> <logger category=”pm.mbo” use-parent-handlers=”false”> <level name=”DEBUG” …

Make your webapplication log debug messages under jboss Read More »