This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Confusing maven error: Cannot run program

 
Rancher
Posts: 4618
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried modifying the manifest to supply Spring Boot with the extra classpath info, as I suggested?
 
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:I have assigned few cows for members who helping OP tremendously by investing their time within this thread.
This message will disappear within a day.



I totally agree. The support here on this topic has been incredible.

Thanks to all.

- mike

P.S. Due to these issues encountered, we've abandoned SPSS and are going to use R instead.
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Maven, you just can't reference the IBM SPSS jar in Maven; you have to add that jar to the project manually.  Or you can use the IBM utilities to find the path of the installation directory, but this requires that you use reflection every time you need an SSPS method -- not trivial!  Here is what the demo code looks like using reflection:
...and here is the utility class I used to abstract away all the reflection code: (Note: this is a full utility class; you don't need all of it in your programs)
 
Mike London
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks nice, but were you able to get their simple example to work in a SpringBoot service?

I tried to dynamically load the classes using your code from a day or so ago in the Spring startup sequence (Before the JavaApplication run method), and other places, but when loading the JAR on the command line, it still did not work (ClassNotFound exception for StatsException, despite that I loaded it dynamically).

Since this is similar to the reflection code you posted before (that I couldn't get to work), if you've tested this updated logic with SPSS and a SpringBoot JAR, I will take another look.

Appreciate all you're doing to help.

- mike
 
Mike London
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason I asked if you tested it is that I dynamically loaded both classes right in the code where they're needed and it still doesn't work. Starting the JAR from the command line has ClassNotFound Exceptions. I also tested the dynamic JAR loading on app start up and in other places. Made no difference.

See attachment for where I put the reflection load method call below in one test.

The first error is actually about failed introspection...I moved the JAR loading code due to this error, but the end result is the same.
.
.
.
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spssService': Failed to introspect bean class [com.company.spssdemo.service.SpssService] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: com/ibm/statistics/plugin/StatsException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:269)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 27 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/ibm/statistics/plugin/StatsException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:247)
... 39 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.ibm.statistics.plugin.StatsException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 46 common frames omitted

------------------

Thanks again for all your help.

- mike
jarinfo.png
[Thumbnail for jarinfo.png]
 
Dave Tolls
Rancher
Posts: 4618
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It fails because Boot starts up from its own launcher, and then goes to piece together the app via injection.
One of the classes to be wired up is your SpssService class, which uses (not too surprisingly) some classes from the SPSS plugin.

All of this happens before any of your actual code is run.

That's why I started to look at a way of adding the jar to the classpath used by Boot.
 
Mike London
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:It fails because Boot starts up from its own launcher, and then goes to piece together the app via injection.
One of the classes to be wired up is your SpssService class, which uses (not too surprisingly) some classes from the SPSS plugin.

All of this happens before any of your actual code is run.

That's why I started to look at a way of adding the jar to the classpath used by Boot.



Yep, what you're saying is EXACTLY why I asked Knute if he tested his idea.

BTW, I also tried several things in the MANIFEST file, based on your interesting suggestions, but none worked for me.

We're moving away from SPSS now. I had hoped there might be something that would work, and I think I've done all that is reasonable at this point.

Considering that (free!!!) "R" and other environments are not "Maven-hostile", we'll move that way.

Thanks again!

- mike
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did test my code, but I don't have a Spring environment.  It sounds like Dave Tolls has a way through the problem, but it sounds like you're going to code this in R now.  BTW, why were you using Spring?
 
Mike London
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I did test my code, but I don't have a Spring environment.  It sounds like Dave Tolls has a way through the problem, but it sounds like you're going to code this in R now.  BTW, why were you using Spring?



Hi Knute,

We are using SpringBoot so we can create a RESTful interface between one program and SPSS.

Thanks,

- mike
 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic