Quarkus ClassLoader gRPC/protobuf and Library - maven

we are using Quarkus with gRPC and some internal library that also uses the same protobuf data. So the dependency graph looks as follows:
quarkus-project
|
+--> lib
| |
| +--> my-protocol.proto
|
+--> my-protocol.proto
Our current solution is a maven artifact (my-protos) that wraps the my-protocol.proto and also includes the generated sources from that.
As Quarkus also needs the raw *.proto file to generate Mutiny wrappers around it, we also include my-protocol.proto via git submodule, s.t. we end up with the following structure:
quarkus-project
|
+--> lib
| |
| +--> my-protos
| |
| +--> my-protocol.proto
| +--> <generated sources>
|
+--> <git submodule> my-protocol.proto
|
+--> <mvn exclude> my-protos // are generated by quarkus again
The compiler checks that the classes to be generated from this proto are already present. So we had to exclude the dependency my-protos via maven dependency management.
Works inside IDE, all classes are present.
BUT as soon as we run Quarkus in dev mode (mvn quarkus:dev), the QuarkusClassLoader throws a ClassNotFoundException when we access a protobuf-generated class inside of the library-code. Checking the stacktrace, we see that the class we are trying to load is a banned dependency. We assume this is caused by the <exclude> in the pom.
Accessing the same class from code that is witten inside the quarkus-project, we do NOT see the exception.
So our best guess is that we are currently dealing with different classloaders (see [1]). The classloader, which is responsible for loading the libseems to have the banned dependency, the other one not.
This explanation is confirmed by running quarkus in production mode (where only the system classloader is used) and there we do not have the banned dependency problem there.
Please send help :)
[1] https://quarkus.io/guides/class-loading-reference

Related

Working with multiple module using Maven for Automation

I have a problem and i have confidence that you guys can clarify it.
I have created a java based automation project using maven project structure. I have applied the concept of Page Object Model in it. My project structure is like below.
Automation
Module1
|_____ FrameworkCore.java
|_____ FrameworkWebDriver.java
|_____ DynamicMethodCalling.java
|_____ RunSuit.csv
Module2
|_____CommonPage.java - extends Framework core
|_____Pages
| |_____ LoginPage.java
| |_____ HomePage.java
| |_____ ContactPage.java
|_____Test
|_____ Test1.java
|_____ Test2.java
--> I have created test functions in Test1 and Test2 and i am dynamically calling the methods based on the methodName.
-->In order to achieve the above i need to configure the Module1 as depenency in Module 2
("in-order to refer the webdriver defined in framework code")
AND Module 2 as dependency in Module1
(in-order to call the methods from Test1 & Test2).
This causing the circular dependency.
Is there any way to avoid this circular dependency???
Note: i have searched a lot in the internet and have not found any suitable solution for this issue
Regards,
SomeshKumar Nagarajan

Maven: how to make things different in a parent while all children behave otherwise?

I have a multi-module Maven project (one level deep only). I like not to have to repeat the same things in all child projects, but how can I still do it (avoir repeating) when the parent project itself needs a different setting ?
The example I’m facing is when trying to produce a common folder for all artifacts and dependencies (but I can imagine other equivalent situations):
<properties>
<__.build.folder>../last_build</__.build.folder>
</properties>
Of course, this will lead to a situation where I have two last_build folder, one common to all child projects, one in the upper level folder.
How can I avoid that without having to duplicate the same setting in every child pom.xml ?
Can I use profiles ?
I don’t know, I’m new to Maven.
Thanks
Edit :
In this example, last_build is a subfolder of the folder containing the parent pom.xml. The child projects are all in other subfolders, from which last_build has to be addressed as "../last_build" - but not in the parent pom.xml !
|
*--rootFolder
| |
| *--last_build // aggregation folder
| |
| *--subProject1
| | |
| | *--pom.xml (../last_build)
| |
| *--subProject2
| | |
| | *--pom.xml (../last_build)
| |
| *--subProject3
| | |
| | *--pom.xml (../last_build)
| |
| *--pom.xml (last_build) // different here for the parent project
I don't think you're proceeding down a very useful path and I think that you may be confused about a few things.
First, at the highest level, your root or parent pom, there should be no project, no code, no resources, and no artifact, so there should also be no output or need for an output directory. All you should have at the highest level is the parent pom and subdirectories containing modules.
The next problem is that you think you need a common build folder. I am hard pushed to imagine a rational scenario where that would be necessary. The artifacts one typically builds in maven are self-contained jars/wars -- one per module, and these are cached in the local repo whenever you build through the install lifecycle. They can be used in situ from there.

Provisioning of JAXB in Apache Karaf - fail to resolve javax.xml.namespace

I am trying to deploy a simple feature into a branded Karaf 4.0.2 which brings a bundle with a JAXB Specification:
<?xml version="1.0" encoding="UTF-8"?>
<features name="my-feature" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0">
<feature name="my-javaee-api" version="6.0-5" install="auto">
<bundle>mvn:org.apache.geronimo.specs/geronimo-jaxb_2.2_spec/1.0.1</bundle>
</feature>
</features>
It fails with the following error message:
2015-12-22 13:38:07,218 | ERROR | a0a-abc5141ad81f | FeatureDeploymentListener
| 43 - org.apache.karaf.deployer.features - 4.0.2 | Unable to install features
org.osgi.service.resolver.ResolutionException: Unable to resolve root:
missing requirement [root] osgi.identity; osgi.identity=my-javaee-api; type=karaf.feature; version="[6.0.0.5,6.0.0.5]";
filter:="(&(osgi.identity=my-javaee-api)(type=karaf.feature)(version>=6.0.0.5)(version<=6.0.0.5))"
[
caused by: Unable to resolve my-javaee-api/6.0.0.5:
missing requirement [my-javaee-api/6.0.0.5] osgi.identity; osgi.identity=org.apache.geronimo.specs.geronimo-jaxb_2.2_spec;
type=osgi.bundle; version="[1.0.1,1.0.1]"; resolution:=mandatory
[
caused by: Unable to resolve org.apache.geronimo.specs.geronimo-jaxb_2.2_spec/1.0.1:
missing requirement [org.apache.geronimo.specs.geronimo-jaxb_2.2_spec/1.0.1] osgi.wiring.package;
filter:="(&(osgi.wiring.package=javax.xml.namespace)(version>=1.0.0))"
]
]
I wondered how it could miss javax.xml.namespace because it's a part of OSGi-Framework. So I checked if that package is really missing:
admin#root()>package:exports | grep javax.xml.namespace
javax.xml.namespace | 0.0.0 | 0 | org.eclipse.osgi
And voila - here's the root of the problem - the version. For a comparison I checked how it looks on a stock karaf:
karaf#root()> package:exports | grep javax.xml.namespace
javax.xml.namespace | 0.0.0 | 0 | org.apache.felix.framework
javax.xml.namespace | 1.4.0 | 0 | org.apache.felix.framework
It uses Felix and has a proper version 1.4.0. My first thought was that the branded karaf uses Equinox as default OSGi-Framework and switching it to Felix would fix that. But a look inside karaf/etc/config.properties has disproved that thought (it looks exactly like stock):
karaf.framework=felix
karaf.framework.equinox=mvn\:org.eclipse.birt.runtime/org.eclipse.osgi/3.10.2.v20150203-1939
karaf.framework.felix=mvn\:org.apache.felix/org.apache.felix.framework/5.2.0
Now I reached an impasse and don't know how to resolve my problem. Any ideas?
Unfortunately I cannot contact people who branded karaf at the moment because they are already at christmas vacation ¯\_(ツ)_/¯
Make sure that your custom distribution doesn't change the config.properties.
If it does make sure that the org.osgi.framework.system.packages.extra
does contain that version for javax.xml.namespace;version=1.4,
Usually if you want to override certain properties for Karaf you can put those changes into the custom.properties
The exports from the OSGi Framework are controlled by the configuration properties org.osgi.framework.system.packages and org.osgi.framework.system.packages.extra. These are appended at runtime to form the system bundle exports.
It seems that in your "stock" version of Karaf (not sure what that means but I'll just use your term) somebody has added javax.xml.namespace;version=1.4.0 to one of those configuration properties. If you are able to do the same in the other version of Karaf then things should work.

Sonar Report + Multi module maven + Jacoco plugin

I am new to Sonar.
I have multi-module maven project.
please find the Project structure below
-Parent
| -Module A
|
-pom.xml (Module A)
| -Module B
|
-pom.xml (Module B)
| -Module C
| |
| -pom.xml (Module C)
|
--pom.xml (parent pom)
Note : (Module C is shared module in Module A/ Module B - means Internally module C will the part of into Module A , Module B library)
Based on the Project requirement we have these structure.
Module A - works for external users.
Module B - works for internalusers.
Module C -common b/w both the module.
I am trying to create single sonar report for both the module, but I am not able to integrate all the module junit report (Module A and Module B report)
into single report.I followed couple of example to combine the muti-module maven porject but nothing works.
similar issue1 similar issue2
github-example (reference given in sonar)
I had similiar problem with over 40 modules which were even nested. What you have to do is to create whole sonar configuration in parent pom.
<sonar.host.url>set url here (default is localhost)</sonar.host.url>
<sonar.login>user for host url (default admin)</sonar.login>
<sonar.password>password for host url (default is admin)</sonar.password>
<sonar.projectName>optional name for whole project in sonar view</sonar.projectName>
<sonar.projectDescription>optional project description for sonar view</sonar.projectDescription>
<sonar.projectBaseDir>like name says you can set project base dir, if you have parent pom as a separate module then you can type ".." to set main directory with all modules</sonar.projectBaseDir>
Set properly all modules which will be analysed separately for the whole project:
<sonar.modules>module1, module2, module3</sonar.modules>
Configure each one of them properly:
<module1.sonar.projectName>module1</module1.sonar.projectName>
<module1.sonar.projectBaseDir>module1/</module1.sonar.projectBaseDir>
<module1.sonar.sources>optionally set sources to proper directory for example src/main/java</module1.sonar.sources>
<!-- similiar for other 2 projects -->
That way all junit reports will be used per module but it will be listed in single project with modules. That way you will be able to see reports per module and per whole single project.
It's a good practise to check results after adding every single module. In case of failure simply check error in console and fix the problem.
I am able to achieve Integration test coverage using sonar with Jococo plugin.
To run the Sonar in local, i was facing the issue with SCM error in sonar.
Every time it was failing in the in sonar report creation.
For resolving the issue in local you need to disable the SCM configuration in sonar.
login in local sonar as Admin - admin/admin (default username/password)
Now under setting we have SCM tab - disable the SCM Senor and save the SCM Setting.
Now in Dashboard --> Configure widgets .Search "Integration Tests Coverage"
Now add widget into your Project Dashboard.
Follow the same configuration in your pom.xml as given in the link.
https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/code-coverage/combined%20ut-it/combined-ut-it-multimodule-maven-jacoco

Create a war containing only image

I'm trying to create a war that is to be deployed in an EAR and that should contain only images.
My war source organization is as follows :
+---src
| +---main
| | +---java
| | +---resources
| | | \---META-INF
| | | \---resources
| | | \---images
| | | placeholder_image.jpg
| | | placeholder_template.png
| | |
| | \---webapp
| | \---WEB-INF
| \---test
| +---java
| \---resources
and my war effective organization is
+---META-INF
\---WEB-INF
\---classes
\---META-INF
\---resources
\---images
placeholder_image.jpg
placeholder_template.png
The images I want to serve are in the src/main/resources/META-INF/resources/images folder.
I package this war using maven-war-plugin.
Under which url will those images be available on my local machine, provided my war is indicated as available under the http://localhost:8080/myapp/ path ?
None. Content from WEB-INF is not statically served, resources is for classpath resources. You need to put the images (folder) directly under webapp or add an servlet that serves the content.
This depends on whether you deploy the war in a Servlet-3-compatible container like Tomcat 7 or Jetty 8.
If so, your resources should be visible under http://localhost:8080/myapp/images/....
See also this post, where the only difference is that the resources are packaged in a jar. For jars, this feature makes more sense than for WEB-INF/classes, as, like the first answer points out, you should simply put your resources directly into src/main/webapp if they are located in the same Maven module.

Resources