Is it possible to use messaging, and kafka-messaging separately from helidon? - helidon

I created library using helidon-messaging, helidon-messaging-kafka. Also I created an example Java SE app using that library and all works fine. But when I try to use that library in Java EE (Weblogic) legacy application I have got an exception while that application starts:
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Config with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject io.helidon.messaging.connectors.kafka.KafkaConnector(Config)
at io.helidon.messaging.connectors.kafka.KafkaConnector.<init>(KafkaConnector.java:0)
Is it possible some how to switch off CDI stuff there?

Did you try to exclude the connector package from bean scanning?
Something like this should help:
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
version="2.0"
bean-discovery-mode="annotated">
<scan>
<exclude name="io.helidon.messaging.connectors.kafka.**" />
</scan>
</beans>
More info can be found here

Related

How do I fix the Spring XML validation in IntelliJ

I am getting a "false positive" error in a Spring XML file....
Expected behavior: The inbound channel adapter element with header-mapper of DefaultAmqpHeaderMapper validates properly in IntelliJ
Actual behavior: IntelliJ reports that the header-mapper is not of type HeaderMapper
There was an issue that was fixed in 3.0 but it seems like my IntelliJ is validating the below applicationContext.xml against an old version of the amqp schema. How do I refresh it?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/amqp http://www.springframework.org/schema/integration/amqp/spring-integration-amqp-4.2.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd">
<int-amqp:inbound-channel-adapter
channel="ch1" queue-names="queue"
connection-factory="amqpConnectionFactory" error-channel="errorChannel"
header-mapper="allHeadersMapper" concurrent-consumers="1" />
Edit: Was found in 14.1.5. Upgraded to 2016.3.4 on Linux and reproduced.
Reproduced with simple code at https://github.com/dcw312/intellij-validation-error. IntelliJ issue created: https://youtrack.jetbrains.com/issue/IDEA-167842

How to fix NoClassDefFoundError error with Aquillian

Hi I set up Arquillian with Wildfly 10 embedded, which is loaded into the target folder.
I see two mistakes at the moment:
Cannot not load JBoss LogManager. The LogManager has likely been accessed prior to this initialization.
java.lang.NoClassDefFoundError: org/jboss/remoting3/spi/ConnectionProviderFactory
The first one I hope I can ignore. The second one I can't solve. Any idea why?
The ejb has dependency to four external ejbs over JNDI. In the arquillian.xml I mentioned nothing about this dependency.
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="wildfly10" default="true">
<configuration>
<property name="jbossHome">target/wildfly-10.0.0.Final/</property>
<property name="modulePath">target/wildfly-10.0.0.Final/modules</property>
</configuration>
</container>
</arquillian>
Where does the second error comes from? How can I solve it?
Thanks,
Markus
Ok, solved it was a Maven exclusion problem. :-(

Wildfly 10 - How to use a newer version of jackson for an aplication

I have an application running on wildfly 10 that needs a newer version of jackson. Simply updating the maven dependency does not to work. Wildflys own version seems to interfere...
Somebody has a hint?
You can add a newer version of Jackson to your war and use that, but the JAX-RS subsystem of the container (Resteasy) will still use it's own jackson module to (de)serialize you HTTP request/response bodies.
You could add a module with the newer version, but you could run into dependency problems with other modules (see this pull request which already was accepted, so it should be in the next release, but I don't know of any planned Wildfly release dates).
Or you could package your own version of Jackson and register those MessageBodyReaders/Writers to be used by JAX-RS. This should do the job.
#Provider
public class CustomJacksonJsonProvider extends JacksonJsonProvider {}
You may also have to exclude the built-in Jackson by adding a jboss-deployment-structure.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
</exclusions>
</deployment>
</jboss-deployment-structure>

how to import osgi blueprint xml

I am trying to import an OSGI blueprint XML file in to another OSGi blueprint XML file.
e.g.:
blueprint1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint ....>
<bean id="myBean1" class="com.company.Class1"/>
<bean id="myBean2" class="com.company.Class2"/>
</blueprint>
</xml>
blueprint2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint ....>
<!-- DOES NOT WORK -->
<import resource="blueprint1.xml" />
</blueprint>
The <import> works for spring but not for blueprint.
Does anybody know a way of doing this in OSGi blueprint XML files?
Apparently, Spring like imports are not currently possible in blueprint.
However, if the files are in the same OSGi bundle then they are in the same context and can be used from other blueprint files.
Also, see here: http://fusesource.com/forums/message.jspa?messageID=15091#15091
If you're using Gemini Blueprint (formerly Spring DM) you can simply tell it to load both files, and basically treat them as if they were one big file:
In the absence of the Spring-Context header the extender expects every
".xml" file in the META-INF/spring folder to be a valid Spring
configuration file [...].
It also treats any xml files in /OSGI-INF in the same way.

Using hibernate validator JodaTime bean validation constraints in JBoss

We have an enterprise application that uses the Joda DateTime library. The application is deployed into a JBoss 7.2.0 Alpha1 Container. Some classes in our domain model have #Past annotations on fields of type DateTime. In order to validate these constraints we'd like to use the constraint validators provided by hibernate-validator. Therefore we added a dependency 'org.hibernate.validator' to the MANIFEST.MF of our ear file. We are using version 2.0 of the Joda library. Therefore we have packaged the joda-time-2.0.jar file in our ear. We are not using the version 1.6.2 that is available as a module of JBoss 7
When validating an object with a DateTime field following exception is thrown:
10:51:41,140 ERROR [org.acme.GlobalExceptionHandler] (EJB default - 10) Exception caught by global exception handler: javax.validation.UnexpectedTypeException: No validator could be found for type: org.joda.time.DateTime
at org.hibernate.validator.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:383) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:364) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:313) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:144) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:117) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:84) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:452) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
After some debugging we detected that the call to 'TypeUtils.isAssignable( validatorType, type )' in 'ConstraintTree.findSuitableValidatorTypes' fails since the available validator types are taken from the Joda library that has been shipped with JBoss instead of the Joda library that is packaged in our ear file.
I guess we are doing something wrong regarding classloading. Can anybody give me a hint?
Have you tried adding a jboss-deployment-structure.xml to your ear file? This way you should be able to exclude the Joda time module:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.joda.time"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
See also https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7
Following Hardy's idea I solved my problem creating a jboss-deployment-structure.xml in my application's WEB-INF folder containing this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.hibernate.validator" />
</exclusions>
</deployment>
</jboss-deployment-structure>
In stead of excluding org.joda.time I excluded org.hibernate.validator. I hope this works for you too.