spring framework build error - spring

I am trying to build spring framework (both trunk and 3.0.5 Release). The build fails with the error was shown below. Steps taken.
svn co https://src.springsource.org/svn/spring-framework/trunk spring-framework
or svn co https://src.springsource.org/svn/spring-framework/tags/spring-framework-3.0.5.RELEASE spring-framework-3.0.5.RELEASE
cd build-spring-framework
ant
Unfortunately, I am building on windows machine. Java version shows
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
thanks.
[s:javac] at org.apache.tools.ant.Task.perform(Task.java:348)
[s:javac] at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
[s:javac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[s:javac] at sun.reflect.GeneratedMethodAccessor151.invoke(Unknown Source)
[s:javac]
[s:javac] ----------
[subant] Leaving directory: C:\Work\SpringFramework\spring-framework-3.0.5.RELEASE\org.springframework.web
BUILD FAILED
C:\Work\SpringFramework\spring-framework-3.0.5.RELEASE\spring-build\multi-bundle\artifact.xml:60: The following error oc
curred while executing this line:
C:\Work\SpringFramework\spring-framework-3.0.5.RELEASE\spring-build\multi-bundle\common.xml:86: The following error occu
rred while executing this line:
C:\Work\SpringFramework\spring-framework-3.0.5.RELEASE\spring-build\common\artifact.xml:43: The following error occurred
while executing this line:
C:\Work\SpringFramework\spring-framework-3.0.5.RELEASE\spring-build\common\common.xml:161: The following error occurred
while executing this line:
C:\Work\SpringFramework\spring-framework-3.0.5.RELEASE\spring-build\standard\common.xml:29: java.lang.reflect.Invocation
TargetException

Well, I am still to correct it.. but the actual cause was
java.lang.OutOfMemoryError: PermGen space
I remember I have to increase the XX:MaxPermSize VM argument, and going through the option. Sorry for the trouble.
Edit:
adding a system variable ANT_OPTS with value -XX:MaxPermSize=128m -Xmx256m did the trick.

Even using ANT_OPTS="-Xms768m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m" the build is failling. There is no PermGen error anymore but the unit tests are failling.
Whereas I'm just trying to use build/IVY to get all dependencies becouse I just need to debug spring code to learn things that are not in the docs, and considering that Spring code is ok, I'm disabling all the tests that are failling but I think that shouldn't exists such errors.
I will try to make a ant clean, to erase the IVY repository chache and start all again.
Actually I just want to learn what configurations I must to change to build my own HttpMessageConverter to use with #ResponseBody to do Json things with Gson and not with Jackson.

Related

macOS: how to install JavaFX properly to run mqtt-spy?

I'm trying to run mqtt-spy-1.0.0.jar on my macOS 10.14 system but it won't start, returning the following error message:
According to the developers, this problem is caused if JavaFX is missing on the system.
The latest version of the Oracle JDK is installed on my system as can be seen below, however, I'm aware that Oracle has excluded JavaFX from the JDK in v11.
So I downloaded JavaFX from GluonHQ and followed their instructions on how to get started.
Despite having both required variables set correctly in ~/.bash_profile, mqtt-spy-1.0.0.jar is still returning the error message shown on the first screenshot ...
What else do I need to do or what do I need to do differently to run mqtt-spy?
There is already an issue filed about this, but not a solution.
I haven't really tried to get it fully working, but these are the required steps to run a jar on Java 11 that requires JavaFX 11, but doesn't bundle it:
Go to OpenJFX docs and read about how to get started with JavaFX 11.
Download JavaFX 11 for your platform from here. Unzip it
Providing that you have Java 11 installed, and set as JAVA_HOME:
With mqtt-spy-1.0.0.jar (as latest release), you can run:
java --module-path /path-to/javafx-sdk-11.0.1/lib \
--add-modules javafx.controls,javafx.fxml -jar mqtt-spy-1.0.0.jar
After you run this, you will get this exception:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
Since Java 9, JAXB is not part of the JDK either. So you can add try to download the dependency from here) and add it to the classpath. But this will take some iterations (there are a few other required jars more, see this).
So why don't you use the latest snapshot available, that includes dependencies: mqtt-spy-1.0.1-beta-b18-jar-with-dependencies.jar.
With this:
java --module-path /path-to/javafx-sdk-11.0.1/lib \
--add-modules javafx.controls,javafx.fxml -jar mqtt-spy-1.0.1-beta-b18-jar-with-dependencies.jar
I get:
Warning: But this doesn't mean that the app will fully work. Given that it is a Java 8 app, there are things that have changed in JavaFX 11, mainly related to the control skins. If the app was using private API (com.sun.javafx....), that won't work now, because either it has been moved to public packages, or because it is not accessible by the modules. For the latter you can use --add-opens, but for the former there is no solution other than update the app dependencies to Java 9+.

no matter what i do sonar refused to go beyond Unsupported major.minor version 52.0 in jenkins

I am trying to set up devops and have reached up-to sonarQube integration in jenkins. Now its not moving beyond "Unsupported major.minor version 52.0". I had java 1.8 but i installed 1.7 to remove this error. Still coming. Changed java version (checked in command line as well). JAVA_HOME, PATH, all those variable point to java 1.7. Still coming. I can run analysis on sonarqube server, if i try separately (localhost:9000) but in jenkins it's just refusing to go beyond this message. I am not from java background so i might be missing something obvious. Any help is appreciated
The JVM used to run the job must be >=Java 8. Whether or not you had it installed, the error you're getting indicates that Java 8 wasn't being used by the job.

How to add enable flag for Flight Recorder in Maven project?

I'm just about start using Java Mission Control 5.3.0.
I have added -XX:+UnlockCommercialFeatures -XX:+FlightRecorder into my web-app's jetty.template.
Then I start the web-app with mvn jetty:run.
But while I was starting Flight Recorder I got the problem occurred pop-up as below.
'Start Flight Recording.. (Last attempt failed)' have encountered a problem.Commercial features are not enabled. In JDK7u4 and above,the JVM must be started with -XX:+UnlockCommercialFeatures -XX:+FlightRecorder .
And I also try adding the flags as below into pom.xml but it doesn't work.
<jvmArgs>
<jvmArg>-Xmx128m</jvmArg>
<jvmArg>-Xms128m</jvmArg>
<jvmArg>-XX:MaxPermSize=512m</jvmArg>
<jvmArg>-XX:+UnlockCommercialFeatures</jvmArg>
<jvmArg>-XX:+FlightRecorder</jvmArg>
<jvmArg>-XX:StartFlightRecording=duration=160s,delay=20s,settings=profile,filename=target/recording.jfr</jvmArg>
</jvmArgs>
What should I do for enable Flight Recorder on my web-app?
That configuration should be added to the running VM of Jetty so I'd try this:
mvn jetty:run -XX:+UnlockCommercialFeatures -XX:+FlightRecorder
I could not test this, and I work most on Tomcat, but I think this could help you
I got the answer by using below.
export MAVEN_OPTS="$MAVEN_OPTS -XX:+UnlockCommercialFeatures -XX:+FlightRecorder"
If you are using jcmd command from jdk, then could enable JFR via:
jcmd 31118 VM.unlock_commercial_features
Then use JFR.
e.g
jcmd 31118 JFR.start name=a
After some tests, I'll add something that could help someone else :
This is the JVM (Azul Zulu) I am using for my tests :
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (Zulu 8.50.0.21-CA-linux64) (build 1.8.0_272-b17)
OpenJDK 64-Bit Server VM (Zulu 8.50.0.21-CA-linux64) (build 25.272-b17, mixed mode)
I created in the top of the project a file :
.mvn/jvm.config
That contains only one instruction :
-XX:StartFlightRecording=filename=build.jfr
Then, do whatever mvn goal you want to do and look for the build.jfr command you want.
Zulu's JVM has flight record enabled by default, so you this is one step less to worry.
It is important to mention that, in my case I had several JVM's installed in my machine and the mvn command uses JAVA_HOME variable, so make sure it is pointing to the right jvm.

FHIR build fails with NoSuchMethodError: net.sf.saxon.Configuration.newConfiguration()

Following instructions at http://wiki.hl7.org/index.php?title=FHIR_Build_Process my FHIR build is failing. I modified the publish.bat to ensure it uses the correct JDK. Running it on Windows 7 64-bit machine with JDK 1.6 (also tried JDK 1.7) and both failing with same error.
Looks like some Saxon JAR hell somewhere. Any ideas?
...validate v2-tables 441sec 755MB
...validate v3-codesystems 443sec 889MB
Reference Platform Validation. 447sec 1067MB
...test adversereaction-example 447sec 1067MB
Exception in thread "main" java.lang.NoSuchMethodError: net.sf.saxon.Configuration.newConfiguration()Lnet/sf/saxon/Configuration
;
at net.sf.saxon.xpath.XPathFactoryImpl.<init>(XPathFactoryImpl.java:33)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at javax.xml.xpath.XPathFactoryFinder.loadFromService(XPathFactoryFinder.java:401)
at javax.xml.xpath.XPathFactoryFinder._newFactory(XPathFactoryFinder.java:222)
at javax.xml.xpath.XPathFactoryFinder.newFactory(XPathFactoryFinder.java:143)
at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:185)
at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:99)
at org.hl7.fhir.tools.publisher.Publisher.testSearchParameters(Publisher.java:2796)
at org.hl7.fhir.tools.publisher.Publisher.testSearchParameters(Publisher.java:2785)
at org.hl7.fhir.tools.publisher.Publisher.validateRoundTrip(Publisher.java:2759)
at org.hl7.fhir.tools.publisher.Publisher.validateXml(Publisher.java:2656)
at org.hl7.fhir.tools.publisher.Publisher.execute(Publisher.java:378)
at org.hl7.fhir.tools.publisher.Publisher.main(Publisher.java:281)
A workaround... do a fresh build of the publisher tool jar from source.
Following instructions in the build/buildhowto.txt I was able to build the tool jar inside Eclipse, run the Publisher successfully from inside Eclipse and then export it as a fresh tool jar overwriting the one I pulled from SVN. The freshly build one then ran to completion from the command line.
Could be there's just a problem with the version of tools jar out there in SVN at the moment.
For the record I am working with Version 0.12-1953.
You have two classes net.sf.saxon.Configuration in your classpath. One containing the method newConfiguration() and one not.
The method is probably called from Saxon-HE 9.x, and the class net.sf.saxon.Configuration is found in saxon 8.x, while the class should have been found inside Saxon-HE 9.x, where it also is, and does have this method.
So, check your dependencies to see if saxon 8.x is called, and try replacing that with Saxon-HE 9.x, then your problem is solved

Maven - Could not reserve enough space for object heap error

I am Maven to build my Java project. After several successful build, I am now getting the following error:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
In my maven.sh file that my build is using, I have added the following as the first line
export MAVEN_OPTS=-Xmx512m
I am still getting the error.
Can anyone suggest a fix?
The solution was to set the forkMode of maven-surefire-plugin to 'never'. It seems that when tests are run, maven sure fire spawns a new JVM. Setting it to never fixed the issue.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
**<forkMode>never</forkMode>**
<argLine>-Xms1024m -Xmx1024m -XX:MaxPermSize=2048m</argLine>
<systemPropertyVariables>
<user.name>${user.name}</user.name>
</systemPropertyVariables>
</configuration>
</plugin>
I had the same issue and I figured Maven was not using the right jvm. You can check this with
mvn -version
In my case, the jvm specified in my JAVA_HOME and PATH was incorrect: I was using an x86 jdk 6 instead of an x64 jdk 7. Fixing this solved the issue.
I ran into this same issue when I was trying to build the Cloudera Navigator SDK examples. I am using a 32-bit JVM and the compile seemed to go OK but the test afterwards failed with this error:
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
I tried setting MAVEN_OPTS=-Xmx512m but this had no effect- it failed with the same message. Even the value of 2097152KB in the error message was still the same (strange!).
I finally figured out that the heap size value had been hard-coded for the test in the pom.xml file! It had
<argLine>-Xmx2048m ...
</argline>
I edited pom.xml and changed that to -Xmx1024m and then maven was able to build and test everything with no problems.
So the lesson from this is that if you are building something given to you by someone else (such as Cloudera) and you get an error like this, check pom.xml carefully to see if the setting is hard-coded in there.
FYI- I think that using a 64-bit JVM might have also possibly resolved this, but I can't switch to 64-bit. We have some other stuff that we need to get this to work with that says that it only works with a 32-bit JVM (I can't really explain in any more detail than that here).
I think you want to reserve more space than you have, with your settings:
MAVEN_OPTS=-Xmx512m
Try to set it lower, since Maven starts only if it can reserve the whole space.
This problem occurred to me and I could solve it like described.
Try to set variable:
MAVEN_OPTS = -Xmx512m -XX:MaxPermSize=128m
Changing to MAVEN_OPTS = -Xmx512m helped me on a Windows 64 bit.
Try Java 64 bits and configure your java_home to this Java 64.
obs.: javac -version and mvn -version needs return this Java 64.
As Didier L above said
This was exactly what problem I was having, we were running the x86 JVM instead of the 64 bit...
It fixed my issue when I changed to the 64bit JVM.
In IDEA IntelliJ IDE there is a setting on Maven -> Runner to use a specific JVM. The default for me was to use the JRE and not the JDK set on JAVA_HOME. Make sure to check that setting. Once i switched to use JAVA_HOME everything ran fine.
I tried this and its works for me-
maven version -3.2.5
java version -jdk1.7.0_10
-Xmx600m -XX:PermSize=256m

Resources