Search code examples
javamavenjbossjavac

create jar with META-INF\services for Jboss module extension


I wish to implement an interface, to create a jar to put it in the deployment folder in JBoss.
I only have one .java file.
However I can't get any jar working.

I could not find any doc on how to build the Jar.
I'm willing to use any tool, i tried an InterliJ Artefact (was the whole project).
I tried javac (using the InteliJ artefact for libraries), then jar, then adding the file /META-INF/services/org.[myinterface] manually

I found the two posts Adding META-INF\services\javax.xml.parsers.SAXParserFactory to jar and Create META-INF/services file with Maven
But none of these give me enough precision.

I don't think it's helping, because I know my Jar has en issue, but here is the error in the deployment :

org.my-class-to-implement: Provider org.my-implementation not found

If someone has a link to an existing project that can generate the correct jar, or a procedure to create it, that could save my day

Question that could help me : Is it ok to manually add the /META-INF/services/ file ?
If there is a package name, should i mention it somewhere ?

Thanks for any help, if i find the correct procedure in the meantime, i'll post it here


Solution

  • I managed it using an artefact in Intellij
    It worked once i put the Abstract class (the one i whished to implement) in the module

    step to follow :

    • create a module in Intellij (i copyed an existing example)
    • Add the class i wished to implement
    • Put the implementation of the class
    • In src/main/ressources/META-inf/org.my.interface.to.implement put the name of my class : org.my.implmentation
    • Create an artefact of the module (you can follow this guide How to build jars from IntelliJ properly?)
    • The jar can deployed in the JBOSS deploy directory

    I removed the pom in the commentary to avoid confusion. I can send you the jar or the module per mail if that can help, just ask