Hi Tom,
Thanks for your prompt response. Note that the application does
function correctly on GlassFish but I'm trying to port it to WebLogic.
<pasting the relevant part of the Person class>
@NamedQueries(
{
@NamedQuery(name = "getPostedEvents",
query = "SELECT s FROM SocialEvent s WHERE s.submitterUserName =
:submitter"),
@NamedQuery(name = "getIncomingInvitations",
query = "SELECT i FROM Invitation i WHERE i.candidate.userName =
:candidate"),
@NamedQuery(name = "getOutgoingInvitations",
query = "SELECT i FROM Invitation i WHERE i.requestor.userName =
:requestor")
}
)
@Entity
@Table (name="PERSON")
public class Person implements java.io.Serializable {
private String userName;
private String password;
private String firstName;
private String lastName;
private String summary;
private String telephone;
private String email;
private String imageURL;
private String imageThumbURL;
private String timezone;
private Collection<Person> friends=new ArrayList<Person>();
private Collection<SocialEvent> socialEvents=new
ArrayList<SocialEvent>();
private Collection<Invitation> incomingInvitations=new
ArrayList<Invitation>();
private Collection<Invitation> outgoingInvitations = new
ArrayList<Invitation>();
private Address address;
//used for UI display purposes
private boolean hasReceivedInvitation;
private Collection<Person> nonFriendList = new ArrayList<Person>();
private int friendshipRequests;
........
/* The default fetch type for OneToOne is EAGER. However, for person, the
* address is not required for listing attendees in a social event.
* So we will set it to LAZY and only load it when required (in
ModelFacade).
* */
@OneToOne(cascade={CascadeType.PERSIST}, fetch=FetchType.LAZY)
public Address getAddress() {
return address;
}
.....
}
For SocialEvent, the getAddress is also similar:
public class SocialEvent implements java.io.Serializable {
private int socialEventID;
private String title;
private String submitterUserName;
private Timestamp createdTimestamp;
private Timestamp eventTimestamp;
private String summary;
private String description;
private String imageURL;
private String imageThumbURL;
private String literatureURL;
private String telephone;
private Address address;
private int totalScore;
private int numberOfVotes;
private int disabled;
private List<SocialEventTag> tags = new ArrayList<SocialEventTag>();
private Collection<Person> attendees = new ArrayList<Person>();
private Collection<CommentsRating> comments = new
ArrayList<CommentsRating>();
public SocialEvent() { }
public SocialEvent(String title, String summary, String description,
String submitterUserName, Address address, String telephone, int
totalScore, int numberOfVotes,
String imageURL, String imageThumbURL, String literatureURL,
Timestamp eventTimestamp) {
this.title = title;
this.summary = summary;
this.description = description;
this.submitterUserName = submitterUserName;
this.address = address;
this.totalScore = totalScore;
this.numberOfVotes = numberOfVotes;
this.imageURL = imageURL;
this.imageThumbURL = imageThumbURL;
this.literatureURL = literatureURL;
this.telephone = telephone;
this.eventTimestamp = eventTimestamp;
this.disabled = 0;
this.createdTimestamp=new Timestamp(new Date().getTime());
}
.....
/* The default fetch type for one-to-one is EAGER.
* However, for SocialEvents, this information may not be required in
cases
* where the event is listed for attendees, tags and comments.
* So make it lazy. The Address has to be fetched in the ModelFacade
when
* the event is loaded.
* */
@OneToOne(cascade={CascadeType.PERSIST, CascadeType.MERGE},
fetch=FetchType.LAZY)
public Address getAddress() {
return address;
}
Thanks again,
Kim
Weaving should be transparent to you when running on WebLogic.
What does your Person class look like?
-Tom
Kim LiChong wrote:
Hi,
I am deploying a webapp to Weblogic 10.3.1.0 with eclipselink 1.1. I
am using resource injection in a ModelFacade class to get
EntityManager Factory:
public class ModelFacade implements ServletContextListener {
@PersistenceUnit(unitName = "BPWebappPu")
private EntityManagerFactory emf;
@Resource
private UserTransaction utx;
I don't have any weave specific properties set in my persistence.xml
either:
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="BPWebappPu">
<description>BPWebapp Persistence Unit
</description>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/BPWebappDB</jta-data-source>
<properties>
<!-- for eclipselink 1.0 -->
<property name="eclipselink.target-database"
value="org.eclipse.persistence.platform.database.MySQLPlatform"/>
</properties>
</persistence-unit>
</persistence>
I am getting the following exception after deploying and hitting the
home page for the first time:
####<Aug 24, 2009 3:11:10 PM PDT> <Error> <HTTP> <etc01>
<AdminServer> <[ACTIVE] ExecuteThread: '3' for queue:
'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <>
<12511518704
52> <BEA-101020> <[ServletContext@16140565[app:_appsdir_webapp_war
module:webapp.war path:/webapp spec-version:2.5]] Servlet failed with
Exception
javax.persistence.PersistenceException: Exception [EclipseLink-0]
(Eclipse Persistence Services - 1.1.1.v20090430-r4097):
org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
---------------------------------------------------------
Descriptor Exceptions:
---------------------------------------------------------
Exception [EclipseLink-60] (Eclipse Persistence Services -
1.1.1.v20090430-r4097):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_setaddress_vh] or
[_persistence_getaddress_vh] is not defined in the object
[org.apache.olio.webapp.model.Person].
Internal Exception: java.lang.NoSuchMethodException:
org.apache.olio.webapp.model.Person._persistence_getaddress_vh()
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[address]
Descriptor: RelationalDescriptor(org.apache.olio.webapp.model.Person
--> [DatabaseTable(PERSON)])
Exception [EclipseLink-60] (Eclipse Persistence Services -
1.1.1.v20090430-r4097):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_setaddress_vh] or
[_persistence_getaddress_vh] is not defined in the object
[org.apache.olio.webapp.model.SocialEvent].
Internal Exception: java.lang.NoSuchMethodException:
org.apache.olio.webapp.model.SocialEvent._persistence_getaddress_vh()
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[address]
Descriptor:
RelationalDescriptor(org.apache.olio.webapp.model.SocialEvent -->
[DatabaseTable(SOCIALEVENT)])
Runtime Exceptions:
---------------------------------------------------------
java.lang.NullPointerException
java.lang.NullPointerException
at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:272)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:111)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:163)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:150)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
weblogic.deployment.EntityManagerFactoryProxyImpl.invoke(EntityManagerFactoryProxyImpl.java:75)
at $Proxy117.createEntityManager(Unknown Source)
at
org.apache.olio.webapp.model.ModelFacade.getSocialEvents(ModelFacade.java:1076)
at
org.apache.olio.webapp.controller.EventAction.listEvents(EventAction.java:219)
at
org.apache.olio.webapp.controller.EventAction.process(EventAction.java:57)
at
org.apache.olio.webapp.controller.ControllerServlet.process(ControllerServlet.java:61)
at
org.apache.olio.webapp.controller.ControllerServlet.doGet(ControllerServlet.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
Note that for both of the address fields "Address" mentioned in
Person and Social event, they are defined as LAZY type fetches.
I had a colleague inform me that since the resource injection is
being injected, the weaving should be transparent to me and should
occur between WebLogic and Eclipselink. However, the error seems to
indicate that the weaving did not occur. Any ideas?
Thanks for the help,
Kim
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users