Win7+MySql,opentaps安装

opentaps主页上没有提供下载,要到sourceforge上去下http://sourceforge.net/projects/opentaps/

在MySql中新建opentaps
CREATE DATABASE `opentaps` /*!40100 DEFAULT CHARACTER SET utf8 */;

opentaps
修改framework\entity\config\entityengine.xml 文件

    a)找到<delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">

        <group-map group-name="org.ofbiz" datasource-name="localderby"/>(54行)的localderby修改为localmysql

    b)找到<datasource name="localmysql"  (314行)做以下修改:

       table_type="InnoDB"  修改为  Engine="InnoDB"

       character-set="lantin1"  修改为  character-set="utf8"

       collate="lantin1_general_cs"  修改为  collate="utf8_general_ci"

       jdbc-uri="jdbc:mysql://127.0.0.1/ofbiz?autoReconnect=true&amp;useOldAliasMetadataBehavior=true"  中的ofbiz修改为opentaps   //opentaps为创建的数据库名字

       jdbc-username="ofbiz"  和  jdbc-password="ofbiz"  中的ofbiz修改为mysql上创建了的用户名和密码

     c)修改build.properties文件,把里面的内存值减小一半(如果内存是4G以上就不用修改了)

     d)把 \framework\webapp\src\org\ofbiz\webapp\controlfor\ConfigXMLReader.java文件中的 81行 

       for (String a : url.toString().split(File.seperator)) {   中File.seperator修改为 "/"

 e)打开\opentaps\opentaps\opentaps-common\build-aspects.xml文件,将以下三行注释掉

      <jar jarfile="${ofbiz.dir}/framework/entity/build/lib/ofbiz-entity.jar" update="true" basedir="${build.dir}/classes/" includes="META-INF/aop.xml" />

      <jar jarfile="${ofbiz.dir}/framework/common/build/lib/ofbiz-common.jar" update="true" basedir="${build.dir}/classes/" includes="META-INF/aop.xml" />

      <jar jarfile="${ofbiz.dir}/applications/order/build/lib/ofbiz-order.jar" update="true" basedir="${build.dir}/classes/" includes="META-INF/aop.xml" />

      f) 如果Mysql 版本太低,会导致表无法创建, 解决方法如下
  framework\entity\src\org\ofbiz\entity\jdbc下的DatabaseUtil.java
  将createTable方法中的
    if (UtilValidate.isNotEmpty(this.datasourceInfo.tableType)) {
            sqlBuf.append(" TYPE ");
            sqlBuf.append(this.datasourceInfo.tableType);
        }
  中的TYPE修改为ENGINE
cmd命令行,到解压后的opentaps目录中,执行ant run-install
得到
BUILD SUCCESSFUL
Total time: 22 minutes 33 seconds

修改startofbiz.bat,把内存值修改为256M,512M,512M(如果是4G内存,则不用改)

在CMD命令行中键入startofbiz.bat等待...。出现connectorservlet successful initialized说明运行成功。
在浏览器中键入:http://localhost:8080/opentaps
出现登陆界面后用户名是admin,密码是opentaps。如果密码不对的话,可以到mysql中去查看user_login表,表上有用户名和密码。

遇到问题:
ant run-install安装都没有问题,提示:BUILD SUCCESSFUL
可是启动服务时:
E:\Setup\opentaps>startofbiz.bat
E:\Setup\opentaps>echo off
E:\Setup\opentaps>"D:\Program Files\Java\jdk1.6.0_43\bin\java" -Xms256M -Xmx768M
 -XX:MaxPermSize=512M -jar ofbiz.jar  1>runtime\logs\console.log
就报错:
E:\Setup\opentaps>"D:\Program Files\Java\jdk1.6.0_43\bin\java" -Xms256M -Xmx768M
 -XX:MaxPermSize=512M -jar ofbiz.jar  1>runtime\logs\console.log
org.ofbiz.base.start.StartupException: Cannot start() org.ofbiz.base.container.NamingServiceContainer (Unable to locate naming service (Port already in use: 1099; nested exception is:
打开untime\logs\console.log,找到第一个错误:
L:164
2013-03-26 18:53:04,787 (main) [       DatabaseUtil.java:1061:ERROR] Unable to establish a connection with the database... Error was:java.sql.SQLException: Unable to acquire a new connection from the pool
jdbc-username="ofbiz"  和  jdbc-password="ofbiz"  中的ofbiz修改为mysql上创建了的用户名和密码
还有错,再看:
L:207
2013-03-26 19:13:08,681 (main) [       DatabaseUtil.java:353:ERROR] Could not create table [ACCOMMODATION_CLASS]: SQL Exception while executing the following:
CREATE TABLE ACCOMMODATION_CLASS (ACCOMMODATION_CLASS_ID VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, PARENT_CLASS_ID VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci, DESCRIPTION VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci, LAST_UPDATED_STAMP DATETIME, LAST_UPDATED_TX_STAMP DATETIME, CREATED_STAMP DATETIME, CREATED_TX_STAMP DATETIME, CONSTRAINT PK_ACCOMMODATION_CLASS PRIMARY KEY (ACCOMMODATION_CLASS_ID)) TYPE InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
Error was: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci' at line 1
把这条长长的SQL建表语句复制到MYSQL里,看到TYPE InnoDB的TYPE下有红线,到framework\entity\config\entityengine.xml中找到
table_type="InnoDB"  修改为  Engine="InnoDB"
再执行,通过了.
收获,总结:命令行上的输出,有时候不够准确,要学会在console.log中找到错误原因.

 

![图片说明](https://img-ask.csdn.net/upload/201912/24/1577183334_328248.png)![图片说明](https://img-ask.csdn.net/upload/201912/24/1577183463_24927.png) **一按登录就出现500,说jdbc连接失败,求求大佬** Type Exception Report Message JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [null]; error code [0]; Unable to acquire JDBC Connection; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception org.springframework.orm.hibernate5.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [null]; error code [0]; Unable to acquire JDBC Connection; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:254) org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:388) org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:347) org.springframework.orm.hibernate5.HibernateTemplate.find(HibernateTemplate.java:831) com.dao.impl.UserDaoImpl.findByName(UserDaoImpl.java:43) com.struts.action.LoginServiceAction.execute(LoginServiceAction.java:45) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:873) ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1539) ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
连接不上我的mysql数据库,但是我单独测试又可以连接上,测试代码如下: Connection conn = null; Statement stmt = null; ResultSet rs = null; try { Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://localhost:3306/shi"; String name = "root"; String password = "root"; conn = DriverManager.getConnection(url, name, password); String sql = "select * from t_user"; stmt = conn.createStatement(); rs = stmt.executeQuery(sql); while(rs.next()) { String username = rs.getString("name"); System.out.println(username); } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { if(rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } } if(stmt != null) { try { stmt.close(); } catch (SQLException e) { e.printStackTrace(); } } if(rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } } } 但是使用c3p0的时候就出问题了: c3p0的配置如下: <?xml version="1.0" encoding="UTF-8"?> <c3p0-config> <default-config> <property name="jdbcUrl">jdbc:mysql://localhost:3306/shi?useUnicode=true&characterEncoding=utf8</property> <property name="driverClass">com.mysql.jdbc.Driver</property> <property name="user">root</property> <property name="password">root</property> <!-- <property name="jdbcUrl">jdbc:oracle:thin:@localhost:1521:orcl</property> <property name="driverClass">oracle.jdbc.driver.OracleDriver</property> <property name="user">scott</property> <property name="password">tiger</property> --> <property name="c3p0.testConnectionOnCheckout">true</property> <property name="acquireIncrement">3</property> <property name="initialPoolSize">10</property> <property name="minPoolSize">2</property> <property name="maxPoolSize">10</property> </default-config> </c3p0-config> 出现的异常如下: kate Tom 2014-8-9 9:31:05 com.mchange.v2.log.MLog 信息: MLog clients using java 1.4+ standard logging. 2014-8-9 9:31:06 com.mchange.v2.c3p0.C3P0Registry 信息: Initializing c3p0-0.9.5-pre8 [built 04-April-2014 04:20:15 -0700; debug? true; trace: 10] 2014-8-9 9:31:06 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource 信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 2sa1hd931f5tqer1kt6lht|2c766a24, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> null, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceUseNamedDriverClass -> false, identityToken -> 2sa1hd931f5tqer1kt6lht|2c766a24, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> null, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ] 2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool 警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@6c3b78cf -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: java.lang.NullPointerException at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507) at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476) at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307) at java.sql.DriverManager.getDriver(DriverManager.java:253) at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:278) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:158) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1814) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) 2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool 警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5c1fe88d is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests. 2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool 警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@53416c84 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: java.lang.NullPointerException at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507) at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476) at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307) at java.sql.DriverManager.getDriver(DriverManager.java:253) at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:278) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:158) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1814) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) java.sql.SQLException: Connections could not be acquired from the underlying database! at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:690) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140) at jdbcUtils.JdbcUtils.getConnection(JdbcUtils.java:44) at jdbcUtils.TestUtils.main(TestUtils.java:59) Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source. at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1422) at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:606) at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:526) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:756) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:683) ... 3 more 2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool 警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5c1fe88d is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests. 2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool 警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@58a2353d -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: java.lang.NullPointerException at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507) at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476) at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307) at java.sql.DriverManager.getDriver(DriverManager.java:253) at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:278) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:158) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1814) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) 2014-8-9 9:31:36 com.mchange.v2.resourcepool.BasicResourcePool 警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5c1fe88d is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页