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

[b]一、安装Maven及m2eclipse插件[/b]
这部分Maven的安装比较简单,不再详述。m2eclipse的安装有一些注意事项,参看如下文章:
[url]http://up2pu.iteye.com/blog/1019251[/url]
m2eclipse的新版本还不稳定,创建appfuse工程时可能会出现问题。请按照上面的方法安装稳定版本。

[b]二、创建appfuse工程[/b]
以Eclipse 3.6.2举例说明如下:
File->New->Other->Maven->Maven Project->Select an Archetype->appfuse-light-struts-archetype(当前版本是2.1.0)->输入Group Id,Artifact Id,Package->Finish

appfuse针对不同框架,提供了light版和basic版的项目模板,light版是简单版本,只有基本功能,basic版是扩展版本,提供了安全性支持,密码找回等常用功能。

[b]三、问题解决方法[/b]
[color=red][i]1.Hibernate dtd问题[/i][/color]
错误信息:
Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2ddl (default) on project light: Execution default of goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2ddl failed: Could not parse configuration: file:/F:/workspace3.5/light/src/main/resources/hibernate.cfg.xml: Connection timed out: connect Nested exception: Connection timed out: connect -> [Help 1]

解决方法:
在hibernate.cfg.xml中将以下内容注释掉
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
使用如下内容
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

[color=red][i]2.MySQL配置问题[/i][/color]
错误信息:
ERROR - SchemaExport.execute(274) | schema export unsuccessful
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:52)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:252)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:211)
at org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:112)
at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:365)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

解决方法:
AppFuse默认不使用MySQL,如果使用MySql需要做如下修改:
1> jdbc.properties注释掉H2配置部分,使用MySQL配置

# MySQL
# -----------------------------------------
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost/appfuse?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=****

hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect

# Needed by Hibernate3 Maven Plugin defined in pom.xml
hibernate.connection.username=root
hibernate.connection.password=****
hibernate.connection.url=jdbc:mysql://localhost/appfuse?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8
hibernate.connection.driver_class=com.mysql.jdbc.Driver


2> pom.xml中删除H2配置,添加MySQL配置

<!-- Database settings, also defined in src/main/jdbc.properties for easy IDE testing -->
<dbunit.dataTypeFactoryName>org.dbunit.ext.mysql.MySqlDataTypeFactory</dbunit.dataTypeFactoryName>
<dbunit.operation.type>CLEAN_INSERT</dbunit.operation.type>
<hibernate.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</hibernate.dialect>
<jdbc.groupId>mysql</jdbc.groupId>
<jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
<jdbc.version>5.1.14</jdbc.version>
<jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
<jdbc.url>jdbc:mysql://localhost/appfuse?createDatabaseIfNotExist=true&amp;useUnicode=true&amp;characterEncoding=utf-8</jdbc.url>
<jdbc.username>root</jdbc.username>
<jdbc.password>****</jdbc.password>


[color=red][i]3.设置代理[/i][/color]
1>Maven代理
C:\Users\sky\.m2\settings.xml
apache-maven-2.2.1\conf\settings.xml

<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
| -->
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username></username>
<password></password>
<host>172.11.22.33</host>
<port>8888</port>
<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
</proxy>
</proxies>


2>SVN代理
报错如下:

[ERROR] 175002 : svn: PROPFIND request failed on '/svn/appfuse~svn/tags/APPFUSE_2.1.0/data/common/src'
[ERROR] 175002 : svn: Connection timed out: connect

解决方法:
C:\Users\sky\AppData\Roaming\Subversion\servers

[global]
http-proxy-host = 172.22.17.66
http-proxy-port = 8888
http-proxy-username = defaultusername
http-proxy-password = defaultpassword


3> ant代理
ANT_OPTS=-Dhttp.proxyHost=172.22.17.66 -Dhttp.proxyPort=8888

4> Java代理
java -DproxySet=true -DproxyHost=myProxyServer.com -DproxyPort=80 MyJavaApp

[color=red][i]4.Build Path中Maven找不到tools-1.5.0.jar[/i][/color]

C:\Program Files\Java\jdk1.5.0_21\lib>mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.5.0 -Dpackaging=jar -Dfile=tools.jar

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [install:install-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [install:install-file {execution: default-cli}]
[INFO] Installing C:\Program Files\Java\jdk1.5.0_21\lib\tools.jar to C:\Users\sky\.m2\repository\com\sun\tools\1.5.0\tools-1.5.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Oct 19 16:41:56 CST 2011
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------


[color=red][i]5.某些jsp页面报如下错误[/i][/color]

Multiple annotations found at this line:
- javax.servlet.jsp.JspException cannot be resolved to a type
- javax.servlet.jsp.PageContext cannot be resolved to a type


解决方法:
修改pom.xml,添加jsp-api-2.1.jar
Add->javax.servlet.jsp->jsp-api:2.1:jar[provided]

[color=red][i]6.执行Maven install报如下错误[/i][/color]

[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.0.6:start (start-container) on project light: Execution start-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.0.6:start failed: Failed to download [http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.zip]: java.net.SocketException: Connection reset -> [Help 1]


解决方法:
主要是通过代理访问有问题,试了很多办法设置代理都没有解决,后来在没有代理的环境下成功运行一次,然后在有代理的环境再运行也不会报错了。所需包和配置文件已经准备好,以后运行就不需要代理访问外网了。

Tomcat下载到以下目录:
C:\Users\sky\AppData\Local\Temp\cargo\installs

[color=red][i]7.创建appfuse-basic-struts-archetype工程后使用mvn eclipse:eclipse报错[/i][/color]
报错信息:

[INFO] Request to merge when 'filtering' is not identical. Original=resource target/resources: output=target/classes, include=[], exclude=[**/*.java], test=false, filtering=true, merging with=resource target/resources: output=target/classes, include=[], exclude=[**/*.java], test=false, filtering=false


解决方法:
eclipse插件2.7和2.8有bug,使用2.6即可
1>mvn org.apache.maven.plugins:maven-eclipse-plugin:2.6:eclipse
2>修改工程pom.xml

<build>
<defaultGoal>install</defaultGoal>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</build>

3>在工程目录下执行 mvn eclipse:eclipse

[color=red][i]8.appfuse-basic-struts-archetype工程中使用mvn install,有些jar无法安装[/i][/color]
问题描述:
以下jar无法下载:
plexus-utils-1.5.1.jar
surefire-api-2.4.3.jar
surefire-booter-2.4.3.jar
junit-4.0.jar
解决方法:
在[url]www.findjar.com[/url]找到所需jar包,下载到本地,然后使用mvn安装

mvn install:install-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-booter -Dversion=2.4.3 -Dpackaging=jar -Dfile=E:\software\dev\Maven\appfuse_basic_struts_missing_jar\surefire-booter-2.4.3.jar
mvn install:install-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-api -Dversion=2.4.3 -Dpackaging=jar -Dfile=E:\software\dev\Maven\appfuse_basic_struts_missing_jar\surefire-api-2.4.3.jar
mvn install:install-file -DgroupId=org.codehaus.plexus -DartifactId=plexus-utils -Dversion=1.5.1 -Dpackaging=jar -Dfile=E:\software\dev\Maven\appfuse_basic_struts_missing_jar\plexus-utils-1.5.1.jar
mvn install:install-file -DgroupId=junit -DartifactId=junit -Dversion=4.0 -Dpackaging=jar -Dfile=E:\software\dev\Maven\appfuse_basic_struts_missing_jar\junit-4.0.jar


[color=red][i]9.appfuse-basic-struts-archetype工程中使用mvn install,test报错[/i][/color]
错误描述:
ERROR - JDBCExceptionReporter.logExceptions(234) | Duplicate entry 'matt@raibledesigns.com' for key 'email'
ERROR - AbstractFlushingEventListener.performExecutions(324) | Could not synchronize database state with session

解决方法:
有人已经提交了该bug,回复是不修改,参见下面链接
[url]http://issues.appfuse.org/browse/APF-1253[/url]

[color=red][i]10.关于ojdbc14.jar[/i][/color]
错误描述:
Could not find artifact com.oracle:ojdbc14:jar:10.2.0.4.0 in central

解决方法:
网上有很多人已经说了原因及解决方法,因为版权问题,Maven库不能发布ojdbc14.jar。可以通过手工安装的方法,将ojdbc14.jar安装到本地库。
>mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14-Dversion=10.2.0.4.0 -Dpackaging=jar -Dfile=E:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar

但是如果手工安装之后还是不好使怎么办,按照以下步骤操作即可:
1>删除以下的文件夹和文件
.m2\repository\com\oracle\ojdbc14\10.2.0.4.0
.m2\repository\com\oracle\ojdbc14\maven-metadata-local.xml
2>按照上面的方法重新手动安装ojdbc14.jar

[color=red][i]11.下载jar包对应源代码[/i][/color]
mvn dependency:sources

下一篇地址:[url]http://up2pu.iteye.com/blog/1254093[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值