All things are lawful, but not all things are profitable.
Knute Snortum wrote:I'm confused. What's the command you issued that caused the error?
Paul Clapham wrote:That looks like an error message saying that it can't find a certain file. But you're talking about a JAR file in a way that makes me think that there's something inside the JAR which is supposed to be used. And things inside JAR files are resources, not files, so perhaps the code throwing the error message is looking for a file and not a resource?
java.io.IOException: Cannot run program "/Users/mike/.m2/repository/com/ibm/spssplugi/MacOS/StartXD.sh": error=2, No such file or directory
All things are lawful, but not all things are profitable.
Knute Snortum wrote:Is this an exact copy of (part of) the error message?
java.io.IOException: Cannot run program "/Users/mike/.m2/repository/com/ibm/spssplugi/MacOS/StartXD.sh": error=2, No such file or directory
Notice that it references "spssplugi", not spssplugin. Try searching your POM to see if "spssplugi" is anywhere and add the n.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:Here's a note about how to ask questions so that you get a good answer. Describe the problem fully. Describe exactly what you were doing when you got the error. Copy and paste the full error message or stack trace.
So in this case, I'm guessing this is what happened:
* You put a 3rd party jar into the Maven local directory
* You build the project with the command mvn install or the like (exact command unknown)
* You execute the application from IntelliJ
* While running the application you encounter an error (stack trace unknown)
* You build the project some other way (unknown)
* When you execute the application, you don't get an error
Is that about right? The problem is, I have to guess at a lot of what you did. I'm not even sure I'm describing the problem correctly -- but that's your job. I shouldn't have to guess.
Also (if the above is correct) your conclusion is that there's a bug in Maven. But isn't it more likely that there's a problem with your POM?
So if you can't find any problem in your POM, go through my starred assumptions, filling in the unknown information and correcting what's wrong. This is what we call TellTheDetails (that's a link).
All things are lawful, but not all things are profitable.
Knute Snortum wrote:Thanks for your post with a more detailed explanation. If you are pretty sure it's not a POM configuration problem, tell me what you do exactly to build the project some other way.
Another note: Please UseCodeTags (that's a link) when you post code; don't use screenshots. It's a lot easier to copy the code if needed when it's pasted in with code tags surrounding it.
Mike London wrote:Sorry, I thought I was pretty thorough.
* You put a 3rd party jar into the Maven local directory
Yes, as I indicated above, that's what I did. I also included above the exact maven install command I used.
* You build the project with the command mvn install or the like (exact command unknown)
For the SpringBoot version, yes, Maven install. However, for the separate test project(s), which has the exact same problem, as you can see with the screen-shot I posted above, this was a non SpringBoot example with a simple Java main method.
* You execute the application from IntelliJ
Yes, but also tested with MyExclipse and using the output JAR generated from Maven "Install" goal.
* While running the application you encounter an error (stack trace unknown)
I included the stack trace above in my last posting for the test project I created.
* You build the project some other way (unknown)
As mentioned in postings problem happens with simple Java application. And, in the separate production project using SpringBoot with built jars.
* When you execute the application, you don't get an error
In the main method of the sample project (screenshot in last posting), the error happens on the first line of code that references the JAR file (StatusUtil.start()).
If I run the separate SpringBoot project, then the project loads and then crashes when the incoming URL hits that same line of code.
So, really the same behavior.
All things are lawful, but not all things are profitable.
If I instead import the spss jar file into a standalone (separate) Java project (no maven), then it works fine.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:I'm pretty baffled too.
If I instead import the spss jar file into a standalone (separate) Java project (no maven), then it works fine.
Could you expand on this? I'm very interested in a project that works correctly. What exactly do you mean by "import the ssps jar"?
Knute Snortum wrote:I may need to try this out myself (downloading the SPSS jar and running the simple program) to get a better idea of what's going on.
Dave Tolls wrote:In the installation directory for SPSS does it have that sh script?
I have seen other errors like this in a simple google, but for the exe (which I presume is the WIndows installation), for example here.
Reading that and it seems that it needs to be linked to in situ...as in, the classpath points to the jar file in the installation directory.
Now, I can only assume that means that the missing file is actually somewhere in that area, and so won't actually be available if you stick it in Maven.
If that's the case then this isn't a Maven issue, but an IBM one.
Dave Tolls wrote:I'm not saying the jar file is missing.
I'm saying that, from that IBM forum thread, you should be pointing your classpath at the jar file in the installation directory, because it looks like it uses that location to find the relative path to this shell script.
How are you adding the jar file to the regular Java project?
If you are using the IDE to point at the jar file in the installation directory then that would explain why it works.
But have you actually looked for that file?
All things are lawful, but not all things are profitable.
Knute Snortum wrote:I came to the same conclusion as Dave Tolls: you can't move the spssplugin.jar file from the IBM installation directory. This link talks about how to distribute an app using spssplugin.jar. It sounds like you need the end user site to have IBM SPSS installed and then you use either an ini file or a utility to locate the installation.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:My take on the web page is that you can't use Maven to find the spssplugin.jar, unless you used the bat file and rewrote the POM -- but don't do that. Programmatically load the jar file using the utilities mentioned in the web page. My guess is that it would go like this:
* Download the SPSS developer utilities here
* Use those utilities in your app to get the location of the local IBM SPSS installation
* Use the Java Class class to load the jar file: Class.forClass("location/of/spssplugin.jar");
There may be another way to programmatically load an external jar file in Java, but Class.forName() is the one I know.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:Well, if you don't mind changing the POM for every installation, you can specify a local repository and point it at your local jar file (I think, I haven't tested it). But this sort of defeats the idea of a POM file, which you should be able to just download, run mvn clean install, and be done with it.
Rather, I'm suggesting (or IBM is) that you use the utilities to find the path to the local installation, then load the jar in Java programatically. With this approach, Maven doesn't know about the SPSS jar file at all; it's all handled in Java.
I've tested the code below and it works for me. What I don't know for sure is whether you have do a Class.forName() for every class you need. If so, then the Maven local repository is the way to go.
Mike London wrote:...
However, if I'm using Maven for the rest of the SpringBoot project, how do I first load the spssplugin.jar file (assuming you meant Class.forName()) so the maven project can resolve dependencies?
I may be missing part of your point.
- mike
Dave Tolls wrote:
How do you run it in the IDE? What is the configuration used?
Good questions.
The configuration in the iDE, which works is this pom.xml portion below.
Note that I am merely referencing the server SPSS JAR file, not including it in the JAR.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spss.lib.folder.macserver>/Applications/IBMSPSSStatistics/Subscription/SPSSStatisticsSubscription.app/Contents/bin/spssjavaplugin.jar</spss.lib.folder.macserver>
</properties>
<dependencies>
<!--
Can't do this since you can't have the IBM SPSS JAR locally --> WON'T WORK
<dependency>
<groupId>com.ibm.statistics</groupId>
<artifactId>spssjavaplugin</artifactId>
<version>1.0</version>
</dependency>
-->
<dependency>
<groupId>com.ibm.statistics</groupId>
<artifactId>spssjavaplugin</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${spss.lib.folder.macserver}</systemPath>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Dave Tolls wrote:[b]How do you run the jar file?
The JAR file is the same project built by the maven install goal.
I then run it at the command line like this:
$java -jar spss.jar
Dave Tolls wrote: ETA: Also, what do your logs show?
Ensure they are setup to show debug level, and add some more debug logging into the loadSpssJar method.
The logs show the same Exceptions as posted.
As you suggested, I added more logging to the loadSpssJarInfo() method, and, indeed, the classes are being dynamically loaded:
Gives...
07:45:09.999 [main] DEBUG com.spssdemo.SpssdemoApplication - Loaded com.ibm.statistics.plugin.StatsUtil
07:45:10.005 [main] DEBUG com.spssdemo.SpssdemoApplication - Loaded com.ibm.statistics.plugin.StatsException
Dynamically Loaded SPSS Classes from SPSS JAR...
-----
Does this additional info help?
Thanks,
- mike
Dave Tolls wrote:Well, when I run code in my IDE I use the run button, so I was checking to see how you were doing it.
What are you selecting in order to run the code?
(Actually, might have missed it, but what IDE is it?)
Also you say you run the jar file, so how do you do that?
(And your quote boxes are a bit out of synch).
Dave Tolls wrote:OK, so the IDE is launching from the main() definitely.
What do the logs show for the version run from the command line?
What's the MANIFEST for your jar file hold?
Edit: Ah, forget about the logs bit, I just saw that you are seeing the output for loading the classes!
All things are lawful, but not all things are profitable.
Knute Snortum wrote:My conclusion from playing with the POM file in Maven is that you can't make a dependency to the IBM SPSS plugin jar because Maven requires a version and the path to the plugin doesn't include a version. Basically, you can't make SPSS's folder structure fit Maven's requirement. At least, I didn't find a way.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |