How can i configure Custom Plugins for ActiveMQ - plugins

Since i didn't get a working answer on the mailinglist i try it here.
The Documentation says its possible to configure your own plugins like that:
<plugins>
<bean id="myPlugin" class="org.myorg.MyPlugin"/>
</plugins>
I tried this with on ActiveMQ 5.5 the following way:
<plugins>
<jaasAuthenticationPlugin configuration="activemq-domain" />
<bean id="authplug" class="org.apache.activemq.security.AuthorizationPlugin"><property name="map"><bean name="authMap" class="my.authMap" /></property></bean>
</plugins>
This config raised two problems:
1. Validation fails. The xml validation fails for this configuration because the "bean"-Tag is not expected, even if the documentation sais otherwise.
2. When validation is deactivated for my config spring throws the following exception:
org.springframework.beans.factory.BeanDefinitionStoreException: Unrecognized xbean element mapping: bean in namespace http://activemq.apache.org/schema/core
How can i configure custom plugins for ActiveMQ?

The Problem was the missing namespace. The examples in the documentation show the plugins tag like i described. In reality the bean tag must include the spring namespace to be recognized.

For those who were missing the information and needed the exact answer
<plugins>
<jaasAuthenticationPlugin configuration="activemq" />
<bean id="myBrokerPlugin" class="omsplugin.oms.MyBrokerPlugin" xmlns="http://www.springframework.org/schema/beans">
</bean>
</plugins>

Related

TomEE Microprofile OpenAPI in Plume

I wrote a simple JAX-RS REST service (which is working as expected) and I'm trying to generate the OpenAPI documentation using microprofile. Therefore I added the following dependency to my pom.xml:
<dependency>
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-api</artifactId>
<version>2.0</version>
</dependency>
When I deploy the application on TomEE 9.0.0 M7 Microprofil everything works as expected and the OpenAPI schema is reachable under http://localhost:8080/openapi. But when I deploy the same artifact to TomEE 9.0.0. M7 Plume/Webprofile/Plus the schema / endpoint is not available. What am I missing here? Is this a configuration issue? According to https://www.tomitribe.com/blog/tomee-webprofile-vs-tomee-microprofile-vs-tomee-vs-tomee-plume/ MicroProfile should be part of the other distributions of TomEE too...
Thanks a lot!
Yes! MP implementation is available on the others TOMEE Profiles, but you will need to add a flag.
-Dtomee.mp.scan=all
if you are running it trough maven plugin you should put the flag like this.
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>${tomee.version}</version>
<configuration>
<context>ROOT</context>
<args>-Dtomee.mp.scan=all</args>
<tomeeVersion>${tomee.version}</tomeeVersion>
<tomeeClassifier>plus</tomeeClassifier>
</configuration>
</plugin>

Wildfly Maven Plugin ignores deployment name?

I added the name parameter on my deployment using Wildfly Maven Plugin:
mvn wildfly:deploy -Dname=myapp -Dwildfly.hostname=myserver -Dwildfly.username=user -Dwildfly.password=pwd
However, it keeps on deploying with the Maven version and extension.
Here's how it looks in standalone.xml
<deployment name="myapp-1.1-SNAPSHOT.war" runtime-name="myapp-1.1-SNAPSHOT.war">
<content sha1="17e09de2cd8f78ffd033a90b4e82bdb52eb9485b"/>
</deployment>
The reason is to streamline the deployment process. After a Maven release, the deployment name changes to myapp-1.1.war, and the new development becomes myapp-1.2-SNAPSHOT.war. Instead of undeploying release myapp-1.1.war, and deploying myapp-1.2-SNAPSHOT.war, we want to reduce it to a single step - just redeploy myapp, and it should overwrite the old one.
Btw, if I just deploy, I'll have the two versions.
Just to be clear, this is the goal:
<deployment name="myapp" runtime-name="myapp-1.1-SNAPSHOT.war">
<content sha1="17e09de2cd8f78ffd033a90b4e82bdb52eb9485b"/>
</deployment>
This seems like a very simple case, and it should work as per the documentation: https://docs.jboss.org/wildfly/plugins/maven/latest/deploy-mojo.html
You can't override the name parameter on the via the command line. You'd need to add a configuration property for the name configuration parameter and override that on the command line.
...
<properties>
<deployment.name>${project.build.finalName}.${project.packaging}</deployment.name>
</properties>
...
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.1.0.Alpha7</version>
<configuration>
<name>${deployment.name}</name>
</configuration>
</plugin>
...
Then on the command you could use -Ddeployment.name=myapp. One note though is you'll want to use the appropriate file extension, e.g. .war, so the deployment will be processed properly.

Unable to see log output of Spring when starting Jetty from Maven plugin

I am developing a webapp in Eclipse Juno as a Maven multi-module project using Spring MVC and the Jetty Maven plugin version 8.1.7.v20120910 with HSQL as in-memory DB during development. I want to start Jetty from within the IDE using the jetty:run goal. The problem is that I cannot see any log outputs from Spring, but I suspect the context is indeed being loaded since console log outputs stop briefly - just as long as it would take to load my yet so small Spring context - before throwing an NPE on an Autowired bean. So my suspicion is that something went wrong while starting up the Spring context.
This is the log output just before it "stops" briefly:
[INFO] web.xml file = file:/F:/projects/matching/template/template-app/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = F:\projects\matching\template\template-app\src\main\webapp
2013-01-26 11:09:18.130:INFO:oejs.Server:jetty-8.1.7.v20120910
2013-01-26 11:09:20.704:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
Which after the pause is followed by:
2013-01-26 11:09:35.884:INFO:/:No Spring WebApplicationInitializer types detected on classpath
2013-01-26 11:09:36.742:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/F:/projects/matching/template/template-app/src/main/webapp/},file:/F:/projects/matching/template/template-app/src/main/webapp/
2013-01-26 11:09:36.742:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/F:/projects/matching/template/template-app/src/main/webapp/},file:/F:/projects/matching/template/template-app/src/main/webapp/
2013-01-26 11:09:36.742:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/F:/projects/matching/template/template-app/src/main/webapp/},file:/F:/projects/matching/template/template-app/src/main/webapp/
2013-01-26 11:09:36.743:WARN:oejw.WebAppContext:Failed startup of context o.m.j.p.JettyWebAppContext{/,file:/F:/projects/matching/template/template-app/src/main/webapp/},file:/F:/projects/matching/template/template-app/src/main/webapp/
java.lang.NullPointerException
Now I am confident that I will be able to fix whatever is causing the NPE, but for that I need to see what is happening to my Spring context. I used to work on the same constellation of tools last year, when a colleague had set it up with what I believe was the same configuration as I am using now.
I have searched the web all morning and couldn't find anything useful about it, only the vague suggestion to run Jetty externally and assemble the war and deploy the app, which is exactly not what I want.
This is my pom's build configuration:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
<warName>template</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
<webApp>
<jettyEnvXml>${jettyEnvXml-file}</jettyEnvXml>
</webApp>
<contextPath>template</contextPath>
<systemProperties>
<systemProperty>
<name>log4j.configuration</name>
<value>file:jetty/log4j-jetty.properties</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
And this is my log4j configuration for Jetty:
log4j.debug=true
log4j.threshold=ALL
log4j.rootLogger=DEBUG, consoleLogger
log4j.appender.consoleLogger=org.apache.log4j.ConsoleAppender
log4j.appender.consoleLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleLogger.layout.ConversionPattern=%-5p [%t]: %m%n
log4j.appender.consoleLogger.Threshold=TRACE
Could it have to do with this line at the beginning of my log?
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
But as far as I know it's just an m2e bug that can be ignored. I have slf4j in my classpath though.
When I run my unit tests with HSQL in the SpringJPA module, it works nicely, so I suspect it's a Jetty issue or something with my log4j configuration is just bogus.
Any ideas, hints, helps are greatly appreciated.
You have slf4j in your classpath, then Jetty will use slf4j.
Make sure you setup/configure for slf4j.
You can even setup slf4j to have its log events route to log4j for actual writing to disk or presenting to your console.

glassfish 3.1 system properties deployment

I had a log4j error (see here) and the suggested fix worked. I set the org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES system property to false in the console with asadmin.
As I am working with maven in a project using glassfish 3.1 I have to insert this fix in my code somewhere to make it run for everybody. I figured out this can be done with the maven-embedded-glassfish-plugin as a command. So i wrote this code and put it in my pom.xml:
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1</version>
<configuration>
<commands>
<command>create-system-properties org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false</command>
</commands>
</configuration>
</plugin>
But the server will not create the system property. What am I missing here?
Is there another way to realize this? Any help is appreciated.

JBoss Microcontainer + AOP in a standalone app

I'm trying to create a standalone app using JBoss Microcontainer for IoC and JBoss AOP for, well, AOP.
I've boot-strapped, deployed a descriptor with AOP XML, so far so good.
But the aspect is not performed. Do I need to enable AOP plugin or something?
Note that I don't want to add a build step - I want it to work like Spring AOP.
Please check the code below.
Thanks for help.
<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
xmlns="urn:jboss:bean-deployer:2.0"
xmlns:aop="urn:jboss:aop-beans:1.0">
<bean name="myGarage" class="jbmctest.Garage">
<property name="car">
<bean name="myCar" class="jbmctest.Car">
<property name="name">Red Devil</property>
</bean>
</property>
</bean>
<aop:interceptor name="FuelInterceptor" class="jbmctest.FuelInterceptor"/>
<aop:bind pointcut="execution(* *->*(..)">
<aop:interceptor-ref name="FuelInterceptor"/>
</aop:bind>
</deployment>
You're missing the pieces that are in aop.xml in JBossAS5 -> conf/bootstrap/aop.xml.
I've eventually solved this, and wrote an article for those who will try the same.
http://ondra.zizka.cz/stranky/programovani/java/jboss-aop-howto-example-standalone-app.texy