Issues with CATALINA_OPTS in tomcat 7 - tomcat7

I am trying to set a couple of properties in my catalina.bat file.
set "CATALINA_OPTS=-Denvironment.properties.location=D:\Office\IR\irEnvironmentProperties\environment.properties"
CATALINA_OPTS="%CATALINA_OPTS% -Dappconfig.dir=D:\Office\IR\IR\appconfig -Dappconfig.farm=dev -Dir.log.dir=D:\Office\IR\irlogs -Denvironment.properties.location=D:\Office\IR\irEnvironmentProperties\environment.properties"
rem set appconfig.dir=D:\Office\IR\IR\appconfig
rem set appconfig.farm=dev
rem set ir.log.dir=D:\Office\IR\irlogs
Above are all combinations I tried but I am not able to shake off the problem that environment.properties file not found.
On first line I also tried removing the surrounding double quotes.
The directory paths are correct I can access the correct dir by simply pasting the path on browser or windows run prompt.
What is the correct way to set CATALINA_OPTS in tomcat? Please point me to some beginner tutorial on this, if possible.
###EDIT###
I have tomcat in standalone mode(downloaded a zip file, NO windows installer).
Stack trace:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'envPropertiesLoader' defined in class path resource [application-context.xml]: Cannot create inner bean 'util:properties#4589632c' of type [org.springframework.beans.factory.config.PropertiesFactoryBean] while setting bean property 'arguments'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'util:properties#4589632c': Invocation of init method failed; nested exception is java.io.FileNotFoundException: "D:\Office\IR\irEnvironmentProperties\environment.properties" (The filename, directory name, or volume label syntax is incorrect)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:649)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
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:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'util:properties#4589632c': Invocation of init method failed; nested exception is java.io.FileNotFoundException: "D:\Office\IR\irEnvironmentProperties\environment.properties" (The filename, directory name, or volume label syntax is incorrect)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
... 29 more
Caused by: java.io.FileNotFoundException: "D:\Office\IR\irEnvironmentProperties\environment.properties" (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:125)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.beans.factory.config.PropertiesFactoryBean.createInstance(PropertiesFactoryBean.java:113)
at org.springframework.beans.factory.config.PropertiesFactoryBean.createProperties(PropertiesFactoryBean.java:98)
at org.springframework.beans.factory.config.PropertiesFactoryBean.afterPropertiesSet(PropertiesFactoryBean.java:69)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 32 more

From where are you setting these variables...
I think the first option set (with double quotes) shall work...
Try adding this variable to setenv.bat file in \bin\setenv.bat file...
Alternately, you could specify this in startup.bat as well (If you are using this script for managing tomcat

The recommended place to set environment variables such as CATALINA_OPTS is bin/setenv.bat file, as documented in RUNNING.txt.
For many system properties it is possible to set then in conf/catalina.properties file. All properties listed there are read and passed to System.setProperty() at Tomcat bootstrap time.
Disclaimer: While it is convenient to use catalina.properties, the recommended way is to use -D in CATALINA_OPTS and JAVA_OPTS.
You may try running with a debugger,
https://wiki.apache.org/tomcat/FAQ/Developing#Debugging
It is odd that the error message is about invalid syntax, not about non-existing path. Is it possible to reproduce this message with a simple sample java program? Does a non-existent path produce a different error message?
Maybe you will succeed if you use straight slash '/' instead of backslash. Looking at the stacktrace, some API there is using URLs (FileURLConnection). It may be that straight slashes will work better.
It may be that the message is actually provided by underlying OS, not by Java code. If such, it may be a fixed message that the OS provides as explanation to a numeric error code. If that is the case, its text may be trying hard to cover all cases when some specific numeric error code is used. (Just guessing)

Related

How to use aws docker image into spring boot project

I have a spring boot project working on docker perfectly, now i added some functionalities to my project for upload and remove files to s3, and locally it works very well because i've installed the AWS SDK for java on my computer. Now i want to create a docker image of my project, but when i run it i get this exception:
2018-08-20 15:21:43.129 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tinmueblesResource' defined in URL [jar:file:/home/jhipster/app.war!/WEB-INF/classes!/com/divergente/administrador/inmuebles/web/rest/TinmueblesResource.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amazonClient': Invocation of init method failed; nested exception is com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
2018-08-20 15:21:43.234 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tinmueblesResource' defined in URL [jar:file:/home/jhipster/app.war!/WEB-INF/classes!/com/divergente/administrador/inmuebles/web/rest/TinmueblesResource.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amazonClient': Invocation of init method failed; nested exception is com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1276)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1133)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at com.divergente.administrador.inmuebles.AdministradorInmueblesApp.main(AdministradorInmueblesApp.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amazonClient': Invocation of init method failed; nested exception is com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:138)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:424)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1700)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724)
... 25 common frames omitted
Caused by: com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
at com.amazonaws.client.builder.AwsClientBuilder.setRegion(AwsClientBuilder.java:386)
at com.amazonaws.client.builder.AwsClientBuilder.configureMutableProperties(AwsClientBuilder.java:352)
at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
at com.divergente.administrador.inmuebles.service.AmazonClient.initializeAmazon(AmazonClient.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:308)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135)
... 38 common frames omitted
Looks like docker don't recognize the AWS credentials, and i decided to download a docker container with the AWS CLI installed:
https://hub.docker.com/r/garland/aws-cli-docker/
I ran this container on docker and i configured the credentials and works good, now i want to integrate all these pieces into my Dockerfile but i don't know where i have to configure the use of this new container to upload and remove files to S3.
In my project i have configured the AWS dependencies.
This is my Dockerfile:
FROM openjdk:8-jre-alpine
ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
JHIPSTER_SLEEP=0 \
JAVA_OPTS=""
# Add a jhipster user to run our application so that it doesn't need to run as root
RUN adduser -D -s /bin/sh jhipster
WORKDIR /home/jhipster
ADD entrypoint.sh entrypoint.sh
RUN chmod 755 entrypoint.sh && chown jhipster:jhipster entrypoint.sh
USER jhipster
ADD *.war app.war
ENTRYPOINT ["./entrypoint.sh"]
EXPOSE 2020
The application runs fine locally but fails in a container, probably because your local machine is authenticated to AWS with a set of credentials: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. You might have the key values in ~/.aws/credentials file listed like that:
[default]
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
You can pass these values to the container as environmental variables, which will allow AWS SDK to use them while accessing S3. Example of Docker command:
docker run -e "AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE" -e "AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" my-image:latest

what could be possible reasons for integrationMBeanExporter ... javax.management.InstanceAlreadyExistsException

I have chose to implement my jobs using Spring Batch Admin and, unfortunately, it works perfectly in all environment except the production. I guess there is another application from another team causing some indirect effect but I can't stop them in order to check which one is affecting and if there is really some application affect.
I am desparetely looking for possible causes and I can't find. Any imagine reason would be a start point appreciatted.
The entire error is:
Trace: 2016/09/09 22:49:17.049 02 t=9BDE88 c=UNK key=P8 tag= (13007004)
SourceId: com.ibm.ws.webcontainer.webapp.WebApp.logServletError
ExtendedMessage: BBOO0220E: SRVE0293E: ÝServlet Error¨-ÝBatch Servlet¨: org.springframework.beans.factory.BeanCreationException: E
rror creating bean with name 'mbeanExporter': Invocation of init method failed; nested exception is org.springframework.jmx.export.U
nableToRegisterMBeanException: Unable to register MBean Ýorg.springframework.integration.monitor.IntegrationMBeanExporter#4ed60bcf¨
with key 'integrationMBeanExporter'; nested exception is javax.management.InstanceAlreadyExistsException: spring.application:cell=dt
l85cel,name=integrationMBeanExporter,type=IntegrationMBeanExporter,node=wlemyAppa,process=WLEmyApp
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.j
ava:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.jav
a:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:
475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:70
3)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:7
60)
...
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanSe
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:814)
at com.ibm.ws390.management.connector.corba.CorbaConnectorImpl.invoke(CorbaCon
at com.ibm.ws390.management.connector.corba._CorbaConnectorImplBase._invoke(_C
at com.ibm.ws390.orb.CommonBridge.invoke(CommonBridge.java:1898)
at com.ibm.ws390.orb.CommonBridge.getAndProcessWork(CommonBridge.java:725)
at com.ibm.ws390.orb.CommonBridge.runApplicationThread(CommonBridge.java:614)
at com.ibm.ws390.management.connector.corba.CorbaConnectorImpl.invoke(CorbaCon
at com.ibm.ws390.management.connector.corba._CorbaConnectorImplBase._invoke(_C
at com.ibm.ws390.orb.CommonBridge.invoke(CommonBridge.java:1898)
at com.ibm.ws390.orb.CommonBridge.getAndProcessWork(CommonBridge.java:725)
at com.ibm.ws390.orb.CommonBridge.runApplicationThread(CommonBridge.java:614)
at com.ibm.ws.util.ThreadPool$ZOSWorker.run(ThreadPool.java:2116)
Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean Ýorg.springframework.integration.
monitor.IntegrationMBeanExporter#4ed60bcf¨ with key 'integrationMBeanExporter';nested exception is javax.management.InstanceAlready
ExistsException: spring.application:cell=mycel,name=integrationMBeanExporter,type=IntegrationMBeanExporter,node=wlemyAppa,process
Is there any way to turn off in Spring Batch Admin such duplicated Bean? How can I try IGNORE_EXISTING or REPLACE_EXISTING just to see if it fix my problem?

Spring config location file not found exception

In my web app i'm trying to use spring security. I have the following project structure:
In my web.xml i set the configLocations like this:
And in my HibernateUtil, i create the ClassPathXmlApplicationContext like this:
But, when i execute the app, i get the following errors:
GRAVE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [resources/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [resources/applicationContext.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:527)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:441)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.io.FileNotFoundException: class path resource [resources/applicationContext.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 20 more
What might be wrong?
See maven war plugin.
Check your target folder actually contains the files.
https://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
The error is clearly telling you that it cannot find resources/applicationContext.xml in your classpath.
Looking at your code organization, I think the problem is that your Spring applicaitonContext.xml file is directly under WEB-INF and in a typical web-application, this is NOT in the classpath. You would be better off creating a WEB-INF/classes/ folder and putting your applicationContext.xml file in there.
Since the error is complaining about resources/appliationContext.xml you may also need to create a WEB-INF/classes/resources/ folder and put it in there.

Axis client jar is was 6.1 shared app

I've created an axis client for a web service. I exported as a jar and included in in the shared/app folder so that it is available to all portlet apps to use. The problem is that when my portlet projects try to init the client I get the following exception:
ERROR [org.springframework.web.portlet.DispatcherPortlet] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'portalStatisticsTransactionDelegateProxy' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.uig.portal.ws.statistics.service.PortalStatisticsTransactionDelegateProxy]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.apache.axis.client.AxisClient (initialization failure)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at com.ibm.ws.wswebcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:653)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:370)
at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:293)
at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:93)
at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:162)
at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:673)
at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:626)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:335)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:551)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1274)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1138)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:569)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:817)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:921)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2124)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:342)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.uig.portal.ws.statistics.service.PortalStatisticsTransactionDelegateProxy]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.apache.axis.client.AxisClient (initialization failure)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
... 30 more
Caused by: java.lang.NoClassDefFoundError: org.apache.axis.client.AxisClient (initialization failure)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:134)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.<init>(Service.java:113)
at com.uig.portal.ws.statistics.service.PortalStatisticsTransactionServiceLocator.<init>(PortalStatisticsTransactionServiceLocator.java:12)
at com.uig.portal.ws.statistics.service.PortalStatisticsTransactionDelegateProxy._initPortalStatisticsTransactionDelegateProxy(PortalStatisticsTransactionDelegateProxy.java:18)
at com.uig.portal.ws.statistics.service.PortalStatisticsTransactionDelegateProxy.<init>(PortalStatisticsTransactionDelegateProxy.java:8)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:522)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
... 32 more
Any ideas? I tried referencing the axis jars from my portlet project, but that didn't work.
I think that your client jar interferes with standard websphere libraries. It leads to a situation where two different versions of the same class exist on the server classloader hierarchy. Your application classs loader probably picks the wrong version.
I would suggest to remove the jar from shared/app and configure a shared library instead. Then you associate the shared library with your application. You can find more details in was infocenter.

Spring 3 and MyBatis 3.0.4 / 3.0.6: MalformedParameterizedTypeException

I am trying to use Spring 3.0.5.RELEASE together with MyBatis in a Maven environment. I added the mybatis-spring dependency. This turned out not to work due to a MalformedParameterizedTypeException (a detailed stacktrace is included below).
Stacktrace:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:60)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:53)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:104)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.visitor.Reifier.visitArrayTypeSignature(Reifier.java:159)
at sun.reflect.generics.tree.ArrayTypeSignature.accept(ArrayTypeSignature.java:42)
at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94)
at java.lang.reflect.Method.getGenericParameterTypes(Method.java:300)
at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:385)
at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:116)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:74)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:58)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1196)
at java.beans.Introspector.getBeanInfo(Introspector.java:423)
at java.beans.Introspector.getBeanInfo(Introspector.java:189)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:224)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:149)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:305)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:335)
at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1327)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 19 more
There are quite some posts concerning this iusse, yet most of them refer to the problem as being caused by having some Spring 2 dependency somewhere in the class-path which was not the case for me:
http://mybatis-user.963551.n3.nabble.com/mybatis-integration-with-Spring-2-5-not-working-td2499805.html
http://groups.google.com/group/mybatis-user/browse_thread/thread/42698cff74504603
The first link mentions an imcompatability to Spring 2 because of the BeanFactory being paramterized in Spring 3 but not in Spring 2. Well, it turns out that the real problem was, that I had a separate MyBatis version (3.0.4) in my dependencies. I changed version 3.0.4 to version 3.0.6 and everything worked just fine. Usually, if one does not have a separate MyBatis dependency somewhere in the project (or parent projects!), the mybatis-spring artifact from Maven comes with MyBatis 3.0.6.
Side note: I had some other issues with the Maven dependency management system I was using because the changed pom.xml dependency would not propagate through to the top-level projects. Obviously after running a mvn clean install -Dmaven.text.skip=true dependencies got propagated to the top level projects and everything was working.

Resources