通过AppFuse创建ssh工程问题总结(二)

第一篇太长了,也为了纪念这个节日,重新开个贴。第一篇地址: http://up2pu.iteye.com/blog/1019259

1.中文环境测试问题

错误信息:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An Ant BuildException has occured: The following error occurred while executing this line:
F:\workspace\og\src\test\resources\web-tests.xml:92: Step[verifytext "verify results" (11/11)]: Text not found in page. Expected <One user found.>


解决方法:
在中文环境下,验证使用中文,修改web-tests.xml
    <target name="SearchUser" description="Tests search for and displaying all users">
        <webtest name="searchUser">
            &config;
            <steps>
                &login;
                <invoke description="click View Users link" url="/admin/users"/>
                <verifytitle description="we should see the user list title" 
                    text=".*${userList.title}.*" regex="true"/>
                <setinputfield description="set search term" name="q" value="tomcat"/>
                <clickbutton label="${button.search}" description="Click Search"/>
                <verifytext description="verify results" text="共找到一条user记录。"/> <!--One user found. -->
            </steps>
        </webtest>
    </target>


2.copyright错误
错误信息:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An Ant BuildException has occured: The following error occurred while executing this line:
F:\workspace\og\src\test\resources\web-tests.xml:8: Property copyright.year was circularly defined.


解决方法:
ApplicationResources.properties中将为copyright.year设置具体的值
copyright.year=2003-2011


3.代理问题
错误信息:
src\test\resources\login.xmlf:1: HTTP error 404


解决方法:
取消代理设置

4.tomcat问题
错误信息:
ERROR [main] Dispatcher.error(27) | Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/F:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/og/WEB-INF/lib/struts2-core-2.1.8.jar!/struts-default.xml:47:178
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
	at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.init(StrutsPrepareFilter.java:50)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4001)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4651)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/F:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/og/WEB-INF/lib/struts2-core-2.1.8.jar!/struts-default.xml:47:178
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:221)
	at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:169)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
	... 22 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
	at java.lang.Class.getDeclaredConstructors(Class.java:1808)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:211)
	... 25 more


2011-11-9 10:59:16 org.apache.catalina.core.StandardContext listenerStart
严重: Error configuring application listener of class net.ecoolsoft.og.webapp.listener.StartupListener
java.lang.ClassNotFoundException: net.og.webapp.listener.StartupListener
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2011-11-9 10:59:16 org.apache.catalina.core.StandardContext listenerStart
严重: Error configuring application listener of class net.og.webapp.listener.UserCounterListener
java.lang.ClassNotFoundException: net.ecoolsoft.og.webapp.listener.UserCounterListener
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2011-11-9 10:59:16 org.apache.catalina.core.StandardContext listenerStart
严重: Error configuring application listener of class net.ecoolsoft.og.webapp.jsp.EscapeXmlELResolverListener
java.lang.ClassNotFoundException: net.ecoolsoft.og.webapp.jsp.EscapeXmlELResolverListener
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)


解决方法:
以上两种情况,经过检查所需要的jar都有,后来发现是server中的tomcat出了问题,将tomcat删除,重新设置即可

5.编码问题
错误信息:
2011-11-9 23:07:59 org.apache.tomcat.util.modeler.Registry registerComponent
严重: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/og,J2EEApplication=none,J2EEServer=none
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassFormatError: Truncated class file
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2733)
	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
	at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:145)
	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:73)
	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:56)
	at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
	at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1078)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4540)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
	... 6 more



解决方法:
一般是修改了资源文件的编码方式导致的问题

6.campass的bug
错误信息:
-------------------------------------------------------------------------------
Test set: net.og.webapp.listener.StartupListenerTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.725 sec <<< FAILURE!
testContextInitialized(net.ecoolsoft.og.webapp.listener.StartupListenerTest)  Time elapsed: 5.716 sec  <<< ERROR!
org.compass.core.engine.SearchEngineException: Failed to rename index [target/test-index/index/user] to [target\test-index\index\user-copy0]
	at org.compass.core.lucene.engine.store.FSDirectoryStore.beforeCopyFrom(FSDirectoryStore.java:157)
	at org.compass.core.lucene.engine.store.DefaultLuceneSearchEngineStore.copyFrom(DefaultLuceneSearchEngineStore.java:616)
	at org.compass.core.lucene.engine.store.DefaultLuceneSearchEngineStore.copyFrom(DefaultLuceneSearchEngineStore.java:602)
	at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager$ReplaceIndexOperationCallback$1$1.run(DefaultLuceneSearchEngineIndexManager.java:298)
	at org.compass.core.lucene.engine.manager.IndexHoldersCache.doUnderCacheLock(IndexHoldersCache.java:126)
	at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager$ReplaceIndexOperationCallback$1.doInTransaction(DefaultLuceneSearchEngineIndexManager.java:294)
	at org.compass.core.impl.DefaultCompass$CompassTransactionContext.execute(DefaultCompass.java:423)
	at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager$ReplaceIndexOperationCallback.secondStep(DefaultLuceneSearchEngineIndexManager.java:290)
	at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager.doOperate(DefaultLuceneSearchEngineIndexManager.java:248)
	at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager.doReplaceIndex(DefaultLuceneSearchEngineIndexManager.java:266)
	at org.compass.core.lucene.engine.manager.DefaultLuceneSearchEngineIndexManager.replaceIndex(DefaultLuceneSearchEngineIndexManager.java:261)
	at org.compass.gps.impl.SingleCompassGps.doIndex(SingleCompassGps.java:118)
	at org.compass.gps.impl.AbstractCompassGps.index(AbstractCompassGps.java:154)
	at org.compass.gps.impl.AbstractCompassGps.index(AbstractCompassGps.java:128)
	at net.ecoolsoft.og.webapp.listener.StartupListener.setupContext(StartupListener.java:110)
	at net.ecoolsoft.og.webapp.listener.StartupListener.contextInitialized(StartupListener.java:93)
	at net.ecoolsoft.og.webapp.listener.StartupListenerTest.testContextInitialized(StartupListenerTest.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)


解决方法:
修改src/main/webapp/WEB-INF/applicationContext.xml

    <bean id="compass" class="org.compass.spring.LocalCompassBean">
        <property name="mappingScan" value="org.appfuse"/>
        <property name="postProcessor" ref="compassPostProcessor"/>
        <property name="transactionManager" ref="transactionManager" />
        <property name="settings">
            <map>
                <entry key="compass.engine.connection" value="target/test-index" />
            </map>
        </property>
    </bean>

改为
    <bean id="compass" class="org.compass.spring.LocalCompassBean">
        <property name="mappingScan" value="org.appfuse"/>
        <property name="postProcessor" ref="compassPostProcessor"/>
        <property name="transactionManager" ref="transactionManager" />
        <property name="settings">
            <map>
                <entry key="compass.engine.connection" value="ram://index"/>
            </map>
        </property>
    </bean>

参考:
http://issues.appfuse.org/browse/APF-1261
http://static.compassframework.org/docs/latest/core-configuration.html#CompassSettings

7.中文乱码问题
问题说明:
ApplicationResources中的中文可以正常显示,但是displaytag和errors中的中文是乱码

解决方法:
修改pom.xml,将
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>native2ascii-maven-plugin</artifactId>
                <version>1.0-alpha-1</version>
                <configuration>
                    <dest>target/resources</dest>
                    <src>src/main/resources</src>
                </configuration>
                <executions>
                    <execution>
                        <id>native2ascii-utf8</id>
                        <goals>
                            <goal>native2ascii</goal>
                        </goals>
                        <configuration>
                            <encoding>UTF8</encoding>
                            <includes>ApplicationResources_*.properties</includes>
                            <excludes>ApplicationResources.properties,
                                ApplicationResources_de*.properties,
                                ApplicationResources_fr*.properties,
                                ApplicationResources_nl*.properties,
                                ApplicationResources_pt*.properties,
                                ApplicationResources_es*.properties</excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>native2ascii-8859_1</id>
                        <goals>
                            <goal>native2ascii</goal>
                        </goals>
                        <configuration>
                            <encoding>8859_1</encoding>
                            <includes>ApplicationResources.properties,
                                ApplicationResources_de.properties,
                                ApplicationResources_fr.properties,
                                ApplicationResources_nl.properties,
                                ApplicationResources_pt*.properties,
                                ApplicationResources_es*.properties</includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>ApplicationResources*.properties</exclude>
                </excludes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>target/resources</directory>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>

改为
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>native2ascii-maven-plugin</artifactId>
                <version>1.0-alpha-1</version>
                <configuration>
                    <dest>target/classes</dest>
                    <src>src/main/resources</src>
                </configuration>
                <executions>
                    <execution>
                        <id>native2ascii-utf8</id>
                        <goals>
                            <goal>native2ascii</goal>
                        </goals>
                        <configuration>
                            <encoding>UTF8</encoding>
                            <includes>*_zh*.properties</includes>
                        </configuration>
                    </execution>
                    
                    <execution>
                        <id>native2ascii-8859_1</id>
                        <goals>
                            <goal>native2ascii</goal>
                        </goals>
                        <configuration>
                            <encoding>8859_1</encoding>
                            <includes>displaytag*.properties,errors*.properties,ApplicationResources*.properties</includes>
                            <excludes>*_zh*.properties</excludes>
                        </configuration>
                    </execution>
                     
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>ApplicationResources*.properties</exclude>
                    <exclude>errors*.properties</exclude>
                    <exclude>displaytag*.properties</exclude>
                </excludes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>target/resources</directory>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>


你可能感兴趣的:(maven,ssh,Appfuse)