我正在使用 Gernomino 3.0.1 尝试使用 Aries/Blueprint 的 OSGI。由于以下异常而碰壁:
2013-08-06 10:54:54,832 错误 [BlueprintContainerImpl] 无法启动捆绑包 com.xxx.xxx 的蓝图容器 org.osgi.service.blueprint.container.ComponentDefinitionException:无法实例化组件 在 org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:644) 在 org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:331) 在 org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227) 在 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) 在 java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 在 java.util.concurrent.FutureTask.run(FutureTask.java:138) 在 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) 在 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) 在 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) 在 java.lang.Thread.run(Thread.java:662) 引起:java.lang.VerifyError: (class: com/xxx.xxx/services/impl/$UserServiceImpl307032798, method: signature: (Ljava/lang/reflect/InvocationHandler;)V) 调用错误的初始化方法 在 java.lang.Class.getDeclaredConstructors0(本机方法) 在 java.lang.Class.privateGetDeclaredConstructors(Class.java:2398) 在 java.lang.Class.getConstructor0(Class.java:2708) 在 java.lang.Class.getConstructor(Class.java:1659) 在 org.apache.aries.proxy.impl.gen.ProxySubclassGenerator.newProxySubclassInstance(ProxySubclassGenerator.java:159) 在 org.apache.aries.proxy.impl.AsmProxyManager.createNewProxy(AsmProxyManager.java:81) 在 org.apache.aries.proxy.impl.AbstractProxyManager.createProxy(AbstractProxyManager.java:50) 在 org.apache.aries.blueprint.container.BeanRecipe.addInterceptors(BeanRecipe.java:688) 在 org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:728) 在 org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64) 在 org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219) 在 org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:147) 在 org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:640) ... 10 更多
我的 JDK 版本是 Ubuntu 13.04 上的 1.7.0_25-b15。
这是我的蓝图配置的样子:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
<!-- DataSource Derby -->
<bean id="dataSourceDerby" class="org.apache.derby.jdbc.EmbeddedDataSource">
<property name="databaseName" value="/home/imme/Data/xxxxdb"/>
<property name="createDatabase" value="create"/>
</bean>
<bean id="dataSourceXADerby" class="org.apache.derby.jdbc.EmbeddedXADataSource">
<property name="databaseName" value="/home/imme/Data/xxxxdb"/>
<property name="createDatabase" value="create"/>
</bean>
<!-- Expose DataSource as JNDI reference -->
<service ref="dataSourceDerby" interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/xxxxdb"/>
</service-properties>
</service>
<service ref="dataSourceXADerby" interface="javax.sql.XADataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/xaxxxxdb"/>
</service-properties>
</service>
<bean id="userServiceImpl" class="com.xxx.xxx.services.impl.UserServiceImpl">
<tx:transaction method="*" value="Required" />
<jpa:context property="entityManager" unitname="xxx-unit"/>
</bean>
<service id="userService" ref="userServiceImpl" interface="com.xxx.xxxx.services.UserService"/>
</blueprint>
如果我注释掉该行:
<tx:transaction method="*" value="Required" />
我不再看到异常,但是服务不起作用,因为容器无法打开事务。已尝试使用 JDK 1.6,同样的问题。
感谢任何帮助,谢谢!