How to fix "Error creating bean with name" - java

My website is/was working just fine. But I am being forced to upgrade the OS of the servers it runs on, because the newer version of a piece of software I need to upgrade, won't run on the old OS. So, now I am in dependency hell.
So, on a test server, I've upgraded the OS from Ubuntu 14.04 to 18.04.1 . I was also forced to use a later version of Java from:
echo $JAVA_HOME
/usr/lib/jvm/java-7-oracle
to
echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64/
And the version of Tomcat from 7 to 8.
Having fiddled a bit (I started this in January, but have only just been able to get back to it, so I can't remember what exactly, though can search the history for clues if required), I can build my application OK, but it fails at the final hurdle:
BUILD SUCCESSFUL Total time: 19 seconds Using CATALINA_BASE:
/var/lib/tomcat8 Using CATALINA_HOME: /usr/share/tomcat8 Using
CATALINA_TMPDIR: /var/lib/tomcat8/temp Using JRE_HOME:
/usr/lib/jvm/java-11-openjdk-amd64/ Using CLASSPATH:
/usr/share/tomcat8/bin/bootstrap.jar:/usr/share/tomcat8/bin/tomcat-juli.jar
Using CATALINA_PID: /root/catalina.pid Tomcat started.
--2019-05-28 16:10:16-- http://localhost:8080/ Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost
(localhost)|127.0.0.1|:8080... connected. HTTP request sent, awaiting
response... 404 2019-05-28 16:10:16 ERROR 404: (no description).
Further investigation reveals:
less /var/log/tomcat8/catalina.out
2019-05-28 16:10:06.418 UTC [localhost-startStop-1] ERROR
org.springframework.web.context.ContextLoader - Context initialization
failed org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'embedController' defined in ServletContext
resource [/WEB-INF/playground-servlet.xml]: Cannot resolve reference
to bean 'homeController' while settin g bean property
'homeController'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'homeController' defined in ServletContext
resource [/WEB-INF/playground-servlet.xml]: Cannot re solve reference
to bean 'execService' while setting bean property 'execService';
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'execService': Invocation of init method
failed; nested exception is javax.ws.rs.ProcessingException:
java.net.ConnectException: Connection refused (Connection refused)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE]
It should be abundantly clear by now that I don't have much clue what I'm doing. I have spent the afternoon doing lots of googling and looking at lots of Stack Overflow answers, but nothing seems relevant.

that error comes from Spring. For Java 11 support, you'd also need to upgrade Spring to the latest 5.x version (currently 5.2.x).
You may encounter various compatibility issues when upgrading an older environment to Java 11. Unless you absolutely need to upgrade, you may consider staying on a previous version. Java 8 is still being supported.

Related

How to debug java.lang.ClassNotFoundException during Tomcat startup?

When Tomcat loads my war, I get this error:
Exception in thread "ClientMessageReceptor0" java.lang.NoClassDefFoundError: java/net/Inet6Address
at org.jacorb.orb.iiop.IIOPAddress.getNetworkInetAddresses(IIOPAddress.java:675)
at org.jacorb.orb.iiop.IIOPAddress.getLocalHost(IIOPAddress.java:591)
at org.jacorb.orb.iiop.IIOPAddress.getLocalHostAddress(IIOPAddress.java:574)
at org.jacorb.orb.listener.SSLListenerUtil.processException(SSLListenerUtil.java:73)
at org.jacorb.orb.iiop.IIOPConnection.handleCommFailure(IIOPConnection.java:77)
at org.jacorb.orb.etf.StreamConnectionBase.read(StreamConnectionBase.java:139)
at org.jacorb.orb.giop.GIOPConnection.getMessage(GIOPConnection.java:389)
at org.jacorb.orb.giop.GIOPConnection.receiveMessagesLoop(GIOPConnection.java:541)
at org.jacorb.orb.giop.GIOPConnection.receiveMessages(GIOPConnection.java:533)
at org.jacorb.orb.giop.MessageReceptor.doWork(MessageReceptor.java:69)
at org.jacorb.util.threadpool.ConsumerTie.run(ConsumerTie.java:60)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: Illegal access: this web application instance has been stopped already. Could not load [java.net.Inet6Address]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1375)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1226)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
Our application uses Tomcat v9.0.41 and JDK 1.8.0_111 . This same combination works for others in my team and also it worked for me sometime back. I'm not sure what changed now. I have looked at other similar posts and they suggest mismatch between Tomcat and JDK version. But above combination of Tomcat and JDK works for others.
I have removed all other JDK and JRE version on my system.
Ensured JAVA_HOME points to JDK 1.8.0_111 and PATH points to correct JRE.
Any pointers on how to debug this further? Can I turn on some logging during Tomcat startup to see what paths are being used by Tomcat? Any suggestions are highly appreciated :).

How to solve java error on Geoserver GSR extension

I have set up a Geoserver instance. Now I need the GSR extension to have an ArcGIS compatible REST API.
I installed the extension as described but on Geoserver startup I get a couple of errors and when I access the webpage a HTTP error 503.
I already tried different versions of Geoserver and JDK, all with the same result.
Here is the Java error:
11:52:17.791 [main] ERROR
org.springframework.web.context.ContextLoader - Context initialization
failed org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'gsrDispatcher' defined in URL
[jar:file:/home/nico/gs/webapps/geoserver/WEB-INF/lib/gs-gsr-2.21-SNAPSHOT.jar!/applicationContext.xml]:
Initialization of bean failed; nested exception is
javax.xml.stream.FactoryConfigurationError: Provider for
javax.xml.stream.XMLOutputFactory cannot be found
Thanks for any hint,
best regards
Nico
I did some more research and tested the following versions each with both openjdk version ("1.8.0_312" & "11.0.14.1"):
geoserver-2.18-SNAPSHOT-gsr-plugin.zip
Geoserver version:
2.18.2-6
Running without problems
geoserver-2.19-SNAPSHOT-gsr-plugin.zip
Geoserver version:
2.19.0-5
Problem: Error creating bean with name 'geoServicesExceptionResolver'
geoserver-2.19-SNAPSHOT-gsr-plugin.zip
Geoserver version:
2.19.6
Problem: Error creating bean with name 'gsrDispatcher'
geoserver-2.20-SNAPSHOT-gsr-plugin.zip
Geoserver version:
2.20.0-4
Problem: Error creating bean with name 'gsrDispatcher'
geoserver-2.21-SNAPSHOT-gsr-plugin.zip
Geoserver version:
2.21
Problem: Error creating bean with name 'gsrDispatcher'
So it seems something happened between geoserver version 2.18.6 and 2.19.0 and something more happened between version 2.19.5 and 2.19.6.
It would be helpful if someone could give me the contact of the community GSR extenstion. I can not find anything about it.
To get my geoserver updated it would be great to have this fixed soon.
Many thanks in advance.
Make sure you're installing the same plugin version for the same GeoServer version you're having.
I think you have did something wrong in applicationContext.xml file.

Heroku deploy fails

I'm using Play framework with Java 1.7.
Last time deploy:
-----> Play! app detected
-----> Installing OpenJDK 1.7... done
-----> Building Play! application...
This time deploy:
-----> Play! app detected
/app/tmp/buildpacks/85dfc1d8f48aec0b42f03a59461dc516a918eb099c9e908767a7f42ddf326e12e48c6030ff4891e5c63f08e3b760ea09dee5bbfa4ca293b152d266406bfa29b3/bin/compile:
line 31: detect_java_version: command not found
-----> Installing OpenJDK .../app/tmp/buildpacks/85dfc1d8f48aec0b42f03a59461dc516a918eb099c9e908767a7f42ddf326e12e48c6030ff4891e5c63f08e3b760ea09dee5bbfa4ca293b152d266406bfa29b3/bin/compile:
line 34: jdk_overlay: command not found
-----> Building Play! application...
So after error log
OpenJDK 64-Bit Server VM warning: ignoring option UseSplitVerifier;
support was removed in 8.0
CompilerOracle: exclude jregex/Pretokenizer.next
Listening for transport dt_socket at address: 8000
08:52:08,455 INFO ~ Starting /tmp/build_bedf10ee7c8222565973235fe2454700
08:52:10,049 INFO ~ Precompiling ...
08:53:02,606 ERROR ~
#7e83895fc
Cannot start in PROD mode with errors
Oops: UnexpectedException
An unexpected error occured caused by exception UnexpectedException: While applying class
play.classloading.enhancers.LocalvariablesNamesEnhancer on
controllers.Application
play.exceptions.UnexpectedException: While applying play.CorePlugin#aecb35a on controllers.Application
at play.plugins.PluginCollection.enhance(PluginCollection.java:556)
at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:235)
at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:167)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:431)
at play.Play.preCompile(Play.java:600)
at play.Play.init(Play.java:304)
at play.server.Server.main(Server.java:162)
Caused by: play.exceptions.UnexpectedException: While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer
on controllers.Application
at play.CorePlugin.enhance(CorePlugin.java:302)
at play.plugins.PluginCollection.enhance(PluginCollection.java:551)
... 6 more
Caused by: java.lang.RuntimeException: java.io.IOException: invalid constant type: 18
at javassist.CtClassType.getClassFile2(CtClassType.java:203)
at javassist.CtClassType.subtypeOf(CtClassType.java:303)
at javassist.bytecode.stackmap.TypeData$TypeName.update(TypeData.java:274)
at javassist.bytecode.stackmap.TypeData$TypeName.setType(TypeData.java:203)
at javassist.bytecode.stackmap.TypeData.setType(TypeData.java:46)
at javassist.bytecode.stackmap.Tracer.doInvokeIntfMethod(Tracer.java:828)
at ja
-----> Play! app detected
How to fix it?
First of all, please note that Heroku no longer supports Play 1.x. If you can, please consider upgrading your application to Play 2.x, which is still supported.
However, the issue you describe has now been fixed. A dependency of the now deprecated Play 1.x buildpack broke backwards compatibility. Redeploying your application should work without any work from your side.

IntelliJ: SpringBoot-gradle application fails with "Could not open ServletContext resource"

A spring boot application (uses gradle) setup in IntelliJ starts up properly with no exceptions. However, on hitting it with requests via browser/postman throws Internal Server Error.
The application works perfect when started from commandline via
./gradlew bootRun
The exception stack trace says:
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
I suspect something is not right (on classpath) when the application is started from inside IntelliJ - 14.
Any pointers are appreciated.

How can I changed tomcat app server to version 8 with jdk 1.7 and spring 3.0.4?

My project used tomcat 7 ,jdk 1.6 and spring 3.0.4. I changed tomcat version to 8, jdk to 1.7. It works perfectly in Luna IDE with tomcat installer.(Of course I changed servlet.jar to javax.servlet-api-3.1.0.jar because of an error)
My project is running perfectly with the tomcat8 (binary version) for windows, but the war file is not running with tomcat 8 (linux binary version) at linux server and its error is:
Jun 14, 2015 5:32:47 PM org.apache.catalina.core.StandardContext
listenerStart SEVERE: Exception sending context initialized event to
listener instance of class utils.SysParams
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Failed to import bean definitions from relative
location [hibernate-beans.xml] Offending resource: ServletContext
resource [/WEB-INF/applicationContext.xml]; nested exception is
org.springframework.beans.factory.BeanDefinitionStoreException:
Unexpected exception parsing XML document from ServletContext resource
[/WEB-INF/hibernate-beans.xml]; nested exception is
java.lang.NoSuchMethodError:
org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;
Its a Spring 3.0 method which should work in your case as it works on localhost. I guess your linux tomcat has pre-3.0 Spring versions somewhere in classpath- which could be from this project or legacy project. On linux tomcat check your classpath, search for spring 2* jars and try deleting work/temp folders..

Categories

Resources