jboss7.1.1 部署
前2个步骤实际上与Broadleaf无关,但是提到该步骤是为了使其易于执行(复制/粘贴)这些步骤。
步骤#1:在JBoss AS中配置数据源。
<datasource jta="true" jndi-name="java:jboss/datasources/BroadleafDS" pool-name="BroadleafDS_Pool" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/broadleaf</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>admin</password>
</security>
<timeout>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>600</query-timeout>
</timeout>
</datasource>
<datasource jta="true" jndi-name="java:jboss/datasources/BroadleafSecureDS" pool-name="BroadleafSecureDS_Pool" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/broadleaf</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>admin</password>
</security>
<timeout>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>600</query-timeout>
</timeout>
</datasource>
<datasource jta="true" jndi-name="java:jboss/datasources/BroadleafCmsDS" pool-name="BroadleafCmsDS_Pool" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/broadleaf</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>admin</password>
</security>
<timeout>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>600</query-timeout>
</timeout>
</datasource>
步骤2:按照以下步骤更新
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="blPU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:jboss/datasources/BroadleafDS</non-jta-data-source>
<exclude-unlisted-classes/>
</persistence-unit>
<persistence-unit name="blSecurePU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:jboss/datasources/BroadleafSecureDS</non-jta-data-source>
<exclude-unlisted-classes/>
</persistence-unit>
<persistence-unit name="blCMSStorage" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:jboss/datasources/BroadleafCmsDS</non-jta-data-source>
<exclude-unlisted-classes/>
</persistence-unit>
</persistence>
步骤#3:如下更新site / src / main / webapp / WEB-INF / applicationContext.xml:
<bean id="blMergedDataSources" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map>
<entry key="java:jboss/datasources/BroadleafDS" value-ref="webDS"/>
<entry key="java:jboss/datasources/BroadleafSecureDS" value-ref="webSecureDS"/>
<entry key="java:jboss/datasources/BroadleafCmsDS" value-ref="webStorageDS"/>
</map>
</property>
</bean>
现在,如果您部署该应用程序,将出现以下错误:
错误创建在从字节数组加载的资源中定义的名称为'blMergedDataSources'的bean时出错:使用键[TypedStringValue:value,目标类型[null]]设置bean属性'sourceMap'时,无法解析对bean'webDS'的引用; 嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为'webDS'的bean时出错:FactoryBean对象的后处理失败; 嵌套异常是java.lang.IllegalArgumentException:警告此类型名称不匹配:org.broadleafcommerce.profile.core.service.CustomerAddressService [Xlint:invalidAbsoluteTypeName]
步骤#4:在site / src / main / webapp / WEB-INF /文件夹中创建
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
<module name="org.jboss.ironjacamar.jdbcadapters" />
</dependencies>
<exclusions>
<module name="org.apache.commons.logging"/>
<module name="org.apache.log4j"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.logmanager.log4j"/>
<module name="org.slf4j"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
现在,如果您尝试部署应用程序,则将收到以下错误,因为JBossAS7随Hibernate4一起提供,并且应用程序正在使用某些hibernate3功能。
@CollectionOfElements
@JoinTable(name = "BLC_CATEGORY_IMAGE", joinColumns = @JoinColumn(name = "CATEGORY_ID"))
@MapKey(columns = { @Column(name = "NAME", length = 5, nullable = false) })
@Column(name = "URL")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region="blStandardElements")
@BatchSize(size = 50)
@Deprecated
protected Map<String, String> categoryImages = new HashMap<String, String>(10);
org.hibernate.MappingException:无法确定类型:java.util.Map,在表:BLC_CATEGORY,对于列:[org.hibernate.mapping.Column(URL)]
因此,让我们在JBossAS7中安装hibernate3模块并使用它。
步骤#5:在JBoss AS 7中安装Hibernate 3模块。
将以下jar(可从site.war文件中获取)复制到jboss-as-7.1.1.FINAL/modules/org/hibernate/3/文件夹中。
antlr-2.7.6.jar
commons-collections-3.2.1.jar
dom4j-1.6.1.jar
hibernate-commons-annotations-3.2.0.Final.jar
hibernate-core-3.6.10.Final.jar
hibernate-entitymanager-3.6.10.Final.jar
javassist-3.16.1-GA.jar
在jboss-as-7.1.1.FINAL/modules/org/hibernate/3/文件夹中创建module.xml 。
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.hibernate" slot="3">
<resources>
<resource-root path="hibernate-core-3.6.10.Final.jar"/>
<resource-root path="javassist-3.16.1-GA.jar"/>
<resource-root path="antlr-2.7.6.jar"/>
<resource-root path="commons-collections-3.2.1.jar"/>
<resource-root path="dom4j-1.6.1.jar"/>
<!-- Insert other Hibernate 3 jars to be used here -->
<resource-root path="hibernate-commons-annotations-3.2.0.Final.jar"/>
<resource-root path="hibernate-entitymanager-3.6.10.Final.jar"/>
</resources>
<dependencies>
<module name="org.jboss.as.jpa.hibernate" slot="3"/>
<module name="asm.asm"/>
<module name="javax.api"/>
<module name="javax.persistence.api"/>
<module name="javax.transaction.api"/>
<module name="javax.validation.api"/>
<!-- <module name="org.apache.ant"/> -->
<module name="org.infinispan" optional="true"/>
<module name="org.javassist"/>
<module name="org.slf4j"/>
</dependencies>
</module>
更新core / src / main / resources / META-INF / persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="blPU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:jboss/datasources/BroadleafDS</non-jta-data-source>
<exclude-unlisted-classes/>
<properties>
<property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />
<property name="jboss.as.jpa.managed" value="false" />
</properties>
</persistence-unit>
<persistence-unit name="blSecurePU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:jboss/datasources/BroadleafSecureDS</non-jta-data-source>
<exclude-unlisted-classes/>
<properties>
<property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />
<property name="jboss.as.jpa.managed" value="false" />
</properties>
</persistence-unit>
<persistence-unit name="blCMSStorage" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:jboss/datasources/BroadleafCmsDS</non-jta-data-source>
<exclude-unlisted-classes/>
<properties>
<property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />
<property name="jboss.as.jpa.managed" value="false" />
</properties>
</persistence-unit>
</persistence>
翻译自: https://www.javacodegeeks.com/2013/05/deploying-broadleafcommerce-2-0-on-jboss-as-7.html
jboss7.1.1 部署