ClassNotFoundException while loading class from extension spring context file

cancel
Showing results for 
Search instead for 
Did you mean: 
brijeshnk
Established Member

ClassNotFoundException while loading class from extension spring context file

Jump to solution

Guys  , 

I created a sample class registered in spring xml file in the folder(tomcat\shared\classes\alfresco\extension)  

packaged a class in a jar file and copied into  folder - tomcat\webapps\alfresco\WEB-INF\lib

When i restarted , i got  following exceptions(ClassNotFoundException) in Tomcat logs , is there any config or settings i need to have for loading the class.

It seems like Spring is unable to load this class from class path or lib directory

followings are log snippets -

2020-02-18 11:24:13,535 INFO [management.subsystems.ChildApplicationContextFactory] [localhost-startStop-1] Startup of 'Authentication' subsystem, ID: [Authentication, managed, alfrescoNtlm1] complete
2020-02-18 11:24:17,170 INFO [management.subsystems.ChildApplicationContextFactory] [localhost-startStop-1] Starting 'sysAdmin' subsystem, ID: [sysAdmin, default]
2020-02-18 11:24:17,203 INFO [management.subsystems.ChildApplicationContextFactory] [localhost-startStop-1] Startup of 'sysAdmin' subsystem, ID: [sysAdmin, default] complete
2020-02-18 11:24:18,057 WARN [context.support.XmlWebApplicationContext] [localhost-startStop-1] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.tutorialspoint.HelloWorld] for bean with name 'helloWorld' defined in file [C:\alfresco-content-services\tomcat\shared\classes\alfresco\extension\move-monthily-data-context.xml]; nested exception is java.lang.ClassNotFoundException: com.tutorialspoint.HelloWorld
2020-02-18 11:24:18,103 WARN [factory.support.DisposableBeanAdapter] [localhost-startStop-1] Invocation of destroy method failed on bean with name 'serverConnector': java.lang.NullPointerException
2020-02-18 11:24:19,176 INFO [management.subsystems.ChildApplicationContextFactory] [localhost-startStop-1] Stopping 'Authentication' subsystem, ID: [Authentication, managed, alfrescoNtlm1]
2020-02-18 11:24:19,177 INFO [management.subsystems.ChildApplicationContextFactory] [localhost-startStop-1] Stopped 'Authentication' subsystem, ID: [Authentication, managed, alfrescoNtlm1]
2020-02-18 11:24:19,177 INFO [management.subsystems.ChildApplicationContextFactory] [localhost-startStop-1] Stopping 'sysAdmin' subsystem, ID: [sysAdmin, default]
2020-02-18 11:24:19,178 INFO [management.subsystems.ChildApplicationContextFactory] [localhost-startStop-1] Stopped 'sysAdmin' subsystem, ID: [sysAdmin, default]
2020-02-18 11:24:19,190 ERROR [web.context.ContextLoader] [localhost-startStop-1] Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.tutorialspoint.HelloWorld] for bean with name 'helloWorld' defined in file [C:\alfresco-content-services\tomcat\shared\classes\alfresco\extension\move-monthily-data-context.xml]; nested exception is java.lang.ClassNotFoundException: com.tutorialspoint.HelloWorld
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1347)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:913)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:617)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:938)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:70)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5110)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5633)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:712)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.tutorialspoint.HelloWorld
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:265)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:419)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1299)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1270)

 

 

2 Solutions

Accepted Solutions
angelborroy
Alfresco Employee

Re: ClassNotFoundException while loading class from extension spring context file

Jump to solution

That should be working. Is that class included in the JAR copied to alfresco/WEB-INF/lib folder?

Hyland Developer Evangelist

View solution in original post

brijeshnk
Established Member

Re: ClassNotFoundException while loading class from extension spring context file

Jump to solution

thanks for the reponse I have resolved it

I was doing something wrong while creating jar file . Class files were not packaged in jar along with package structure.

View solution in original post

3 Replies
angelborroy
Alfresco Employee

Re: ClassNotFoundException while loading class from extension spring context file

Jump to solution

That should be working. Is that class included in the JAR copied to alfresco/WEB-INF/lib folder?

Hyland Developer Evangelist
brijeshnk
Established Member

Re: ClassNotFoundException while loading class from extension spring context file

Jump to solution

thanks for the reponse I have resolved it

I was doing something wrong while creating jar file . Class files were not packaged in jar along with package structure.

EddieMay
Alfresco Employee

Re: ClassNotFoundException while loading class from extension spring context file

Jump to solution

Hi @brijeshnk,

Thanks for reporting back - it's helpful to other users. 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!