2

I want to add 3rd party external jar into my maven repository. My project is in Spring Boot.

Error :

`Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)

Caused by: java.lang.NoClassDefFoundError: com/omnesys/omne/om/OMNM
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
        at java.lang.Class.getConstructor0(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at com.omnesys.nestq.classes.ClassNestQ12.<init>(ClassNestQ12.java:28)
        at com.omnesys.nestq.classes.NestControl.<init>(NestControl.java:39)
        at orion.ibclient.OmnesysJAPI.<init>(OmnesysJAPI.java:69)
        at orion.TradingProgram.connectToNest(TradingProgram.java:452)
        at orion.TradingProgram.main(TradingProgram.java:90)
        at com.orion.main.OrionController.loadPrperty(OrionController.java:39)
        at com.orion.main.NestOrionApplication.main(NestOrionApplication.java:21
)
        ... 8 more
Caused by: java.lang.ClassNotFoundException: com.omnesys.omne.om.OMNM
        at java.lang.ClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 19 more`

I had done following things but still I am getting the same error.

NOTE : It working for other jar but not worked only for this jar. Like for DealerSample.jar its working but not working for this jar. You can see the difference in below picture. When I added the same jar in Simple java project through Build path its working but not in Spring Boot project.

  1. Add external jar : https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html : Added my jar to .m2 folder and add dependancy into maven.

Maven Command : mvn install:install-file -Dfile=D:\Vijay\Jars\OmneVerse.15.0.0.0.jar -DgroupId=com.orion -DartifactId=OmneVerse -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true

Pom.xml:

    <dependencies>
        <dependency>
            <groupId>com.orion</groupId>
            <artifactId>OmneVerse</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            <configuration>
                <includeSystemScope>true</includeSystemScope>
            </configuration>
        </plugin>
    </plugins>
</build>

My Project Libs structure :

enter image description here

vijayk
  • 2,633
  • 14
  • 38
  • 59

1 Answers1

0

Why not try Nexus Repository Manager? Though this approach may be long and complex. But I think it is the best and lasting solution to your problem. I have used it many times and find it very helpful.

AfamO
  • 849
  • 8
  • 7
  • Its paid one. If you know the answer please help me in the same setup. – vijayk Jun 18 '20 at 13:05
  • Ok. You mean you are trying out something personal, not for commercial use? – AfamO Jun 18 '20 at 13:12
  • Its commercial but right not we are not in position to buy something. – vijayk Jun 18 '20 at 13:38
  • Ok. No problems. Can you confirm that the jar file(with the same artifactId , groupId and version) is inside '.m2' folder after executing the above 'maven install' command ? – AfamO Jun 18 '20 at 14:58
  • Yes its present at the location. – vijayk Jun 19 '20 at 06:29
  • I have recreated the scenario in my system and everything is fine-I can build successfully. Could you try building the application from command line using 'mvn package' command. I mean the problem could be wrong configuration from your IDE ? – AfamO Jun 20 '20 at 19:44