|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 6
java.lang.IllegalArgumentException: URI is not hierarchical
at java.io.File.<init>(File.java:335)
at oracle.toplink.essentials.ejb.cmp3.persistence.ArchiveFactoryImpl.createArchive
(ArchiveFactoryImpl.java:104)
This exception can be traced to the fact that the WebLogic server sends incorrect URLs to TopLink Essentials. Specifically,
the URLs have the form of jar:file:c/:something.jar. According to the URI specification, this is an invalid URI because no / precedes the schema (jar:file:) definition. In all cases the URI is determined to be opaque and is thus unacceptable for the java.io.File(URI) constructor.
The solution is to change the following line of code in [WebLogic's] createArchive(URL):
File f = new File(uri);
to:
File f;
if (!uri.isOpaque()) {
f = new File(uri);
} else {
f = new File(url.getPath()):
}
To perform Data Manipulation Language (DML) operations using TopLink Essentials on a WebLogic server, you also need a transaction controller, such as the one shown in Listing 1:
import javax.transaction.TransactionManager;
import oracle.toplink.essentials.transaction.JTATransactionController;
public class WebLogicTransactionController extends JTATransactionController {
private static final String JNDI_TRANSACTION_MANAGER_NAME =
"javax.transaction.TransactionManager";
public WebLogicTransactionController() {
}
protected TransactionManager acquireTransactionManager() throws Exception {
return (TransactionManager)jndiLookup(JNDI_TRANSACTION_MANAGER_NAME);
}
}
You must register the WebLogicTransactionController class in the persistence.xml file, as shown in Listing 2:
<?xml version="1.0" encoding="windows-1252" ?>
<persistence ...>
<persistence-unit name="JavaWorld">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
...
<properties>
<property name="toplink.logging.level" value="FINE"/>
<property name="toplink.target-database" value="Oracle"/>
<property name="toplink.cache.shared.default" value="false"/>
<property name="toplink.target-server"
value="model.utils.WebLogicTransactionController"/>
</properties>
</persistence-unit>
</persistence>
The code that Listing 2 adds to the persistence.xml file defines a persistence unit named JavaWorld. The file also defines a provider -- in this case TopLink Essentials -- and some properties to configure the provider. The
toplink.target-server property tells the provider it will be deployed on a certain server, in this case WebLogic server.
Every application using a persistent state must interact with the persistence provider when the state held in memory must
be propagated to the database (or vice versa). In other words, the persistence provider's interface must be used in order
to store and load objects. This interface is the EntityManager. Each EntityManager instance is associated with a persistence context. A persistence context can be viewed as a sort of cache that keeps track of which objects were changed during a certain transaction.
The persistence context is invisible to the application; that is, it's not an API that can be called.