问题:
启动ofbiz项目后,访问localhost:8080/ecommerce/control/;
页面显示“A Product Store has not been defined for this ecommerce site. A Product Store can be created using the ofbizsetup wizard.”。
前提条件:
Ofbiz/framework/entity/config/entityengine.xml配置连接sql;
Ofbiz/framework/entity/lib/jdbc下存在sqljdbc4.jar包;
已经生成数据库表;
问题分析:
如果启动项目过程中控制台出现报错情况,则有可能是项目中其它原因导致,可以跳过本文章。本问题只针对启动过程无报错,但却访问不了店铺应用的情况。本情况出现的根本原因是对应的数据表无演示数据,并非系统代码问题。打开数据库执行查询语句:select * from PRODUCT_STORE,仅有一条数据,这与生成的mysql数据库对应的表有5条数据存在差异。说明在生成演示数据过程中出现问题。
解决:(参考http://ofbiz.135035.n4.nabble.com/Known-issues-using-SQL-Server-2012-td4644269.html)
更改以下配置文件:
1、applications/party/entitydef/entitymodel.xml(改unique="false")
<relation type="one" fk-name="COM_EVNT_RESENUM" rel-entity-name="Enumeration"> <key-map field-name="reasonEnumId" rel-field-name="enumId"/> </relation> <index name="COMMEVT_MSG_ID" unique="false"> <index-field name="messageId"/> </index>
<field name="verifyHash" type="value"></field> <field name="expireDate" type="date-time"></field> <prim-key field="emailAddress"/> <index name="EMAIL_VERIFY_HASH" unique="false"> <index-field name="verifyHash"/> </index>
<index name="LAST_NAME_IDX"> <index-field name="lastName"/> </index> <index name="CARD_ID_IDX" unique="false"> <index-field name="cardId"/> </index>
2、applications/product/entitydef/entitymodel.xml(改unique="false")
<relation type="one" fk-name="INV_ITEM_CUOM" title="Currency" rel-entity-name="Uom"> <key-map field-name="currencyUomId" rel-field-name="uomId"/> </relation> <index name="INVITEM_SOFID" unique="false"> <index-field name="softIdentifier"/> </index> <index name="INVITEM_ACTNM" unique="false"> <index-field name="activationNumber"/> </index> <index name="INV_ITEM_SN"> <index-field name="serialNumber"/> </index>
3、applications/marketing/entitydef/entitymodel.xml(改unique="false")
<relation type="one" fk-name="CNCT_LST_CST_ST" rel-entity-name="StatusItem"> <key-map field-name="statusId"/> </relation> <index name="CNTLSTCST_MSG_ID" unique="false"> <index-field name="messageId"/> </index>
4、applications/accounting/entitydef/entitymodel.xml(改unique="false")
<relation type="one" fk-name="GLACCT_PAR" title="Parent" rel-entity-name="GlAccount"> <key-map field-name="parentGlAccountId" rel-field-name="glAccountId"/> </relation> <index name="GLACCT_UNQCD" unique="false"> <index-field name="accountCode"/> </index>
更改这些配置文件后再重新生成数据表及数据,问题解决。从参考的文件中提及到采用jtds.jar驱动来替换sqljdbc4.jar驱动,后来通过验证,更改驱动不是必要的步骤,只需要更改以上几个配置文件,即能解决问题。
补充:
如果改用jtds驱动来连接,则需要更改Ofbiz/framework/entity/config/entityengine.xml相应的配置如下。
sqljdbc4.jar连接配置节
<datasource name="localmssql" helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" schema-name="dbo" field-type-name="mssql" check-on-start="true" add-missing-on-start="true" join-style="ansi" alias-view-columns="false" use-fk-initially-deferred="false"> <read-data reader-name="tenant"/> <read-data reader-name="seed"/> <read-data reader-name="seed-initial"/> <read-data reader-name="demo"/> <read-data reader-name="ext"/> <read-data reader-name="ext-test"/> <read-data reader-name="ext-demo"/> <inline-jdbc jdbc-driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" jdbc-uri="jdbc:sqlserver://localhost:1433;databaseName=test;SelectMethod=cursor;" jdbc-username="sa" jdbc-password="123456" isolation-level="ReadCommitted" pool-minsize="2" pool-maxsize="250" time-between-eviction-runs-millis="600000"/> <!-- <jndi-jdbc jndi-server-name="default" jndi-name="comp/env/jdbc/xa/localmssql" isolation-level="ReadCommitted"/> --> <!-- Orion Style JNDI name --> </datasource>
<datasource name="localmssql" helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" schema-name="dbo" field-type-name="mssql" check-on-start="true" add-missing-on-start="true" join-style="ansi" alias-view-columns="false" use-fk-initially-deferred="false"> <read-data reader-name="tenant"/> <read-data reader-name="seed"/> <read-data reader-name="seed-initial"/> <read-data reader-name="demo"/> <read-data reader-name="ext"/> <read-data reader-name="ext-test"/> <read-data reader-name="ext-demo"/> <inline-jdbc jdbc-driver="net.sourceforge.jtds.jdbc.Driver" jdbc-uri="jdbc:jtds:sqlserver://localhost:1433;databaseName=ofbiz;SelectMethod=cursor;" jdbc-username="sa" jdbc-password="123456" isolation-level="ReadCommitted" pool-minsize="2" pool-maxsize="250" time-between-eviction-runs-millis="600000"/> <!-- <jndi-jdbc jndi-server-name="default" jndi-name="comp/env/jdbc/xa/localmssql" isolation-level="ReadCommitted"/> --> <!-- Orion Style JNDI name --> </datasource>
经验证,两条连接方式都能正常连接。完毕