spring-boot-devtools fails on JAR with missing MANIFEST.MF - java

I have simple Spring Boot application using 1.4.0.M2 which works fine. When I add spring-boot-devtools to the mix the application refuses to start:
Exception in thread "main" java.lang.NullPointerException
at org.springframework.boot.devtools.restart.ChangeableUrls.…
getUrlsFromClassPathAttribute(ChangeableUrls.java:121)
The culprit is javax.inject:javax.inject:1 which does not contain a MANIFEST.MF. Of course one might argue that it’s a faulty JAR, but unfortunately it’s quite a common one. It looks like a bug in Spring Boot to me to react this way.
How can I circumvent this behaviour short of not using javax.inject?

This issue has been fixed on master and will be available in Spring Boot 1.4.0.M3.

Related

Spring application fails to start with ActiveJDBC instrumented classes

I am using Java 8, ActiveJDBC 1.4.13 and Spring Boot 2.0.0.RC1 with Spring 5.
On application startup I am getting this error:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: FooActiveModel.class;
This problem appeared when I upgraded from Spring Boot 2.0.0.M7 to 2.0.0.RC1.
I have found a few references to this error but no mention of ActiveJDBC. In my case classes extended from the activejdbc.Model class (instrumented classes) are causing the problem.
As per answers and suggestions in these...
SPRING4: Failed to read candidate component class CouchbaseConfig.class
Server fails to start, Spring throws BeanDefinitionParsingException
BeanDefinitionStoreException Failed to read candidate component class
ArrayOutOfBoundsException on Bean creation while using Java 8 constructs
I have...
made sure I'm using Java 8
searched for conflicting dependencies
cleaned and rebuilt my project
deleted local maven repo that "might" have been corrupted
re-imported all the dependencies
upgraded all dependencies to their latest version
These options did not help.
Finally managed to solve this problem by excluding the problematic classes(the ones extended from activejdbc.Model that were being instrumented) from the spring component scan.
To make sure that this was actually the reason for the error, I even reverted to my original pom.xml with all my previous dependency versions, re-imported everything, cleaned, rebuilt and sure enough I'm no longer having this issue.
This was an extremely frustrating and time consuming problem, hope it helps somebody.

I am trying to execute spring jdbc program,but at the time running the application getting exceptions

I am trying to execute spring jdbc program,but at the time running the application getting exceptions like
"Exception in thread "main" java.lang.NoSuchMethodError:
org.springframework.core.convert.converter.ConverterRegistry.addConverter(Ljava/lang/Class;Ljava/lang/Class;Lorg/springframework/core/convert/converter/Converter;)V"
How to resolve this issue? I added below jar.
spring-core-3.1.0.RELEASE
spring-core-3.0.3.RELEASE
spring-context-4.1.6.RELEASE
spring.beans-3.1.1
Ensure that all your spring dependencies are the same version. In your case, you are mixing core 3.1.0 and 3.0.3 with context 4.1.6 and beans 3.1.1. Keep them consistent. If you want to use the highest version in your dependencies then make all of them 4.1.6.RELEASE.
Perhaps you should also consider using spring-io-platform to get a managed set of dependencies with versions that will not conflict. This can be found at http://platform.spring.io/platform/

Simple Spring REST service doesn't work

I am trying out Spring Boot to create a simple MongoDB REST service, but for the life of me cannot figure out why it is so resistant to start. I had these dependencies compiling at runtime with Gradle
compile('org.mongodb:bson:3.3.0')
compile 'org.mongodb:mongodb-driver:3.3.0'
compile('org.springframework.boot:spring-boot-starter-data-mongodb')
compile('springframework:spring-web:1.2.6')
And the app was exiting early with some cryptic message:
Closing org.springframework.context.annotation.AnnotationConfigApplicationContext
So then I tried to add some more dependencies to see if that would help...god, I had dependencies:
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-tomcat")
And that resulted in an even more cryptic message:
java.lang.NoSuchMethodError: org.springframework.web.context.support.ServletContextAwareProcessor: method <init>()V not found
I feel like this process is unceccessarily complex to start such a simple service...I have done this with Express, Revel, and Django very simply, but Spring Boot just doesn't seem to make it easy. What am I missing about this process?
Thanks!
Remove
compile('springframework:spring-web:1.2.6')
from your Gradle file. This artifact is ages old. The Spring Boot dependencies bring in all necessary Spring dependencies, so it is usually not necessary, to specify Spring dependencies itself.

Java classloader with same jar

I know that many subject speak about classpath loader and transitive dependancy but i m little confused.
I m working on a legacy application that use spring 2.0.5 and spring-ws and all work fine from the beginning of the project to now.
And recently we are faced to a runtime problem with a an exception like methodnotfoundexception.
In fact we see that spring-ws depend on spring-2.5. So maven transitive dependancy add spring 2.5 in my webinf/lib directory near spring 2.0.5
But i dont understand why all working fine during many years and now why weblogic decide to load spring2.5 before spring2.0.5 and cause this error?
We have correct the problem and now i m looking for same jar with different version and do build failure when i have a conflit to avoid dependancy problem in the future.
But i just want to understand why weblogic decide to load one or another jar ? Because if its alphabetical order, same jar will be loaded all the time, but in my exemple the order change...
So i don t understand clearly whats happened.
Thanks by advance;)
While it is documented that WEB-INF/classes is loaded before WEB-INF/lib, the documentation is not clear in cases like yours - where there are sibling copies of Spring in the WEB-INF/lib.
In Tomcat it is alphabetical, but looks like Websphere, Jboss and Weblogic are random. See https://stackoverflow.com/a/5817890/327426
From some threads on the Oracle forums, the recommendation is to run the Classloader Analysis Tool available at http://docs.oracle.com/cd/E23943_01/web.1111/e13706/classloading.htm#BABHJGJJ for your app and see the results. This tool will identify classloading conflicts.
See similar issue at https://community.oracle.com/thread/2387921?tstart=0
This post from 2009 http://www.coderanch.com/t/472496/BEA-Weblogic/Loading-order-jar-WEB-INF on Weblogic v9.2 states "Checking the logs I see the .jars in WEB-INF/lib are being loaded in reverse alphabetical order". This may or may not be true for your version
Another option is to use Maven to bypass the transitive import being packaged in the WAR

What is an alternative to jetty-maven-plugin?

Is there any workable alternative to jetty-maven-plugin? This particular plugin is not supported properly. I even failed to find its source code repository.
What I need is an embedded container for integration testing.
There is a very similar Tomcat Maven Plugin. Works exactly the same, except... it uses Tomcat. You might also try Maven Cargo plugin that uniforms deploy process to several different containers/servers.
There's an embedded-glassfish plugin that can be used for this.
I often use an embedded jetty server that is started in the #beforeClass part of an junit test. That embedded jetty along with openejb provides most things you need without having to deploy your application anywhere

Categories