我正在将grails2.5.x应用程序升级到grails4.0.8,在添加了所有内容和所有依赖项之后,我发现了这个错误。
java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Workbook
我在同一个错误上发现了许多类似的帖子,但似乎都不起作用。这个错误似乎是非常特定于用户的。
我的stacktrace看起来像这样->
C:\Java-11.0.8_10-winx64\bin\java.exe -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:CICompilerCount=3 -Djline.WindowsTerminal.directConsole=false -Dfile.encoding=UTF-8 @C:\Users\username\AppData\Local\Temp\idea_arg_file229552621 org.grails.cli.GrailsCli run-app --plain-output
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/Users/idnsuv/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy/2.5.14/f0a005fb21e7bd9b7ebf04cd2ecda0fc8f3be59d/groovy-2.5.14.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
|Running application...
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/Users/idnsuv/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy/2.5.14/f0a005fb21e7bd9b7ebf04cd2ecda0fc8f3be59d/groovy-2.5.14.jar) to method java.lang.reflect.AnnotatedElement.lambda$getDeclaredAnnotationsByType$0(java.lang.annotation.Annotation,java.lang.annotation.Annotation)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
WARNING: The hasOne property in class [com.ideas.cma.gft.RateSourceGftServerDetails] should have an initial expression of type Map or Class.
WARNING: The hasOne property in class [com.ideas.cma.gft.RateSourceGftServerDetails] should have an initial expression of type Map or Class.
WARNING: The hasOne property in class [com.ideas.cma.gft.RateSourceGftServerDetails] should have an initial expression of type Map or Class.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/Users/idnsuv/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy/2.5.14/f0a005fb21e7bd9b7ebf04cd2ecda0fc8f3be59d/groovy-2.5.14.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-03-05 09:49:39.795 ERROR --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplicationPostProcessor' defined in com.ideas.cma.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: Error instantiated artefact class [class com.ideas.cma.excelExport.myTasks.MyTeamTaskExcelExportService] of type [class org.grails.core.DefaultGrailsServiceClass]: InvocationTargetException
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1318)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:554)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:514)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:319)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
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 com.ideas.cma.Application.main(Application.groovy:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
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: Error instantiated artefact class [class com.ideas.cma.excelExport.myTasks.MyTeamTaskExcelExportService] of type [class org.grails.core.DefaultGrailsServiceClass]: InvocationTargetException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
... 25 common frames omitted
Caused by: org.grails.core.exceptions.GrailsRuntimeException: Error instantiated artefact class [class com.ideas.cma.excelExport.myTasks.MyTeamTaskExcelExportService] of type [class org.grails.core.DefaultGrailsServiceClass]: InvocationTargetException
at grails.core.ArtefactHandlerAdapter.newArtefactClass(ArtefactHandlerAdapter.java:170)
at grails.core.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:812)
at grails.core.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:504)
at grails.core.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:775)
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:68)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 26 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at grails.core.ArtefactHandlerAdapter.newArtefactClass(ArtefactHandlerAdapter.java:161)
... 39 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
at java.base/java.lang.Class.privateGetPublicMethods(Class.java:3191)
at java.base/java.lang.Class.getMethods(Class.java:1904)
at java.desktop/com.sun.beans.introspect.MethodInfo.get(MethodInfo.java:70)
at java.desktop/com.sun.beans.introspect.ClassInfo.getMethods(ClassInfo.java:71)
at java.desktop/java.beans.Introspector.getTargetMethodInfo(Introspector.java:1046)
at java.desktop/java.beans.Introspector.getBeanInfo(Introspector.java:462)
at java.desktop/java.beans.Introspector.getBeanInfo(Introspector.java:205)
at java.desktop/java.beans.Introspector.getBeanInfo(Introspector.java:293)
at java.desktop/java.beans.Introspector.<init>(Introspector.java:443)
at java.desktop/java.beans.Introspector.getBeanInfo(Introspector.java:205)
at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:3356)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3354)
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3331)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:287)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:329)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:272)
at org.grails.datastore.mapping.reflect.ClassPropertyFetcher.getStaticPropertyValue(ClassPropertyFetcher.java:176)
at org.grails.core.AbstractGrailsClass.getStaticPropertyValue(AbstractGrailsClass.java:239)
at org.grails.core.DefaultGrailsServiceClass.<init>(DefaultGrailsServiceClass.java:34)
... 44 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Workbook
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at org.springframework.boot.devtools.restart.classloader.RestartClassLoader.loadClass(RestartClassLoader.java:144)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 66 common frames omitted
在intellij idea中使用Java11和Grails4.0.8(Grails4使用gradle构建)。在Java8中运行并没有什么区别。
在gradle中使用pathingjar作为如此巨大的依赖项会导致windows10中文件路径/扩展名过长的错误
build.gradle(缩小)--
buildscript {
repositories {
maven { url "http://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.0"
classpath "org.grails.plugins:hibernate5:7.0.4"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.2.4"
}
}
version "0.1"
group "com.domain.projectname"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"com.github.erdi.webdriver-binaries"
apply plugin:"com.bertramlabs.asset-pipeline"
apply plugin:"org.grails.grails-gsp"
repositories {
mavenCentral()
maven { url "http://repo.grails.org/grails/core" }
//for external-config
maven { url "https://oss.jfrog.org/repo/" }
maven { url "https://repo.grails.org/grails/plugins" }
flatDir {
dirs 'lib'
}
}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
dependencies {
developmentOnly("org.springframework.boot:spring-boot-devtools")
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core:4.0.8"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-i18n"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core"
compile "org.grails.plugins:gsp"
compileOnly "io.micronaut:micronaut-inject-groovy"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2:1.4.199"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "javax.xml.bind:jaxb-api:2.3.1"
runtime "com.bertramlabs.plugins:asset-pipeline-grails"
testCompile "io.micronaut:micronaut-inject-groovy"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.mockito:mockito-core"
testCompile "org.grails:grails-web-testing-support"
testCompile "org.grails.plugins:geb"
testCompile "org.seleniumhq.selenium:selenium-remote-driver"
testCompile "org.seleniumhq.selenium:selenium-api:3.14.0"
testCompile "org.seleniumhq.selenium:selenium-support:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0"
// User added
compile 'org.grails.plugins:external-config:2.0.0'
//Below are the dependencies which are situated in /lib folder as .jar
compile name: 'activation'
compile name: 'axis'
compile name: 'cma-common'
compile name: 'commons-collections4-4.1'
compile name: 'commons-discovery-0.2'
compile name: 'commons-logging-1.0.4'
compile name: 'concurrent'
compile name: 'CSVUpload'
compile name: 'DynamicJasper-3.0.4'
compile name: 'hibernate-entitymanager'
compile name: 'hibernate-search'
compile name: 'hibernate-validator'
compile name: 'ideas-intf-integration'
compile name: 'iText-2.1.4'
compile name: 'jasperreports-3.1.4'
compile name: 'jaxb1-impl'
compile name: 'jaxb-impl'
compile name: 'jaxb-xjc'
compile name: 'jaxrpc'
compile name: 'jbossall-ideas-client'
compile name: 'jboss-aop-jdk50'
compile name: 'jboss-jaxws'
compile name: 'jboss-messaging-client'
compile name: 'jboss-remoting'
compile name: 'jboss-saaj'
compile name: 'jboss-serialization'
compile name: 'jbossws-client'
compile name: 'jbossws-common'
compile name: 'jbossws-spi'
compile name: 'jboss-xml-binding'
compile name: 'jms'
compile name: 'jnp-client'
compile name: 'jsr173_1.0_api'
compile name: 'lucene-core'
compile name: 'mail'
compile name: 'mysql-connector-java-5.1.20'
compile name: 'policy'
compile name: 'saaj'
compile name: 'sfdcws'
compile name: 'sqljdbc4-1'
compile name: 'trove'
compile name: 'ooxml-schemas-1.3'
compile name: 'poi-3.17'
compile name: 'poi-ooxml-3.17'
compile name: 'poi-ooxml-schemas-3.17'
compile name: 'wsdl4j-1.5.1'
compile name: 'xercesImpl'
compile name: 'xmlbeans-3.1.0'
compile name: 'xpp3_min-1.1.4c'
compile name: 'xstream-1.3.1'
runtimeOnly group: 'org.grails.plugins', name: 'jquery', version: '1.11.1'
runtimeOnly group: 'org.grails.plugins', name: 'resources', version: '1.2.14'
implementation group: 'org.grails.plugins', name: 'bubbling', version: '1.5.1'
implementation group: 'org.grails.plugins', name: 'calendar', version: '1.2.1'
implementation group: 'org.grails.plugins', name: 'code-coverage', version: '1.1.6'
implementation group: 'org.grails.plugins', name: 'webflow', version: '2.1.0'
compile "org.grails.plugins:shiro:1.2.1"
implementation group: 'org.grails.plugins', name: 'yui', version: '2.8.2.1'
implementation group: 'org.apache.tomcat', name: 'tomcat', version: '7.0.70', ext: 'pom'
compile "org.grails.plugins:calendar:1.2.1"
implementation group: 'org.grails.plugins', name: 'ckeditor', version: '4.5.9.0'
implementation group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
provided "opensymphony:quartz-all:1.6.3"
runtime "commons-io:commons-io:2.4"
runtime "org.springframework:spring-context-support:3.1.0.RELEASE"
runtime "org.springframework:spring-jms:3.1.0.RELEASE"
runtime "org.jboss.logging:jboss-logging:3.2.1.Final"
runtime "commons-dbcp:commons-dbcp:1.4"
compile 'org.springframework:spring-jms:5.1.20.RELEASE'
}
bootRun {
ignoreExitValue true
jvmArgs(
'-Dspring.output.ansi.enabled=always',
'-noverify',
'-XX:TieredStopAtLevel=1',
'-Xmx1024m')
sourceResources sourceSets.main
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}
grails{
pathingJar = true
}
p、 s.->对其他依赖项也有类似的错误->太“grails依赖项报告”了。不知道如何解决它。(下面只是一个路径。孔报告太长)
+--- myproject-common (n) //A required jar from my another project
+--- commons-collections4-4.1 (n)
+--- commons-discovery-0.2 (n)
+--- commons-logging-1.0.4 (n)
+--- concurrent (n)
+--- CSVUpload (n)
+--- DynamicJasper-3.0.4 (n)
+--- hibernate-entitymanager (n)
+--- hibernate-search (n)
+--- hibernate-validator (n)
+--- myproject-intf-integration (n) //A required jar from my another project
+--- iText-2.1.4 (n)
+--- jasperreports-3.1.4 (n)
+--- jaxb1-impl (n)
+--- jaxb-api (n)
+--- jaxb-impl (n)
+--- jaxb-xjc (n)
+--- jaxrpc (n)
+--- jbossall-ideas-client (n)
+--- jboss-aop-jdk50 (n)
+--- jboss-jaxws (n)
+--- jboss-messaging-client (n)
+--- jboss-remoting (n)
+--- jboss-saaj (n)
+--- jboss-serialization (n)
+--- jbossws-client (n)
+--- jbossws-common (n)
+--- jbossws-spi (n)
+--- jboss-xml-binding (n)
+--- jms (n)
+--- jnp-client (n)
+--- jsr173_1.0_api (n)
+--- lucene-core (n)
+--- mail (n)
+--- mysql-connector-java-5.1.20 (n)
+--- policy (n)
+--- saaj (n)
+--- sfdcws (n)
+--- sqljdbc4-1 (n)
+--- trove (n)
+--- wsdl4j-1.5.1 (n)
+--- xercesImpl (n)
+--- xmlbeans-3.1.0 (n)
+--- xpp3_min-1.1.4c (n)
+--- xstream-1.3.1 (n)
+--- org.grails.plugins:quartz:2.0.13 (n)
+--- commons-io:commons-io:2.8.0 (n)
+--- org.springframework:spring-context-support:3.2.18.RELEASE (n)
+--- org.apache.poi:poi-ooxml-schemas:4.1.2 (n)
+--- org.apache.poi:poi:4.1.2 (n)
+--- org.apache.poi:poi-ooxml:4.1.2 (n)
+--- org.quartz-scheduler:quartz:1.7.2 (n)
\--- org.grails.plugins:jms:2.0.0.RC2 (n)
我还尝试过删除.m2、.grails、.gradle、grails clean以及与重置项目相关的所有内容
1条答案
按热度按时间6psbrbz91#
从错误来看,应用程序似乎无法找到
org.apache.poi.ss.usermodel.Workbook
. 原因可能有多种,如:类路径中不存在apache poi jar。因此,需要添加相应的依赖项。
当您有多个poi库的不同版本时也可能发生这种情况,我认为它们彼此不兼容。在这种情况下,您需要确保每个poi依赖项都指向同一版本。
最后,您可能需要检查库的相应版本中是否存在具有相同包的类。检查是否使用jetbrains intellij idea的最简单方法是导航到类。