Hi,
This is the task I added into NetBeans broject's build.xml
to have classes enhanced while clean and build a project. I
can't still get daployment running with the right button
menu "Undeploy and Deploy" but building and enhancement are
fine.
To deploy I'm just using a regular <copy> task from
<PROJECT_HOME>/dist to server webapp dir.
<property name="jpa-home"
value="${user.home}/NetBeansProjects/java-libraries/apache-openjpa-1.0.1"/>
<path id="jpa.classpath">
<pathelement path="${jpa-home}/openjpa-1.0.1.jar"/>
<fileset dir="${jpa-home}/lib">
<include name="*.jar"/>
</fileset>
</path>
<taskdef name="openjpac"
classname="org.apache.openjpa.ant.PCEnhancerTask">
<classpath refid="jpa.classpath"/>
</taskdef>
<target name="-pre-dist">
<property name="jpa-home"
value="${user.home}/NetBeansProjects/java-libraries/apache-openjpa-1.0.1"/>
<openjpac>
<classpath>
<pathelement
location="${basedir}/build/web/WEB-INF/classes"/>
</classpath>
<config
propertiesFile="${basedir}/build/web/WEB-INF/classes/META-INF/persistence.xml"/>
</openjpac>
</target>
Using this task I rebuilt two application. Classes get
enhanced, I can see by the fact that built classes are a
size and distributed class are bigger and I checked via
reflection (see beloow)
----> Subscription interfaces are:
----> java.io.Serializable
---->
org.apache.openjpa.enhance.PersistenceCapable
---------------------------
162216 estePU3 INFO [http-10080-1] openjpa.Runtime -
Starting OpenJPA 1.0.1
162389 estePU3 INFO [http-10080-1] openjpa.jdbc.JDBC -
Using dictionary class
"org.apache.openjpa.jdbc.sql.PostgresDictionary".
The thing I can't understand is that una app (just
servlet/dirct + use of EntityManager) is fine, JPA doesn't
print any unespected message and performance increase is
huge. The second app is a Spring/JPA web app that uses
JpaTemplate
prints the following line:
163398 estePU3 INFO [http-10080-1] openjpa.Enhance -
Creating subclass for "[class it.lhtc.este.domain.Request]".
This means that your application will be less efficient and
will consume more memory than it would if you ran the
OpenJPA enhancer. Additionally, lazy loading will not be
available for one-to-one and many-to-one persistent
attributes in types using field access; they will be loaded
eagerly instead.
It was the message outputted when classes was just built and
context used to load classes using <Loader
loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
Now the above classloader isn't in use any more and even the
jar file has been removed from the Tomcat's lib dir.
What's missing? Any idea?
Andrea Martano
--------------
LiteHouse srl
Milano - Italy