我的问题与"Cycle detected while trying to load class"
启动jpa-only bundle
.
我创建了一个JPA
带有 maven 原型的包,并将其修改pom.xml
为与Karaf (4.0.1), Aries Blueprint, MySQL, OpenJPA, OpenJDK 1.8.
使用添加的 eclipse-tooling 生成的实体类一起使用persistence.xml
。
我能够编译它并将其安装在 Karaf 上而不会出错。启动捆绑包时出现错误。这个类运行良好Karaf 2.x (Geronimo App Server).
我怀疑它可能与@OneToMany/@ManyToOne
类中的带注释字段有关,因为如果我只生成一个没有连接的类,捆绑就完美地开始了。我也尝试pax-jdbc-mysql
了方法(不使用蓝图),但除了dataSource
成功创建之外,结果相同。我的课程只有jpa
注释。
捆绑包结构如下:
bse.jpa\
- src/main/java/mycustom-path/entities
- src/main/resources/META-INF
MANIFEST.MF
persistence.xml
- src/main/resources/OSGI-INF/blueprint
datasource.xml
类定义示例:
@Entity
@Table(name="business_entities")
@NamedQuery(name="BusinessEntity.findAll", query="SELECT b FROM BusinessEntity b")
public class BusinessEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(unique=true, nullable=false)
private Integer identity;
@Column(length=1000)
private String address;
@Column(length=150)
private String city;
@Column(length=1000)
private String comments;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="date_created")
private Date dateCreated;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="date_updated")
private Date dateUpdated;
@Column(length=200)
private String description;
@Column(length=75)
private String email;
@Column(length=45)
private String fax;
private Integer idcompany;
private Integer idcountry;
private Integer iduser;
@Column(name="iduser_updated")
private Integer iduserUpdated;
@Column(length=200)
private String name;
@Column(length=45)
private String phone;
@Column(length=45)
private String postalcode;
@Column(name="tax_id", length=20)
private String taxId;
@Column(length=500)
private String website;
//bi-directional many-to-one association to BusinessEntityContact
@OneToMany(mappedBy="businessEntity")
private List<BusinessEntityContact> businessEntityContacts;
//bi-directional many-to-one association to CustomerExtInfo
@OneToMany(mappedBy="businessEntity")
private List<CustomerExtInfo> customerExtInfos;
//bi-directional many-to-many association to EntityCategory
@ManyToMany(mappedBy="businessEntities")
private List<EntityCategory> entityCategories;
//bi-directional many-to-one association to EntityAccount
@OneToMany(mappedBy="businessEntity")
private List<EntityAccount> entityAccounts;
//bi-directional many-to-one association to ProviderExtInfo
@OneToMany(mappedBy="businessEntity")
private List<ProviderExtInfo> providerExtInfos;
public BusinessEntity() {
}
public Integer getIdentity() {
return this.identity;
}
public void setIdentity(Integer identity) {
this.identity = identity;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;
}
public String getComments() {
return this.comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public Date getDateCreated() {
return this.dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
public Date getDateUpdated() {
return this.dateUpdated;
}
public void setDateUpdated(Date dateUpdated) {
this.dateUpdated = dateUpdated;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFax() {
return this.fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public Integer getIdcompany() {
return this.idcompany;
}
public void setIdcompany(Integer idcompany) {
this.idcompany = idcompany;
}
public Integer getIdcountry() {
return this.idcountry;
}
public void setIdcountry(Integer idcountry) {
this.idcountry = idcountry;
}
public Integer getIduser() {
return this.iduser;
}
public void setIduser(Integer iduser) {
this.iduser = iduser;
}
public Integer getIduserUpdated() {
return this.iduserUpdated;
}
public void setIduserUpdated(Integer iduserUpdated) {
this.iduserUpdated = iduserUpdated;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return this.phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPostalcode() {
return this.postalcode;
}
public void setPostalcode(String postalcode) {
this.postalcode = postalcode;
}
public String getTaxId() {
return this.taxId;
}
public void setTaxId(String taxId) {
this.taxId = taxId;
}
public String getWebsite() {
return this.website;
}
public void setWebsite(String website) {
this.website = website;
}
public List<BusinessEntityContact> getBusinessEntityContacts() {
return this.businessEntityContacts;
}
public void setBusinessEntityContacts(List<BusinessEntityContact> businessEntityContacts) {
this.businessEntityContacts = businessEntityContacts;
}
public BusinessEntityContact addBusinessEntityContact(BusinessEntityContact businessEntityContact) {
getBusinessEntityContacts().add(businessEntityContact);
businessEntityContact.setBusinessEntity(this);
return businessEntityContact;
}
public BusinessEntityContact removeBusinessEntityContact(BusinessEntityContact businessEntityContact) {
getBusinessEntityContacts().remove(businessEntityContact);
businessEntityContact.setBusinessEntity(null);
return businessEntityContact;
}
public List<CustomerExtInfo> getCustomerExtInfos() {
return this.customerExtInfos;
}
public void setCustomerExtInfos(List<CustomerExtInfo> customerExtInfos) {
this.customerExtInfos = customerExtInfos;
}
public CustomerExtInfo addCustomerExtInfo(CustomerExtInfo customerExtInfo) {
getCustomerExtInfos().add(customerExtInfo);
customerExtInfo.setBusinessEntity(this);
return customerExtInfo;
}
public CustomerExtInfo removeCustomerExtInfo(CustomerExtInfo customerExtInfo) {
getCustomerExtInfos().remove(customerExtInfo);
customerExtInfo.setBusinessEntity(null);
return customerExtInfo;
}
public List<EntityCategory> getEntityCategories() {
return this.entityCategories;
}
public void setEntityCategories(List<EntityCategory> entityCategories) {
this.entityCategories = entityCategories;
}
public List<EntityAccount> getEntityAccounts() {
return this.entityAccounts;
}
public void setEntityAccounts(List<EntityAccount> entityAccounts) {
this.entityAccounts = entityAccounts;
}
public EntityAccount addEntityAccount(EntityAccount entityAccount) {
getEntityAccounts().add(entityAccount);
entityAccount.setBusinessEntity(this);
return entityAccount;
}
public EntityAccount removeEntityAccount(EntityAccount entityAccount) {
getEntityAccounts().remove(entityAccount);
entityAccount.setBusinessEntity(null);
return entityAccount;
}
public List<ProviderExtInfo> getProviderExtInfos() {
return this.providerExtInfos;
}
public void setProviderExtInfos(List<ProviderExtInfo> providerExtInfos) {
this.providerExtInfos = providerExtInfos;
}
public ProviderExtInfo addProviderExtInfo(ProviderExtInfo providerExtInfo) {
getProviderExtInfos().add(providerExtInfo);
providerExtInfo.setBusinessEntity(this);
return providerExtInfo;
}
public ProviderExtInfo removeProviderExtInfo(ProviderExtInfo providerExtInfo) {
getProviderExtInfos().remove(providerExtInfo);
providerExtInfo.setBusinessEntity(null);
return providerExtInfo;
}
}
我得到的错误是:
2017-12-08 07:30:22,514 | ERROR | lixDispatchQueue | container | 108 - org.apache.aries.jpa.container - 2.6.1 | FrameworkEvent ERROR - org.apache.aries.jpa.container
org.osgi.framework.hooks.weaving.WeavingException: Weaving failure on class cbn.bse.jpa.persistence.entities.EntityAccount in bundle bse.jpa/1.0.0.SNAPSHOT using transformer org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl@4d3cfedd
at org.apache.aries.jpa.container.weaving.impl.JPAWeavingHook.transformClass(JPAWeavingHook.java:101)[108:org.apache.aries.jpa.container:2.6.1]
at org.apache.aries.jpa.container.weaving.impl.JPAWeavingHook.weave(JPAWeavingHook.java:65)[108:org.apache.aries.jpa.container:2.6.1]
at org.apache.felix.framework.util.SecureAction.invokeWeavingHook(SecureAction.java:1203)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.transformClass(BundleWiringImpl.java:2370)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2057)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1518)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:79)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1958)[org.apache.felix.framework-5.6.4.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_151]
at java.lang.Class.forName0(Native Method)[:1.8.0_151]
at java.lang.Class.forName(Class.java:348)[:1.8.0_151]
at org.apache.openjpa.meta.MetaDataRepository.classForName(MetaDataRepository.java:1559)[165:org.apache.openjpa:2.4.1]
at org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypesInternal(MetaDataRepository.java:1535)[165:org.apache.openjpa:2.4.1]
at org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypes(MetaDataRepository.java:1513)[165:org.apache.openjpa:2.4.1]
at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:279)[165:org.apache.openjpa:2.4.1]
at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:235)[165:org.apache.openjpa:2.4.1]
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:211)[165:org.apache.openjpa:2.4.1]
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:154)[165:org.apache.openjpa:2.4.1]
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:226)[165:org.apache.openjpa:2.4.1]
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:153)[165:org.apache.openjpa:2.4.1]
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.getProperties(EntityManagerFactoryImpl.java:108)[165:org.apache.openjpa:2.4.1]
at org.apache.aries.jpa.support.osgi.impl.EMFTracker.getTransactionType(EMFTracker.java:96)[109:org.apache.aries.jpa.support:2.6.1]
at org.apache.aries.jpa.support.osgi.impl.EMFTracker.addingService(EMFTracker.java:78)[109:org.apache.aries.jpa.support:2.6.1]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)[org.osgi.core-6.0.0.jar:]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)[org.osgi.core-6.0.0.jar:]
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[org.osgi.core-6.0.0.jar:]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)[org.osgi.core-6.0.0.jar:]
at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)[org.osgi.core-6.0.0.jar:]
at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4579)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.Felix.registerService(Felix.java:3571)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:355)[org.apache.felix.framework-5.6.4.jar:]
at org.apache.aries.jpa.container.impl.ManagedEMF.createAndPublishEMF(ManagedEMF.java:132)[108:org.apache.aries.jpa.container:2.6.1]
at org.apache.aries.jpa.container.impl.ManagedEMF.updated(ManagedEMF.java:125)[108:org.apache.aries.jpa.container:2.6.1]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[3:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[3:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)[3:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1463)[3:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1419)[3:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)[3:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)[3:org.apache.felix.configadmin:1.8.14]
at java.lang.Thread.run(Thread.java:748)[:1.8.0_151]
Caused by: <openjpa-2.4.1-r422266:1730418 nonfatal general error> org.apache.openjpa.util.GeneralException: cbn/bse/jpa/persistence/entities/EntityAccount
at org.apache.openjpa.enhance.PCClassFileTransformer.transform0(PCClassFileTransformer.java:172)
at org.apache.openjpa.enhance.PCClassFileTransformer.transform(PCClassFileTransformer.java:128)
at org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl.transform(PersistenceProviderImpl.java:292)
at org.apache.aries.jpa.container.weaving.impl.JPAWeavingHook.transformClass(JPAWeavingHook.java:86)[108:org.apache.aries.jpa.container:2.6.1]
... 44 more
Caused by: java.lang.NoClassDefFoundError: cbn/bse/jpa/persistence/entities/EntityAccount
at java.lang.Class.getDeclaredMethods0(Native Method)[:1.8.0_151]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)[:1.8.0_151]
at java.lang.Class.getDeclaredMethods(Class.java:1975)[:1.8.0_151]
at org.apache.openjpa.lib.util.J2DoPrivHelper$9.run(J2DoPrivHelper.java:334)
at org.apache.openjpa.lib.util.J2DoPrivHelper$9.run(J2DoPrivHelper.java:332)
at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_151]
at org.apache.openjpa.persistence.PersistenceMetaDataDefaults.determineImplicitAccessType(PersistenceMetaDataDefaults.java:366)
at org.apache.openjpa.persistence.PersistenceMetaDataDefaults.determineAccessType(PersistenceMetaDataDefaults.java:332)
at org.apache.openjpa.persistence.PersistenceMetaDataDefaults.populate(PersistenceMetaDataDefaults.java:274)
at org.apache.openjpa.meta.MetaDataRepository.addMetaData(MetaDataRepository.java:921)
at org.apache.openjpa.meta.MetaDataRepository.addMetaData(MetaDataRepository.java:906)
at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.getMetaData(AnnotationPersistenceMetaDataParser.java:756)
at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseClassAnnotations(AnnotationPersistenceMetaDataParser.java:544)
at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parse(AnnotationPersistenceMetaDataParser.java:414)
at org.apache.openjpa.persistence.PersistenceMetaDataFactory.load(PersistenceMetaDataFactory.java:259)
at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:587)
at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:397)
at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:389)
at org.apache.openjpa.meta.ValueMetaDataImpl.resolveDeclaredType(ValueMetaDataImpl.java:487)
at org.apache.openjpa.meta.ValueMetaDataImpl.resolve(ValueMetaDataImpl.java:466)
at org.apache.openjpa.meta.FieldMetaData.resolve(FieldMetaData.java:1883)
at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1874)
at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1808)
at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:829)
at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:726)
at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:650)
at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:418)
at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:389)
at org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:286)
at org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:257)
at org.apache.openjpa.enhance.PCClassFileTransformer.transform0(PCClassFileTransformer.java:151)
... 47 more
Caused by: java.lang.ClassNotFoundException: Cycle detected while trying to load class: cbn.bse.jpa.persistence.entities.EntityAccount
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1980)[org.apache.felix.framework-5.6.4.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_151]
... 78 more
我正在使用的 pom.xml 是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>bse.persistence</artifactId>
<groupId>bse.persistence</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>bse.jpa</groupId>
<artifactId>bse.jpa</artifactId>
<packaging>bundle</packaging>
<name>bse.jpa Bundle</name>
<description>bse.jpa OSGi bundle project.</description>
<properties>
<maven-bundle-plugin.version>3.3.0</maven-bundle-plugin.version>
<osgi.version>5.0.0</osgi.version>
</properties>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>${osgi.version}</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.enterprise</artifactId>
<version>${osgi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.4.1</version>
<type>bundle</type>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.1</version>
<type>bundle</type>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<archive>
<manifestEntries>
<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
<Bundle-Blueprint>OSGI-INF/blueprint/*.xml</Bundle-Blueprint>
</manifestEntries>
</archive>
<manifestLocation>src/main/resources/META-INF</manifestLocation>
<rebuildBundle>true</rebuildBundle>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>bse.jpa.Activator</Bundle-Activator>
<Import-Package>com.mysql.jdbc.jdbc2.optional,
javax.sql,
javax.persistence;version=2.0,
javax.persistence.metamodel,
javax.transaction,
javax.transaction.xa,
org.osgi.framework</Import-Package>
<Export-Package>cbn.bse.jpa.persistence.entities,
bse.jpa
</Export-Package>
<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
<Bundle-ManifestVersion>2</Bundle-ManifestVersion>
<Include-Resource>src/main/resources</Include-Resource>
<Bundle-Blueprint>OSGI-INF/blueprint/*.xml</Bundle-Blueprint>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<maxmem>256M</maxmem>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<includes>cbn/bse/jpa/persistence/entities/**/*.class</includes>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
蓝图文件:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" id="sssDataSource" >
<property name="serverName" value="localhost"></property>
<property name="databaseName" value="rrrr"></property>
<property name="port" value="3306"></property>
<property name="user" value="yyyy"></property>
<property name="password" value="xxxxx"></property>
</bean>
<!-- javax.sql.DataSource -->
<service id="bseDSService" interface="javax.sql.DataSource" ref="sssDataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/rrrr" />
</service-properties>
</service>
</blueprint>
提前致谢!!