我们正在尝试在 Rhel Linux 上的 Tomcat 7 上使用一个数据库(worklight)在我们的服务器上手动安装 worklight 5.06 企业版。我们运行了 create-worklight-oracle.sql 脚本,并按照http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m6/index.jsp?topic=%2Fcom.ibm.worklight.help上的说明进行操作.doc%2Fadmin%2Fc_installation.html
但仍然遇到一些问题。具体来说,我们的 tomcat 与 worklight DB 对话的配置文件似乎存在问题:
SEVERE: com.worklight.server.bundle.project.messages:logger.projectStartFailed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txManager' defined in URL [jar:file:/usr/share/java/tomcat7/worklight-jee-library.jar!/conf/core.xml]: Cannot resolve reference to bean 'brokerSessionFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brokerSessionFactory' defined in URL [jar:file:/usr/share/java/tomcat7/worklight-jee-library.jar!/conf/spring-server-core.xml]: Cannot resolve reference to bean 'rssBrokerDS' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'rssBrokerDS' defined in URL [jar:file:/usr/share/java/tomcat7/worklight-jee-library.jar!/conf/spring-server-core.xml]: Cannot resolve reference to bean 'worklight-direct' while setting bean property 'targetDataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'worklight-direct' defined in URL [jar:file:/usr/share/java/tomcat7/worklight-jee-library.jar!/conf/spring-server-core.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/WorklightDS] is not bound in this Context. Unable to find [jdbc].
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
可能是一些愚蠢的错误,我为数据库配置做了以下操作:在分解的 worklight.war 中添加了以下到我们的 worklight.properties:取消注释这些行:
wl.db.type=ORACLE
wl.db.url=jdbc:oracle:thin:@//DBSERVER:1521/SERVICE_NAME <-- changed from our internal names
wl.db.username=worklight
wl.db.password=worklight
在该节中为 tomcat 的 context.xml 添加了以下内容;
<Resource name="jdbc/WorklightDS"
auth="Container"
type="javax.sql.DataSource"
username="worklight"
password="worklight"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@//DBSERVER:1521/SERVICE_NAME"/>
在文件末尾的 web.xml 中添加了以下内容(在 /web-app> 结束标记之前):
<resource-ref>
<res-ref-name>jdbc/WorklightDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
可能的解决方案:问题在于使用 JNDI 连接 - 单独使用 jdbc 连接可以正常工作。