Spring 3 MVC - Failed to read candidate component class - spring-mvc

I have a problem to deploy my apps on a weblogic server.
I try to add spring 3 MVC on a "struts 2" project, but when I specified the component-scan I got that error:
<Warning> <HTTP> <wks000fq> <AdminServer> <[ACTIVE] ExecuteThread: '42' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1351179993124> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [zip:D:/Projets/XXX/ZZZ/servers/AdminServer/tmp/_WL_user/YYY/x8a4s2/war/WEB-INF/lib/YYY-pres.jar!/fcdq/epepar/WWW/controleur/cdcais/AbstractActionWebET.class]; nested exception is java.lang.AbstractMethodError: org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:237)
I don't know what to do. I checked the class, I changed it with a empty class and the problem doesn't come from the class.

Related

Incorporating Redis/Spring Session into my application prevents me from deploying the app

I am trying to incorporate SpringSession into my existing (non-Spring boot) application. I have followed Baeldung, which seems to make the most sense:
https://www.baeldung.com/spring-session
Here is my Maven dependencies:
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
Here is the configuration code that I have created:
#Configuration
#EnableRedisHttpSession
public class SessionConfig{
#Bean
public JedisConnectionFactory jedisConnectionFactory() {
JedisConnectionFactory jedisConnectionFactory = new
JedisConnectionFactory();
jedisConnectionFactory.setHostName("localhost");
jedisConnectionFactory.setPort(6379);
jedisConnectionFactory.setDatabase(1);
return jedisConnectionFactory;
}
#Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(jedisConnectionFactory());
return template;
}
}
And here is the Initializer class that extends the HttpSessionInitializer:
public class Initializer extends AbstractHttpSessionApplicationInitializer {
public Initializer() {
super(SessionConfig.class);
}
}
My understanding is that this creates a bean that effectively intercepts sessions and uses Redis to manage them rather that using the Java In Memory session management.
However. I'm unable to deploy the application and am getting the following error in mt catalina logs:
07-Aug-2018 11:13:24.241 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:262)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4751)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5215)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:629)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1839)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
What I derive from this is that the classes that I am now including (possibly in the AbstractHttpSessionApplicationInitializer) are trying to load an application context which is conflicting with the ContextLoaderListener that is already declared in my web.xml. But if I remove that Listener from the web.xml, then that doesn't allow my app to deploy also.
I'm also getting this exception in my tomcat logs, but not sure if it's related:
07-Aug-2018 11:14:57.652 INFO [ektorp-idle-connection-monitor-thread-1] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [org.apache.http.pool.AbstractConnPool$4]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [org.apache.http.pool.AbstractConnPool$4]. 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.checkStateForResourceLoading(WebappClassLoaderBase.java:1311)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1299)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1158)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
at org.apache.http.pool.AbstractConnPool.closeExpired(AbstractConnPool.java:558)
at org.apache.http.impl.conn.PoolingClientConnectionManager.closeExpiredConnections(PoolingClientConnectionManager.java:302)
at org.ektorp.http.IdleConnectionMonitor$CleanupTask.run(IdleConnectionMonitor.java:52)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Is there anything that I am missing that could cause this error?
If you're using web.xml to bootstrap you web app, then you shouldn't be using AbstractHttpSessionApplicationInitializer but rather traditional XML configuration based approach.
You can take a look at Redis HttpSession with XML config guide that's available from Spring Session's reference documentation.
Your Spring config should contain the

Spring Boot exception: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]

I have developed this proof of concept https://github.com/DISID/disid-proofs/tree/master/spring-boot-weblogic to test the deployment of Spring Boot applications in Weblogic 12c (12.2.1).
The application deploys and starts successfully, but when I try to connect to it (i.e. /accounts?number=1234) the error below is shown:
Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it
from fulfilling the request.
And the log file has the exception:
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
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:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:609)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:510)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run
Did I miss something?
Thanks,
I found a workaround putting a dummy dispatcherServlet-servlet.xml file under WEB-INF:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Do not remove this file! -->
</beans>
I've reproduced this issue with WebLogic 12.2.1.0 (plain new install) using spring-boot-sample-war (with an additional weblogic.xml to handle logging). Also tried the latest patchset (WLS PATCH SET UPDATE 12.2.1.0.160419), but the issue remains.
For some reason WebLogic decides it needs to create the DispatcherServlet using it's own configuration as soon as you access the application available on /.
I've put in a service request to Oracle Support and we'll see what they think about this issue.
Update: 'Patch 23124727: CANNOT DEPLOY SPRING BOOT .WAR ON 12.2.1 DUE TO JAVA.IO.FILENOTFOUNDEXCEPTION' is available for Oracle WebLogic Server 12.2.1.0.0 and works with both the spring-boot-sample-war as well as a more advanced application.

Spring Integration gateway error channel - no such bean exception

I've configured a spring integration gateway with a service activator backed by a threadpool.
Everything works fine, till I try to add my own error channel.
Spring begins to complain that it cannot find a bean by the name of the error channel.
Here is my xml config:
<int:gateway service-interface="Messaging.SendMessageToDeviceGateWay"
error-channel="send_message_to_device_error_channel"
default-request-channel="send_message_to_device_channel"
id="send_message_to_device_gateway">
</int:gateway>
<int:channel id="send_message_to_device_channel">
<int:queue message-store="redisMessageStore" />
</int:channel>
<bean id="sendMessageToDeviceServiceBeanId" class="Messaging.SendMessageToDeviceService" />
<int:service-activator input-channel="send_message_to_device_channel"
ref="sendMessageToDeviceServiceBeanId" method="send_message">
<int:poller fixed-rate="500" time-unit="MILLISECONDS"
task-executor="send_message_to_device_task_executor" receive-timeout="0" />
</int:service-activator>
<bean id="sendMessageToDeviceErrorHandlerBeanId"
class="Messaging.SendMessageToDeviceErrorHandler" />
<int:service-activator input-channel = "send_message_to_device_error_channel"
ref="sendMessageToDeviceErrorHandlerBeanId" method="handle_error">
</int:service-activator>
The error I am seeing is :
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'send_message_to_device_gateway': Cannot resolve reference to bean 'send_message_to_device_error_channel' while setting bean property 'errorChannel'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'send_message_to_device_error_channel' is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1469)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1127)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1051)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:949)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
... 24 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'send_message_to_device_error_channel' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:694)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1168)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
... 37 more
Why is it looking for a bean by that name?
Thanks in advance,
Richard.
That's correct: any bean must be presented in the application context.
Even if you use a default errorChannel, it is populated to the application context by the Spring Integration infrastructure.
So, you must provide <channel id="send_message_to_device_error_channel"/> anyway.

Reduce logs generated by SpringMVC application

I have a SpringMVC 3 application which uses Spring Security, AOP, HIbernate etc.
But when I run it in Tomcat or Jetty, it generates a huge amount of log.
How can I reduce this log?
I want a log level starting from WARNING.
Example of the log:
21:16:08.393 [qtp12506312-25] DEBUG o.s.s.w.s.HttpSessionEventPublisher - Publishing event: org.springframework.security.web.session.HttpSessi onCreatedEvent[source=org.eclipse.jetty.server.session.HashedSess ion:db7nzoxke45es1k02gbug79d#6784961]
21:16:08.394 [qtp12506312-25] DEBUG o.s.s.w.s.HttpSessionRequestCache - DefaultSavedRequest added to Session: DefaultSavedRequest[http://xx.xx.xx.xx:8080/favicon.ico]
21:16:08.394 [qtp12506312-25] DEBUG o.s.s.w.a.ExceptionTranslationFilter - Calling Authentication entry point.
21:16:08.440 [qtp12506312-25] DEBUG o.s.s.web.DefaultRedirectStrategy - Redirecting to 'http://xx.xx.xx.xx:8080/default;jsessionid=db7nzoxke45es1k02gbug79d'
21:16:08.441 [qtp12506312-25] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
21:16:08.441 [qtp12506312-25] DEBUG o.s.s.w.c.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
21:16:08.518 [qtp12506312-26] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/default'; against '/loginform.jsp'
21:16:08.518 [qtp12506312-26] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/default'; against '/loginform2.jsp'
21:16:08.518 [qtp12506312-26] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/default'; against '/default'
21:16:08.518 [qtp12506312-26] DEBUG o.s.security.web.FilterChainProxy - /default has an empty filter list
If you are using logback for logging then change the root logger's log lever to WARNING, you can find the logback.xml file in the classpath
Ex:
<root level="WARN">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
If you are using log4j, you can find the log4j.properties file in your classpath. Change the rootlogger level to WARNING again
log4j.rootLogger=WARNING , A1

400 error (Bad Request) creating a Page with Experience Manager

I have an SDL Tridion 2011 SP1 HR1 image in which Experience Manager is installed. I can successfully browse my staging site, log in to ExM and change content and pages. However, when I try to create a new page I get a 400 (Bad Request) error. This is the logged error:
Unable to update the changes using OData Service.
The remote server returned an error: (400) Bad Request.
Component: Tridion.SiteEdit.FastTrackPublishing
Errorcode: 1003
User: NT AUTHORITY\NETWORK SERVICE
StackTrace Information Details:
at System.Net.HttpWebRequest.GetResponse()
at System.Data.Services.Client.DataServiceContext.SaveResult.BatchRequest(Boolean replaceOnUpdate)
at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
at Tridion.SiteEdit.FastTrackPublishing.ServiceImplementation.Preview(IEnumerable1 publishedItemsInfo, TcmUri publishingTargetId)
at Tridion.SiteEdit.FastTrackPublishing.ServiceImplementation.Preview(IEnumerable1 publishedItemsInfo, TcmUri publishingTargetId)
at SyncInvokePreview(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
I've just checked the CD log file and can see this error:
012-10-16 12:29:05,782 ERROR JPADAOFactory - Unable to load JPA DAO with name: TrackedRequest and class: com.tridion.storage.TrackedRequestDAO due too exception in DAO construction
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TrackedRequestDAO' defined in URL [jar:file:/C:/ASP.NET/Preview/httpupload/bin/lib/tracking_core.jar!/com/tridion/storage/TrackedRequestDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.tridion.storage.TrackedRequestDAO]: Constructor threw exception; nested exception is com.tridion.configuration.ConfigurationException: Unexpected dialect encountered: . TrackedRequest item type should be configured to use a supported database.
Inline editing was enabled for the already published content when I received the image but I needed to create the Content Type and Page Type myself. I did this in the usual manner, creating a Page, flagging it as a Page Type, adding the prototype content to it, and configuring the settings for naming and storage (for the created content). I also restarted IIS, shutdown the COM+ package and restarted the Tridion Service Host and Publisher services.
Can anyone explain why I'm getting this error, and how to fix it?
EDIT
So the error suggests it's an issue in the storage config. Here are the relevant sections:
<Storage Id="trackingDB" Class="com.tridion.storage.persistence.JPADAOFactory" Type="persistence" dialect="MSSQL">
<Pool CheckoutTimeout="120" IdleTimeout="120" MonitorInterval="60" Size="5" Type="jdbc"/>
<DataSource Class="com.microsoft.sqlserver.jdbc.SQLServerDataSource">
<Property Name="serverName" Value="SDLPE.pe.local"/>
<Property Name="portNumber" Value="1433"/>
<Property Name="databaseName" Value="tridion_tracking"/>
<Property Name="user" Value="encrypted:u9aIOj9uX2IcL1rI6U5ndA=="/>
<Property Name="password" Value="encrypted:vprUfrnluvIQAVRNSMTx5g=="/>
</DataSource>
</Storage>
And:
<Item cached="true" typeMapping="TrackedRequest" storageId="trackingDB"/>
EDIT
I've just been trawling through the log file and found this:
2012-10-16 14:12:43,148 DEBUG ConfigurationItemTypeLoader - Loaded mapping: trackedrequest to storage: trackingDB
2012-10-16 14:12:43,148 DEBUG ConfigurationItemTypeLoader - Loaded mapping: trackingbatch to storage: trackingDB
2012-10-16 14:12:43,148 DEBUG ConfigurationItemTypeLoader - Loaded mapping: synchronizationrecord to storage: trackingDB
2012-10-16 14:12:43,148 DEBUG ConfigurationItemTypeLoader - Loaded mapping: trackingitem to storage: trackingDB
It seems that the config should be picked up correctly, but still it can't read the dialect propely from the relevant storage definition.
In the end the issue was related to having Page Metadata specified for the Page Type. The errors I was seeing logged don't affect the performance of the website so were misleading me.

Resources