-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to instruct jandex to index a dependency jar? #1960
Comments
The index is passed to the schema builder via For example, the WildFly GraphQL Feature pack uses the |
I was using the smallrye-graphql-servlet in my project, and I didn't even know that it was made for WildFly. Now I understand why it has some dependencies on jboss logging. Anyway, looking at the StartupListener you provided, it seems that it will scan the WEB-INF/lib folder and include all of jar files to the index. So, a packaged WAR file would work just fine. The thing is, I am using OpenLiberty's dev mode do develop my aplication. This means that, instead of deploying a real WAR file, it creates a XML file that mimics the structure of the WAR file, pointing to resources somewhere else on the file system. An example can be seen below:
As can be seen above, app-service is my application and app-model contains the model definitions (including GraphQL stuff). They are part o multi module maven project. You can notice that the app-model.jar points to the build directory of my project, instead of a real JAR file. I then copied the StartupListener to my project (with the same package, so that the class loader would choose mine instead of the one in the dependecy), and made the following changes with success:
The getResourcePaths method will get all the elements in the XML whose targetInArchive tag starts with WEB-INF/lib. Then we use the getRealPath method to get the value of the tag sourceOnDisk. The above solution would work for both cases, a real WAR deployment, and a fake XML deployment. Maybe you could integrate it with your project, with the necessary modifications that you may need, and remove the part where you traverse the WEB-INF/lib looking for files. By the way, before working this out, I had tried to use the OpenLiberty mpGraphQL-2.0 feature, and it had the same problem while using dev mode. I guess their implementation is based on the one you provided. |
So the mpGraphQL feature works in war-mode but not in dev-mode? If I got that right, maybe you should suggest your changes to the OpenLiberty project, as the dev-mode is OpenLiberty specific. |
I decided not to use mpGraphQL feature of OpenLiberty because they use an old version of SmallRye GraphQL. Instead, I am using smallrye-graphql, smallrye-graphql-servlet and smallrye-graphql-ui-graphiql as maven dependencies. I've fixed the problem in dev mode for me. And I just wanted to share how I got it working, because I believe it's more container agnostic if you rely on container specific methods to find resources (getResourcePaths followed by getRealPath), instead of iterating over the filesystem. I'll will probably report that on the OpenLiberty github as well. Thanks for your help. |
I am trying to run a multi module project where one of the modules has all the type definitions, and I also have a module with the application itself. It seems that jandex will only index classes of the application war file. Is there a way to instruct jandex to index a dependency jar?
I am using openliberty with SmallRye GraphQL 2.5.1 as dependency of my project. That means, I am not using the mpGraphQL-2.0 feature.
Here is the error:
SRVE0283E: Exception caught while initializing context: graphql.AssertException: type Xyz not found in schema
It seems quarkus has a configuration for this, as can be seen in the following issue:
quarkusio/quarkus#36688
The text was updated successfully, but these errors were encountered: