tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thiago Veronezi <thi...@veronezi.org>
Subject Re: OpenEJB-client.jar with non OpenJPA persistence providers
Date Wed, 25 Aug 2010 00:37:05 GMT
Hi Yvan,

I cant reproduce your problem. What are you doing exactly?
1) Are you getting from your remote ejb server an entity bean which contains
a lazy collection as property?
2) Or are you getting from your remote ejb server a collection?

I tried both options:
1) hibernate throws a "org.hibernate.LazyInitializationException: failed to
lazily initialize a collection of role:
iserver.iservice.persistence.entity.user.User.contacts, no session or
session was closed" - which is excepted at this point
2) nothing happens... I mean: I works fine.. :O)

My pom.xml
.
.
.
<repository>
<id>jboss</id>
<url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
</repository>
.
.
.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.4-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.5.4-Final</version>
<exclusions>
<exclusion>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
</exclusion>
</exclusions>
</dependency>
.
.
.

My bean

@Entity
@Table(name = "user", uniqueConstraints = { @UniqueConstraint(columnNames =
{ "account" }) })
public class User extends BaseEntity {
private final static long serialVersionUID = 2487283775194384645L;

@Column(name = "account", updatable = false, nullable = false)
private String account;

private String name;

@Column(nullable = false)
private Boolean confirmed;

@Column(name = "password", nullable = false)
private String password;

@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "user_contacts",
joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "uid"),
inverseJoinColumns = @JoinColumn(name = "contact_id", referencedColumnName =
"uid"))
private List<User> contacts;

@ManyToMany(mappedBy = "contacts", fetch = FetchType.LAZY)
private List<User> contactedby;

.
.
.
}

MyTest (webapp side)...

@RequestMapping(value = "/secure/getMyContacts")
public @ResponseBody
List<ContactJson> getMyContacts(HttpServletRequest request, Locale locale)
throws Exception {

final String account = request.getRemoteUser();
ServiceBean serviceBean = getBean(request, ServiceBean.class);
 List<ContactJson> result = new ArrayList<ContactJson>();
//get the lazy list from the bean at the ejbserver side
List<User> contacts = serviceBean.execute(
new FindContactsByAccountCmd(account)
).getResult();
for (User user : contacts) {
result.add(new ContactJson(user.getUid(), user.getAccount(),
user.getName(), user.getConfirmed()));
}
 final User me = serviceBean.execute(
new FindUserByAccountCmd(account, account)
).getResult();

//get the bean with a lazy property at the ejbserver side
System.out.println("me: " + me.getAccount());

//this line thows the LazyInitializationException
System.out.println("mycontacts: " + me.getContacts());

return result;
}


[]s,
Thiago.


On Mon, Aug 23, 2010 at 10:00 AM, Yvan <frontpost@gmail.com> wrote:

>
> I use hibernate 3.5.4-Final as my JPA 2.0 persistence implementation and
> everything works just fine until I try to send lazily initialized objects
> over the RemoteInitialContextFactory as explained here:
>
> http://openejb.979440.n4.nabble.com/Error-reading-response-from-server-OEJP-3-1-with-3-2-SNAPSHOT-td2323297.html#a2323297
> .
>
>
> I know there is the https://jira.jboss.org/jira/browse/EJBTHREE-440 issue
> caused by the bug in the JVM, but since it was solved in the 3.0-final
> version I guess the problem _probably_ comes from somewhere else now.
>
> Is it possible that the reason is that openejb doesn't know how to handle
> third parties providers' proxies on the client side, since it has always
> used OpenJPA as the default provider before the latest 3.2-SNAPSHOT (with
> JPA2 support)?
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/OpenEJB-client-jar-with-non-OpenJPA-persistence-providers-tp2335151p2335151.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message