-1

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

Tryliom
  • 111
  • 1
  • 17
triton oidc
  • 523
  • 5
  • 13

2 Answers2

0

Use Maven to make a jar with mvn package or use Eclipse to create a Runnable jar

Tryliom
  • 111
  • 1
  • 17
  • Thanks for the answer, but how do i include the file /META-INF/services/ in the jar ? I create a new mvn project with just one class, then do some modification on the project ? Or do i do it manually after the jar creation ? – triton oidc May 28 '18 at 10:44
  • There are configuration in Maven to add what you want to your jar, read the doc – Tryliom May 28 '18 at 10:59
  • Add your pom.xml to post – Tryliom May 28 '18 at 11:16
  • When i wish to build the mvn project, i got the same error : `no service provider org.my-class-to-implement` i must be missing something, but i don't know what. Thanks again for your answer, that's what i asked for in the first time, an example or a procedure. I'll keep searching for answers – triton oidc May 28 '18 at 11:17
  • Add it to the main post for best reading, add `Edit: Add Maven to project -> pom.xml` and the content of the pom.xml, thanks – Tryliom May 28 '18 at 11:30
  • Do you think i still should put the pom.xml ? it's 121 lines, and i don't think it's going to help someone much – triton oidc May 29 '18 at 12:41
  • Give it via pastebin/hastbin – Tryliom May 29 '18 at 12:45
  • Use [Shade library](https://maven.apache.org/plugins/maven-shade-plugin/) – Tryliom May 30 '18 at 07:49
  • I managed to create the jar two days ago, the blocking point was that i had to include the interface in the module (just importing it using imports was not enough). I don't need this shade library. Thanks for the answer anyway – triton oidc May 31 '18 at 08:48
0

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

triton oidc
  • 523
  • 5
  • 13