Web programming

Units WEB1P and WEB2P

Fixing persistence.xml problems

Occasionally, NetBeans's persistence unit wizard will create a corrupted persistence.xml file. We don't know why this happens, but it can be recognised in NetBeans's "Design" view of the file by the "Use Java Transaction APIs" checkbox been unchecked and greyed out so that it can't be changed.

When this happens, you can fix the problem by copying and pasting elements of a valid persistence.xml file into the one NetBeans has created.

Here is a valid one to copy:

<!--?xml version="1.0" encoding="UTF-8"?-->
<persistence version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="RelationsPU" transaction-type="JTA">
<jta-data-source>java:app/jdbc/relations</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create"></property>
</properties>
</persistence-unit>
</persistence>

The crucial elements are:

 

Last updated by Prof Jim Briggs of the School of Computing at the University of Portsmouth

 
The web programming units include some material that was formerly part of the WPRMP, WECPP, WPSSM and WEMAM units.