当前位置:编程学习 > JAVA >>

使用myeclipse发布的war正常,但是使用ant制作的war出现异常!求教

1. 问题很简单,就是在myecilpse中使用export的方法生成war包在jboss下能正常运行。
但是使用ant进行编译却无法运行运行。老是报一个spring aspect的一个错误。无法解决。
build文件没有错误。
以下是build文件的内容:


<?xml version="1.0" encoding="UTF-8"?>
<project name="ok" basedir="../." default="makewar">
<!--定义属性-->
<property name="classpath_lib" value="web/WEB-INF/lib" />
<property name="sources" value="${basedir}/src" />

<!--设置classpath属性-->
<path id="classpath">
<fileset dir="${classpath_lib}">
<include name="*.jar" />
</fileset>
<fileset dir="${classpath_lib}/hibernate">
<include name="*.jar" />
</fileset>
</path>
<!-- 创建临时目录和复制内容 -->
<target name="init">
<property name="tmpDir" value="_tmp_ant_dir">
</property>
<property name="src" value="src">
</property>
<delete dir="${tmpDir}" />
<mkdir dir="${tmpDir}" />
<mkdir dir="${tmpDir}/WEB-INF" />
<mkdir dir="${tmpDir}/WEB-INF/classes" />
<mkdir dir="${tmpDir}/WEB-INF/lib" />
<copy todir="${tmpDir}">
<fileset dir="${basedir}/web">
<include name="**" />
<exclude name="WEB-INF/classes/**"/>
</fileset>
</copy>
<copy todir="${tmpDir}/WEB-INF/classes">
<fileset dir="${basedir}/src">
<include name="*.xml" />
<include name="*.properties" />
</fileset>
</copy>
<copy todir="${tmpDir}/WEB-INF/lib">
<fileset dir="${basedir}/web/WEB-INF/lib/hibernate">
<include name="*.jar" />
</fileset>
</copy>
</target>
<target name="complie" depends="init">
<javac srcdir="${src}" destdir="${tmpDir}/WEB-INF/classes" encoding="UTF-8" includeAntRuntime="false">
<classpath refid="classpath">
</classpath>
</javac>
</target>
<target name="makewar" depends="complie">
<war warfile="pims.war" webxml="${tmpDir}/WEB-INF/web.xml" encoding="UTF-8">
<classes dir="${tmpDir}/WEB-INF/classes" />
<fileset dir="${tmpDir}"></fileset>
</war> 
</target>
</project>

报以下的错误:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0' defined in URL [file:/E:/lee/apps/jboss-4.2.3.GA/server/default/deploy/pp.war/WEB-INF/classes/applicationContext-security.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in URL [file:/E:/lee/apps/jboss-4.2.3.GA/server/default/deploy/pp.war/WEB-INF/classes/applicationContext-security.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer$AmbiguousBindingException: Still 2 unbound args at this(),target(),args() binding stage, with no way to determine between them
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:86)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:100)
at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:84)
at org.sp
21:09:02,863 INFO  [STDOUT] ringframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:107)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:880)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:852)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:446)
... 144 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0' defined in URL [file:/E:/lee/apps/jboss-4.2.3.GA/server/default/deploy/pp.war/WEB-INF/classes/applicationContext-security.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in URL [file:/E:/lee/apps/jboss-4.2.3.GA/server/default/deploy/pp.war/WEB-INF/classes/applicationContext-security.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer$AmbiguousBindingException: Still 2 unbound args at this(),target(),args() binding stage, with no way to determine between them
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 161 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0' defined in URL [file:/E:/lee/apps/jboss-4.2.3.GA/server/default/deploy/pp.war/WEB-INF/classes/applicationContext-security.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in URL [file:/E:/lee/apps/jboss-4.2.3.GA/server/default/deploy/pp.war/WEB-INF/classes/applicationContext-security.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer$AmbiguousBindingException: Still 2 unbound args at this(),target(),args() binding stage, with no way to determine between them
--------------------编程问答-------------------- 补充一下,JDK都是使用相同的JDK。还有就是使用ANT编译出来的CLASS要比myeclipse的要小。不知道为什么原因。 --------------------编程问答-------------------- 我试过使用myeclipse编译出来的classes目录替换到ant的classes目录中,能正常运行。这很明显就是ant编译时生成class的问题,请教高手。。 --------------------编程问答-------------------- 1. Ant 默认 编译器 面对 Annotation中使用了 枚举的编译错误

a. 找到 jdtCompilerAdapter.jar and org.eclipse.jdt.core_3.5.2.v_981_R35x.jar (search org.eclipse.jdt.core in eclipse directory)

    b. 然后把它们放入 ${ANT_HOME}/lib
下面一步可有可无
    c.加入配置<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> in builder.xml 
补充:Java ,  非技术区
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,