I am deploying my application into a Docker container, on Webspehre liberty server as an EAR file.
However, when the application is running, it cannot connect to the Oracle Database which is running on another host where we are trying to connect through jndi lookup defined in server.xml of Websphere liberty.
<dataSource id="oracle" jndiName="jdbc/QADBApp" type="javax.sql.Datasource">
<jdbcDriver libraryRef="OracleJDBCLib"/>
<properties.oracle URL="jdbc:oracle:thin:#//xyz.mycomany.com:1521/prexyz" username="****" password="****" />
We are able to ping the server from inside the container and getting response but at run time, it is not able to establish the db connection.
Note:- Oracle DB is not containerized. We are simply trying to establish the connection through jndi lookup as mentioned above.
Below is the error message. Could anyone help on how to connect Database in this scenario?Thanks in advance !!
[ERROR ] Context initialization failed
Error creating bean with name 'myappFacade': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private transient com.mycompany.myappTool.service.util.HibernateUtil com.mycompany.myappTool.service.facade.myappToolFacade.hibernateUtil; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateUtil' defined in file [/opt/ibm/wlp/usr/servers/defaultServer/apps/expanded/myapp.ear/myappTool.war/WEB-INF/classes/com/mycompany/myappTool/service/util/HibernateUtil.class]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com.mycompany.myappTool.service.util.HibernateUtil (initialization failure)
[ERROR ] SRVE0271E: Uncaught init() exception created by servlet [myapp] in application [myapp]: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myappFacade': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private transient com.mycompany.myappTool.service.util.HibernateUtil com.mycompany.myappTool.service.facade.myappToolFacade.hibernateUtil; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateUtil' defined in file [/opt/ibm/wlp/usr/servers/defaultServer/apps/expanded/myapp.ear/myappTool.war/WEB-INF/classes/com/mycompany/myappTool/service/util/HibernateUtil.class]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com.mycompany.myappTool.service.util.HibernateUtil (initialization failure)
could you try using ip address instead of xyz.mycomany.com:1521 ? It is definitely a network issue ,you might want to go through https://docs.docker.com/engine/userguide/networking/default_network/
Also you can try from inside your container cat /etc/hosts
it should list the ip/machine you want to connect to.
Related
I'm trying to create a Web Service from a WSDL File (Top down Java bean Web Service) by using CXF 3.5.3, but it's not working. After I run it on the Server, this error appears
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/cxf/cxf-extension-soap.xml]
Offending resource: ServletContext resource [/WEB-INF/cxf-beans.xml];
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/cxf/cxf-extension-soap.xml];
nested exception is java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] cannot be opened because it does not exist
After researching on other forums, I deleted these two lines in cxf-beans.xml
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
And replace it with
<import resource="classpath*:META-INF/cxf/cxf-extension-*.xml"/>
After cleaning and running on the Server again, I see a new error appearing in the console
WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nvu3interfacev20': Cannot create inner bean '(inner bean)#b790f3d' of type [fr.band.tcn2021.nvu3.servicev2.Nvu3InterfaceV20Impl] while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [fr.band.tcn2021.nvu3.servicev2.Nvu3InterfaceV20Impl] for bean with name '(inner bean)#b790f3d'; nested exception is java.lang.ClassNotFoundException: fr.band.tcn2021.nvu3.servicev2.Nvu3InterfaceV20Impl
Juli 25, 2022 2:10:15 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERED: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nvu3interfacev20': Cannot create inner bean '(inner bean)#b790f3d' of type [fr.band.tcn2021.nvu3.servicev2.Nvu3InterfaceV20Impl] while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [fr.band.tcn2021.nvu3.servicev2.Nvu3InterfaceV20Impl] for bean with name '(inner bean)#b790f3d'; nested exception is java.lang.ClassNotFoundException: fr.band.tcn2021.nvu3.servicev2.Nvu3InterfaceV20Impl
How can I debug this error and run this Web service on the Server. Hope you can help! Thanks!
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feignEncoder' defined in org.springframework.cloud.openfeign.FeignClientsConfiguration:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [feign.codec.Encoder]: Factory method 'feignEncoder' threw exception; nested exception is
java.lang.NoClassDefFoundError: feign/form/FormEncoder
This happened due to incorrect dependency jars. I deleted my local .m2 folder and build the project again and it is working fine now.
I am upgrading to Grails 3.3.1 from a Grails 2.4 app.
Things seemed to be going slow but OK until I stumbled into this problem when trying to run the app:
Configuring Spring Security Core ...
... finished configuring Spring Security Core
Configuring Spring Security Shiro ...
... finished configuring Spring Security Shiro
2017-12-19 18:51:43.400 ERROR --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'grailsCacheFilter': Cannot create inner bean '(inner bean)#3238926e' of type [grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter] while setting bean property 'filter'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#3238926e': Unsatisfied dependency expressed through method 'setUrlMappingsHandlerMapping' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'urlMappingsHandlerMapping': Unsatisfied dependency expressed through method 'setWebRequestInterceptors' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openSessionInViewInterceptor': Cannot resolve reference to bean 'hibernateDatastore' while setting bean property 'hibernateDatastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError
2017-12-19 18:51:43.492 ERROR --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
grailsCacheFilter
↓
(inner bean)#3238926e
↓
urlMappingsHandlerMapping
↓
openSessionInViewInterceptor
┌─────┐
| hibernateDatastore
└─────┘
Hibernate and Shiro version in the build gradle:
// hibernate
compile "org.grails.plugins:hibernate5:6.0.13"
compile "org.hibernate:hibernate-core:5.1.10.Final"
compile "org.hibernate:hibernate-ehcache:5.1.10.Final"
compile 'org.grails.plugins:spring-security-shiro:3.0.1'
Is this a common error people are running into?
Will I have to go through my dependences one by one to see if one of them is causing this?
The following error I am getting when deploying the application on AWS. This is working fine when the application is deployed on in house tomcat server. The location of path where it is unable to get byte contains file with proper read permisson. I am using grails drools 1.1.1 plugin with tomcat 7 and grails 2.4.4
Any help will be appreciated.
ERROR context.GrailsContextLoaderListener - Error initializing the application: Error creating bean with name 'defaultKieStatelessSession': Cannot resolve reference to bean 'defaultKieBase' while setting bean property 'kBase'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultKieBase': Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to get bytes for: /var/lib/tomcat7/webapps/ROOT/WEB-INF/classes/ScaffoldingGrailsPlugin$_closure2.class
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultKieStatelessSession': Cannot resolve reference to bean 'defaultKieBase' while setting bean property 'kBase'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultKieBase': Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to get bytes for: /var/lib/tomcat7/webapps/ROOT/WEB-INF/classes/ScaffoldingGrailsPlugin$_closure2.class
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultKieBase': Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to get bytes for: /var/lib/tomcat7/webapps/ROOT/WEB-INF/classes/ScaffoldingGrailsPlugin$_closure2.class
... 5 more
Instead of using grails drools plugin, used directly drools package through maven, which took care of this issue.
We've started getting the following exception when deploying to Weblogic:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'alertService': Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailService': Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailMessageBuilderFactory': Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailMessageContentRenderer': Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'groovyPagesTemplateEngine': Cannot resolve reference to bean 'gspTagLibraryLookup' while setting bean property 'tagLibraryLookup'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gspTagLibraryLookup': Invocation of init method failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grails.plugin.springsecurity.SecurityTagLib': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webInvocationPrivilegeEvaluator': Cannot resolve reference to bean 'filterInvocationInterceptor' while setting constructor argument; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterInvocationInterceptor': Invocation of init method failed; nested exception is
java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.arrayFormat(Ljava/lang/String;
[Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;
I've tried removing the slf4j jar from my ear. I've also tried putting the following in my weblogic-appliction.xml:
<prefer-application-packages>
<package-name>org.slf4j.*</package-name>
</prefer-application-packages>
<prefer-application-resources>
<resource-name>org/slf4j/impl/StaticLoggerBinder.class</resource-name>
</prefer-application-resources>
Nothing has worked thus far. Basically, I've tried all of the different things that I've found online. Usually, when I have a conflict with a jar that I'm providing myself and that Weblogic is also providing, just using the prefer-application-packages does the trick.
I'm using Grails 2.3.6 with Weblogic 10.3.6.
In case anyone comes across this issue, this is what my problem ended up being:
What was happening is that we were including the activemq-all artifact for JMS stuff, and this artifact is what they call an "uber" jar. It as a ton of dependencies baked into it that cannot be excluded via maven – one of those dependencies was an old version of slf4j. So, even though I had the "prefer-application-packages" set in Weblogic for slf4j, it wasn't using the Grails provided version, but rather the activemq one. Rather than using the activemq-all dependency, I switched to use individual components from activemq and was able to at that point exclude slf4j. This solved my issue.