Import Custom DAO Jar Class File Not Found Exception - dao

I developed a DAO war project using Spring JDBC template which has applicationContext.xml in it and export as jar. Then, I had created another jar project which import the DAO jar but it throw below stack trace.
Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.breeze.bis.dao.service.jdbcTemplate] for bean with name 'genericDaoImpl' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.breeze.bis.dao.service.jdbcTemplate
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1263)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:581)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1332)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:898)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:588)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.breeze.dao.Main.main(Main.java:28)
Caused by: java.lang.ClassNotFoundException: com.breeze.bis.dao.service.jdbcTemplate
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:415)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1284)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1255)
... 9 more
The DAO jar is import as library, required project in build path and order and export tab in eclipse but how come URLClassLoader not able to load the class since the jar consists of the mention class.
Please help.
Thanks.

Thread closed because of wrong class name in applicationContext.xml

Related

Grails ClassNotFoundException only in one subproject

I'm pulling my hair over this crazy problem that doesn't make any sense to me. I have a large Grails 4 project with multiple sub-projects. In two of these subprojects, let's call them A and B, I have a dependency to a plugin (non-public plugin): implementation group: 'dokumentlager', name: 'dokumentlager-grails4-plugin', version: "5.4.1".
This dependency has two transitive dependencies, as seen in the External Libraries list in IntelliJ:
In sub-project B a class from "dokumentlager-api" is used in a Service and imported like so:
import dokumentlager.api.Indholdstype
This gives no errors and I can start B normally.
However, in sub-project A I also import the same class and use in a Service, but there I get a ClassNotFoundException:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplicationPostProcessor' defined in dk.erst.plandata.integration.Application: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [grails.boot.config.GrailsApplicationPostProcessor]: Factory method 'grailsApplicationPostProcessor' threw exception; nested exception is org.grails.core.exceptions.GrailsRuntimeException: Failed to introspect class: class dk.erst.plandata.integration.faelleskomponenter.DokumentlagerPluginService
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1341)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1181)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:119)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at grails.boot.GrailsApp.run(GrailsApp.groovy:99)
at grails.boot.GrailsApp.run(GrailsApp.groovy:485)
at grails.boot.GrailsApp.run(GrailsApp.groovy:472)
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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:149)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:89)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:135)
at dk.erst.plandata.integration.Application.main(Application.groovy:11)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [grails.boot.config.GrailsApplicationPostProcessor]: Factory method 'grailsApplicationPostProcessor' threw exception; nested exception is org.grails.core.exceptions.GrailsRuntimeException: Failed to introspect class: class dk.erst.plandata.integration.faelleskomponenter.DokumentlagerPluginService
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:652)
... 30 common frames omitted
Caused by: org.grails.core.exceptions.GrailsRuntimeException: Failed to introspect class: class dk.erst.plandata.integration.faelleskomponenter.DokumentlagerPluginService
at grails.core.ArtefactHandlerAdapter.isArtefact(ArtefactHandlerAdapter.java:129)
at grails.core.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:774)
at grails.boot.config.GrailsApplicationPostProcessor.performGrailsInitializationSequence(GrailsApplicationPostProcessor.groovy:112)
at grails.boot.config.GrailsApplicationPostProcessor.initializeGrailsApplication(GrailsApplicationPostProcessor.groovy:94)
at grails.boot.config.GrailsApplicationPostProcessor.setApplicationContext(GrailsApplicationPostProcessor.groovy:231)
at grails.boot.config.GrailsApplicationPostProcessor.<init>(GrailsApplicationPostProcessor.groovy:78)
at grails.boot.config.GrailsAutoConfiguration.grailsApplicationPostProcessor(GrailsAutoConfiguration.groovy:70)
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.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 31 common frames omitted
Caused by: java.lang.NoClassDefFoundError: dokumentlager/api/Indholdstype
at dk.erst.plandata.integration.faelleskomponenter.DokumentlagerPluginService.<clinit>(DokumentlagerPluginService.groovy:23)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:67)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:64)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:64)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:161)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:94)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
at grails.plugins.quartz.JobArtefactHandler.isArtefactClass(JobArtefactHandler.groovy:62)
at grails.core.ArtefactHandlerAdapter.isArtefact(ArtefactHandlerAdapter.java:125)
... 42 common frames omitted
Caused by: java.lang.ClassNotFoundException: dokumentlager.api.Indholdstype
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 55 common frames omitted
So far, I've tried:
Adding "dokumentlager-api" as an explicit dependency
Invalidated caches in IntelliJ
Manually deleted all caches in .gradle/
Re-cloned my repository
Reinstalled IntelliJ
How is it possible that with the same setup this gives me an error in project A but not in project B?! I should add that we have another developer that CAN start A locally... so it seems to be a very local issue...
PS: I'm using gradle 5.2
EDIT
I ran a build scan for my two sub-projects and they have the exact same dependencies in borth compileClasspath and runtimeClasspath:

LogFactory ClassNotFoundException with Google AutoValue and spring-context-support

A Spring boot project depends on auto-value 1.1 and spring-context-support 4.2.1. When I run it with mvn spring-boot:run, I see the following error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'velocityConfigurer' defined in class path resource [org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration$VelocityWebConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: autovalue/shaded/org/apache/commons/logging/LogFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
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.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
at com.example.SampleApplication.main(SampleApplication.java:10)
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:483)
at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: autovalue/shaded/org/apache/commons/logging/LogFactory
at org.apache.velocity.runtime.log.CommonsLogLogChute.init(CommonsLogLogChute.java:75)
at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:81)
at org.apache.velocity.runtime.log.LogManager.updateLog(LogManager.java:269)
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:871)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:262)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:93)
at org.springframework.ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:249)
at org.springframework.web.servlet.view.velocity.VelocityConfigurer.afterPropertiesSet(VelocityConfigurer.java:120)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: autovalue.shaded.org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 31 common frames omitted
Looking at AutoValue's pom.xml. It seems Apache commons has been shaded, but why aren't the shaded classes loaded?
My application's pom.xml is on Github.
The problem is the VelocityAutoConfiguration class...
For some reason, AutoValue includes Velocity in its shaded jar but does not relocate the references.
When you include spring-context-support, some Velocity-related classes are loaded, which are picked up by VelocityAutoConfiguration, which then tries to load from the AutoValue included classes, crashing spectacularly.
My solution so far has been adding
#EnableAutoConfiguration(exclude = VelocityAutoConfiguration.class)
I resolved this issue by adding exclude to SpringBootApplicationclass as follows:
#SpringBootApplication(exclude = VelocityAutoConfiguration.class)

ClassNotFoundException after upgrading from Spring 3.0.5 to 3.2.1 in RCP application

I have an RCP application with several hundred bundles that is wired with Spring dm. After upgrading to Spring 3.2.1, I now get the following exception in a couple of bundles. At first I thought it may be caused by some magic in dm, but after testing that theory by initializing the bundle without dm (simply starting up an ApplicationContext programatically), I still faced the same exception.
Stacktrace:
Exception in thread "SpringOsgiExtenderThread-130" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FileSystemsStackViewControlFactory' defined in OSGi resource[classpath:spring/filesystem-ui.xml|bnd.id=176|bnd.sym=filesystem.ui]: Instantiation of bean failed; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1011)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:957)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at org.springframework.cglib.proxy.Enhancer.create(Enhancer.java:285)
at org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy$CglibSubclassCreator.instantiate(CglibSubclassingInstantiationStrategy.java:117)
at org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy.instantiateWithMethodInjection(CglibSubclassingInstantiationStrategy.java:69)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:91)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1004)
... 15 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
... 21 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/cglib/proxy/Factory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
... 26 more
Caused by: java.lang.ClassNotFoundException: org.springframework.cglib.proxy.Factory
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 29 more
The original manifest was a mixture of Require-Bundle and Package-Import, so I tried removing the Require-Bundle altogether. Didn't expect this to change anything, but desperate times call for desperate measures, and I was right, still nothing.
As a last resort, I also tried adding this attribute, still no change.
DynamicImport-Package: *
I know that Spring changed their usage of cglib around version 3.1 to embed cglib and asm within their core jars, but I have included imports for all the cglib and asm packages to no avail.
Manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: File System UI
Bundle-SymbolicName: com.mycorp.filesystem.ui;singleton:=true
Bundle-Version: 15.7.0.qualifier
Bundle-Activator: com.mycorp.filesystem.ui.internal.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Import-Package: com.mycorpcse.utils.eclipse,
com.mycorp.common.ui,
:
Many other in house dependencies
:
com.mycorp.core,
org.eclipse.core.commands,
:
Many other eclipse dependencies
:
org.eclipse.ui.views.properties,
org.osgi.framework;version="1.7.0",
org.springframework.asm;version="3.2.1.RELEASE",
org.springframework.asm.commons;version="3.2.1.RELEASE",
org.springframework.asm.signature;version="3.2.1.RELEASE",
org.springframework.asm.util;version="3.2.1.RELEASE",
org.springframework.beans;version="3.0.5.RELEASE",
org.springframework.beans.factory.annotation,
org.springframework.cglib;version="3.2.1.RELEASE",
org.springframework.cglib.beans;version="3.2.1.RELEASE",
org.springframework.cglib.core;version="3.2.1.RELEASE",
org.springframework.cglib.proxy;version="3.2.1.RELEASE",
org.springframework.cglib.reflect;version="3.2.1.RELEASE",
org.springframework.cglib.transform;version="3.2.1.RELEASE",
org.springframework.cglib.transform.impl;version="3.2.1.RELEASE",
org.springframework.cglib.util;version="3.2.1.RELEASE"
Export-Package: com.mycorp.filesystem.ui,
com.mycorp.filesystem.ui.columns,
com.mycorp.filesystem.ui.model
Update: I now realize that this particular case is caused only when using lookup method injection. As I still don't know how to fix it, I have had to alter the config to not use this feature.
We solved a similar problem by adding import-package of org.springframework.cglib etc. to the org.springframework.transaction bundle.
It seems in Spring 3.2 they changed the internal class structure. With the default OSGI package those clib classes can not be found. Therefore you have to explicit specify in the MANIFEST.MF that you need those packages loaded in the context.
You can edit the MANIFEST.MF file in your jar file. In Import-Package section add the following 3 packages:
'org.springframework.cglib.core','org.springframework.cglib.proxy','org.springframework.beans.factory'
Or if you are using gradle you can do the following (assuming you have osgi plugin enabled already)
jar {
manifest {
instruction 'Import-Package', 'org.springframework.cglib.core', 'org.springframework.cglib.proxy', 'org.springframework.beans.factory', '*'
}
}

OSGi bundle loading: NoClassDefFoundError of standard java class

I'm trying to run iDempiere on Virgo. I loaded multiple bundles without problems. The org.adempiere.server and org.idempiere.webservices load fine. But when loading the org.adempiere.ui.zk bundle, I get a NoClassDefFoundError in the org.adempiere.base bundle. The base bundle didn't cause any problems when loading org.adempiere.server, which also needs it.
The strange thing is, it's the javax.print.attribute.standard.MediaSize$NA class which isn't found, which is a standard Java class.
When executing clexport, the class is exported by org.eclipse.osgi
When executing clload, the class can get loaded by other bundles.
The error stack:
[2012-10-24 20:34:23.592] INFO fs-watcher o.e.virgo.kernel.deployer.hot.HotDeploymentFileSystemListener ApplicationConditionallyDeploying path 'D:\VIRGO-~1.REL\pickup\org.adempiere.ui.zk_1.0.0.v20121024-1809\'.
[2012-10-24 20:34:23.777] INFO start-signalling-1 org.compiere.web.AdempiereMonitorFilter
[2012-10-24 20:34:23.809] ERROR start-signalling-1 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/] StandardWrapper.Throwable java.lang.NoClassDefFoundError: javax/print/attribute/standard/MediaSize$NA
at org.compiere.util.Language.<clinit>(Language.java:101)
at org.compiere.util.Ini.<clinit>(Ini.java:85)
at org.compiere.util.WebEnv.initWeb(WebEnv.java:162)
at org.compiere.util.WebEnv.initWeb(WebEnv.java:129)
at org.compiere.web.AdempiereMonitor.init(AdempiereMonitor.java:1049)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:125)
at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:95)
at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:122)
at org.eclipse.virgo.kernel.install.artifact.internal.StandardArtifactStateMonitor.onStarted(StandardArtifactStateMonitor.java:271)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStartSucceeded(AbstractInstallArtifact.java:319)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.access$0(AbstractInstallArtifact.java:316)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact$StateMonitorSignal.signalSuccessfulCompletion(AbstractInstallArtifact.java:252)
at org.eclipse.virgo.kernel.core.internal.BundleStartTracker$1.run(BundleStartTracker.java:140)
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:722)
Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: javax.print.attribute.standard.MediaSize$NA in KernelBundleClassLoader: [bundle=org.adempiere.base_1.0.0.v20121024-1809]
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:139)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 25 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.print.attribute.standard.MediaSize$NA
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:135)
... 26 common frames omitted
Any idea what could cause this?
I see a:
Caused by: java.lang.ClassNotFoundException: javax.print.attribute.standard.MediaSize$NA
This is a CNFE not a NoClassDefFoundError
In module "org.adempiere.base_1.0.0.v20121024-1809" you need to:
Import-Package: javax.print.attribute.standard
FWIW This is an entry to add/merge into the MANIFEST.MF for that module.

maven test class files are not getting loaded: NoClassDefFoundError

I am getting following error while running junit test file with maven:
Caused
by:java.lang.NoClassDefFoundError:IllegalName:com/home/app/LoginDetailsTest
all my test class files are located at target\ test-classes and java class files are located at target\ classes directory.
since LoginDetailsTest located at target\ test-classes, it couldnot identify class files. how to solve this error?
spring xml file:
<bean id="loginDetails" class="com/home/app/LoginDetailsTest">
<property name="loginDetailsService" ref="loginService" />
</bean>
I am running junit test file through eclipse by right click and run as junit test.
<error message="Cannot find class [/com/home/app/LoginDetailsTest] for bean with name &apos;loginDetails&apos; defined in class path resource [com/home/app/LoginDetails-ctx.xml]; nested exception is java.lang.ClassNotFoundException: /com/home/app/LoginDetailsTest" type="org.springframework.beans.factory.CannotLoadBeanClassException">org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [/com/home/app/LoginDetailsTest] for bean with name &apos;loginDetails&apos; defined in class path resource [com/home/app/LoginDetails-ctx.xml]; nested exception is java.lang.ClassNotFoundException: /com/home/app/LoginDetailsTest
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1319)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:885)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at com.home.app.LoginDetailsTest.testLoginDetails(LoginDetailsTest.java:27)
Caused by: java.lang.ClassNotFoundException: /com/home/app/LoginDetailsTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)
at org.springframework.bea
You have to give the class name this way in Spring : "com.home.app.LoginDetailsTest", not this way "com/home/app/LoginDetailsTest"

Resources