在cmd环境下运行jar包报错,请高手指点下
海洋夜之星 2015-03-06 11:12:29 C:\Users\soulda\Desktop\test>java -jar soulda_ums.jar 3
三月 06, 2015 11:05:47 上午 org.springframework.context.support.AbstractApplicat
ionContext prepareRefresh
信息: Refreshing org.springframework.context.support.FileSystemXmlApplicationCon
text@5f580757: startup date [Fri Mar 06 11:05:47 CST 2015]; root of context hier
archy
三月 06, 2015 11:05:47 上午 org.springframework.beans.factory.xml.XmlBeanDefinit
ionReader loadBeanDefinitions
信息: Loading XML bean definitions from file [C:\Users\soulda\Desktop\test\autol
oad-appcontext-soulda-persist.xml]
三月 06, 2015 11:05:47 上午 org.springframework.beans.factory.support.DefaultSin
gletonBeanRegistry destroySingletons
信息: Destroying singletons in org.springframework.beans.factory.support.Default
ListableBeanFactory@6f4f5643: defining beans [jdbcTemplate,sqlSessionFactory,tra
nsactionManager,org.mybatis.spring.mapper.MapperScannerConfigurer#0,dmsDataSourc
e,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.tr
ansaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.
transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction
.config.internalTransactionAdvisor,org.springframework.context.annotation.intern
alConfigurationAnnotationProcessor,org.springframework.context.annotation.intern
alAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRe
quiredAnnotationProcessor,org.springframework.context.annotation.internalCommonA
nnotationProcessor,org.springframework.context.weaving.AspectJWeavingEnabler#0,o
rg.springframework.context.config.internalBeanConfigurerAspect,loadTimeWeaver,or
g.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAware
BeanPostProcessor#0]; root of factory hierarchy
Exception in thread "main" org.springframework.beans.factory.BeanCreationExcepti
on: Error creating bean with name 'org.springframework.context.weaving.AspectJWe
avingEnabler#0': Initialization of bean failed; nested exception is org.springfr
amework.beans.factory.BeanCreationException: Error creating bean with name 'load
TimeWeaver': Initialization of bean failed; nested exception is java.lang.Illega
lStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide
an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeav
er or start your Java virtual machine with Spring's agent: -javaagent:org.spring
framework.instrument.jar
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBea
n(AbstractApplicationContext.java:1097)
at org.springframework.context.support.AbstractApplicationContext.invoke
BeanFactoryPostProcessors(AbstractApplicationContext.java:661)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:446)
at org.springframework.context.support.FileSystemXmlApplicationContext.<
init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<
init>(FileSystemXmlApplicationContext.java:94)
at com.soulda.ums.Import.main(Import.java:49)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'loadTimeWeaver': Initialization of bean failed; nested except
ion is java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassL
oader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specif
y a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent
: -javaagent:org.springframework.instrument.jar
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:197)
at org.springframework.context.weaving.LoadTimeWeaverAwareProcessor.post
ProcessBeforeInitialization(LoadTimeWeaverAwareProcessor.java:95)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanF
actory.java:394)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1448)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 11 more
Caused by: java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppCl
assLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Sp
ecify a custom LoadTimeWeaver or start your Java virtual machine with Spring's a
gent: -javaagent:org.springframework.instrument.jar
at org.springframework.context.weaving.DefaultContextLoadTimeWeaver.setB
eanClassLoader(DefaultContextLoadTimeWeaver.java:93)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 20 more
上面是运行时报错的信息,下面是我在此包中的程序入口代码:
public static void main(String[] args) {
if(args.length!=1){
System.out.print("参数格式:Import 路径[或数字]");
return;
}
File file = getJarDir(Import.class);
String propsFilePath = file.getPath() + "\\autoload-appcontext-soulda-persist.xml";
ApplicationContext context = new FileSystemXmlApplicationContext(new String[] {propsFilePath});
}
目前可以确定程序运行到ApplicationContext context = new FileSystemXmlApplicationContext(new String[] {propsFilePath});这句话报错,路径是完全没有问题的,xml文件也存在,并且xml的内容如下:
<?xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-lazy-init="true">
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dmsDataSource">
</property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dmsDataSource" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource"><ref bean="dmsDataSource" /></property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<property name="basePackage" value="" />
<property name="markerInterface" value="" />
</bean>
<bean id="dmsDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="" />
<property name="url" value="" />
<property name="username" value="" />
<property name="password" value="" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<context:annotation-config />
<context:component-scan base-package=""/>
<aop:aspectj-autoproxy />
<context:load-time-weaver />
<context:spring-configured />
</beans>
不知道哪里出了错误,上面xml文件里面属性的value都有值,我只是为了发到网上所以把他删除了,请高手帮忙看看错误,小弟我感激不尽。