我有一个具有以下结构的persistence.xml:
<persistence-unit name="contacts_nosql" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:comp/env/jdbc/MY_DS</jta-data-source>
<class>com.mydomain.model.User</class>
<properties>
<property name="eclipselink.target-database"
value="org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"/>
<property name="eclipselink.nosql.connection-spec"
value="org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec"/>
<property name="eclipselink.nosql.property.mongo.port" value="27017"/>
<property name="eclipselink.nosql.property.mongo.host" value="someurl.de"/>
<property name="eclipselink.nosql.property.mongo.db" value="mydb"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
我想通过JNDI设置属性。我认为将以下内容编写到tomcat的context.xml中就足够了:
<Resource name="jdbc/MY_DS" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="20" maxWait="10000"
username="myuser" password="mypwd"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf8"
validationQuery="SELECT 1" removeAbandoned="true" removeAbandonedTimeout="300"
/>
出于某种原因,这不起作用。
我在日志中看到了这个: 异常描述:无法从驱动程序[null],用户[null]和URL [null]获取连接。
有什么问题或我需要添加什么?