我有一个Maven应用程序,当我使用xml-jetty运行我的应用程序时,我收到了Failed to read candidate component class, nested exception is ArrayStoreException: java.lang.String
类的target/classes/com/test/SampleImpl
错误,我看到了原始的SampleImpl.java文件,但无法查找与该文件有关的任何错误。我对该错误进行了一些研究,发现了一些与将Spring的Java版本7
更改为8
有关的建议,我将Java版本更改为8
,并且将Spring版本更改为4.x
bt仍然出现相同的错误,然后像其他站点中所建议的那样,我在dependency-management
中添加了一些spring依赖项,但仍然出现相同的错误。
[main] INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/beans.xml]
[main] INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
[main] INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
[main] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\Projects\my-server\target\classes\com\my\pack\impl\SampleImpl.class]; nested exception is java.lang.ArrayStoreException: java.lang.String
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:290)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:195)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
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:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
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.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:801)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:446)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:793)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:296)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1347)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:745)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:281)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:213)
at org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:763)
at org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:144)
at org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
at org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:605)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:560)
at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.Server.start(Server.java:355)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:99)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:60)
at org.eclipse.jetty.server.Server.doStart(Server.java:324)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1250)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
Caused by: java.lang.ArrayStoreException: java.lang.String
at org.springframework.util.ObjectUtils.addObjectToArray(ObjectUtils.java:188)
at org.springframework.core.type.classreading.RecursiveAnnotationArrayVisitor.visit(AnnotationAttributesReadingVisitor.java:122)
at org.springframework.core.type.classreading.AbstractRecursiveAnnotationVisitor.visitEnum(AnnotationAttributesReadingVisitor.java:77)
at org.springframework.asm.ClassReader.a(Unknown Source)
at org.springframework.asm.ClassReader.a(Unknown Source)
at org.springframework.asm.ClassReader.a(Unknown Source)
at org.springframework.asm.ClassReader.a(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:266)
... 63 more
SampleImpl:-
public class SampleImpl extends AbstractServiceImpl {
/**
* The stack builder to manage the blueprints
*/
protected StackBuilder builder;
protected Sample2ServiceImpl service2;
/**
* The object factory
*/
// DH: remove because it was hiding the same thing in the abstract base class
// protected ObjectFactory objectFactory = new ObjectFactory();
private final static int SAMPLE_VALIDATION_ERROR_CODE = 100;
/**
* Constructor
*/
public SampleImpl() {
}
public SampleImpl(StackBuilderFactory fac, EngineResolver resolver) {
try {
builder = fac.getBuilder();
builder.registerSampleResolver(resolver);
} catch (EngineException e) {
LOG.error("Error initializing SampleImpl", e);
}
}
/**
* Invoked by a BeanFactory after it has set all bean properties. The bean will create an instance of the stack
* builder factory and create a disconnected (not attached to any context) stack builder. A disconnected stack
* builder cannot be used to access any provider services since there is no provider connected. It can still be used
* to validate Samples and process the hierarchy.
*/
public void afterPropertiesSet() throws Exception {
LOG.debug("{}: afterPropertiesSet(): Entered", this);
sbFactory = new StackBuilderFactory();
builder = sbFactory.getBuilder();
builder.registerSampleResolver(getEngineResolver());
service2 = new Sample2ServiceImpl(getDaoProvider());
LOG.debug("{}: afterPropertiesSet(): DONE", this);
}
@AuthorizeOperation(permissionsAuthorized = { Permission.OPERATION_DELETE_Sample })
public void deleteSample(SampleId sampleId) throws UnauthorizedException, EntityNotFoundException,
EntityMappingException, CDPException {
LOG.info("deleting Sample...");
sampleId= getDaoProvider().getSample2Dao().populateSampleIdWithBpId(sampleId);
/**
* Check if the Sample exists
*/
if (StringUtils.isBlank(sampleId.getId())) {
throw new EntityNotFoundException(CDPMsg.REQUESTED_Sample_DOES_NOT_EXIST, sampleId.toString());
}
UUID sampleUUIDId = sampleId.toUUID();
//check if Sample name is System
if (sampleId.getName().equals(com.name.SYSTEM_SAMPLE_NAME)) {
// cannot delete since its System Sample
String msg = "System Sample cannot be deleted";
LOG.error(msg);
throw new EntityMappingException(msg);
}
if(getDaoProvider().getDescendants2Dao().checkSampleIsAncestor(sampleUUIDId )) {
String msg =
Msg.SAMPLE_USED_BY_OTHER_SAMPLE
.getMessage(sampleId.format(sampleId.getId(), sampleId.getName(), sampleId.getVersion()));
LOG.error(msg);
throw new EntityMappingException(CDPMsg.SAMPLE_USED_BY_OTHER_SAMPLE, SampleId.format(sampleId.getId(), sampleId.getName(), sampleId.getVersion()));
}
if (getDaoProvider().getSampleByStack2Dao().checkSampleUsedByStack(sampleId)) {
// cannot delete since its used by stack
String msg = CDPMsg.SAMPLE_USED_BY_STACK.getMessage(SampleId.format(sampleId.getId(), sampleId.getName(), sampleId.getVersion()));
LOG.error(msg);
throw new EntityMappingException(Msg.SAMPLE_USED_BY_STACK, SampleId.format(sampleId.getId(), sampleId.getName(), sampleId.getVersion()));
}
//getDaoProvider().getSampleDao().deleteSample(sampleId.getName(), sampleId.getVersion());
String currentUser = getUserSecurityProvider().getCurrentUserId();
UUID tenantId = getDaoProvider().getBlueprintByTenant2Dao().getTenantIdSampleByTenant(SampleUUIDId);
service2.deleteAllBlueprintTables(sampleUUIDId, tenantId, currentUser);
service2.deleteAncestor2AndDescendant2(sampleUUIDId, currentUser);
getDaoProvider().getSampleByTenant2Dao().delete(sampleUUIDId);
getDaoProvider().getTenantBySample2Dao().delete(tenantId, blueprintUUIDId);
getDaoProvider().getSample2Dao().delete(sampleUUIDId);
LOG.info("deleted Samplesuccessfully");
}