SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-699
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Shay Banon
Reporter: Phil
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Compass

Compass doesn't integrate with Glassfish EJBs

Created: 26/Aug/08 08:01 PM   Updated: 11/Sep/08 06:31 AM
Component/s: Compass::Core
Affects Version/s: 2.0.1
Fix Version/s: 2.1.0 M3

File Attachments: 1. Text File stackTrace.txt (39 kB)
2. Text File stackTrace2.txt (21 kB)
3. Text File stackTrace3.txt (12 kB)

Environment: Windows Vista + Glassfish App Server + Toplink Essentials


 Description  « Hide
When injecting the EntityManager into my Session bean via:

@PersistenceContext(unitName = "myPU")
private EntityManager em;

What actually gets injected is an EntityManagerWrapper.

The EntityManagerWrapper is incompatible with Compass's initialization Helper method:

Compass compass = TopLinkHelper.getCompass(em);

It would be nice to have a method that accepts an EntityManagerWrapper to initialize Compass.

Refer to this forum post for more info: http://forum.compass-project.org/thread.jspa?threadID=215621



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 28/Aug/08 02:53 PM
I have just committed what I hope solves this. I have not tested it within glassfish yet, but I thought that instead of waiting for me to set things up, you can try it out. I have just kicked in a nightly build for 2.1 (trunk), can you download it and test it?

Phil added a comment - 29/Aug/08 07:24 PM
I put the following code inside of my session bean:

@Stateless
public class SearchDaoBean implements SearchDaoLocal
{
@PersistenceContext(unitName = "My-ejbPU")
private EntityManager em;

public void searchAllItems(String aSearchString)
{
Compass compass = TopLinkHelper.getCompass(em); // <-- Line 38
CompassSession session = compass.openSession();
CompassTransaction tr = session.beginTransaction();

CompassHits hits = session.find(aSearchString);
CompassDetachedHits detachedHits = hits.detach();
tr.commit();
session.close();
...

And received the following Exception:

Caused by: java.lang.ClassCastException: com.sun.enterprise.util.EntityManagerWrapper cannot be cast to oracle.toplink.essentials.ejb.cmp3.EntityManager
at org.compass.gps.device.jpa.embedded.toplink.TopLinkHelper.findCompassSessionEventListener(TopLinkHelper.java:151)
at org.compass.gps.device.jpa.embedded.toplink.TopLinkHelper.getCompass(TopLinkHelper.java:64)
at com.my.server.search.dao.SearchDaoBean.searchAllItems(SearchDaoBean.java:38)
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 com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197)
... 38 more


Shay Banon added a comment - 30/Aug/08 04:38 AM
I have kicked in another nightly build, hopefully with more information if the Glassfish native JPA extractor worked or not. Can you please run it with the new nightly build (should be available in an hour). Also, can you set the logging level to TRACE on this package: org.compass.gps.device.jpa.support?

Phil added a comment - 30/Aug/08 04:12 PM
This is the full stack trace after the test.

Phil added a comment - 30/Aug/08 04:13 PM
I've attached the stack trace as a file.

Shay Banon added a comment - 31/Aug/08 01:44 AM
Are you using the latest nightly build? If you set the logging level, you should see a message saying:

Using native JPA extractors [a list of extractors].

What you should see there (hopefully) is the Glassfish native extractor (should be detected automatically). Also, if something went wrong (it uses reflection to get the actual EM/EMF), you should see an exception.


Phil added a comment - 31/Aug/08 11:13 PM
I might not be setting up the logging properly. How should I set that package to TRACE level? Is it in the persistence.xml via a toplink property or using a log4j property file? If it's log4j, could you supply a property file you'd like me to use?

Thanks


Shay Banon added a comment - 01/Sep/08 01:44 AM
log4j property. The level should be TRACE.

Phil added a comment - 04/Sep/08 12:55 PM
Sorry I haven't tested this yet, things got busy around here. I'll try it and let you know soon.

Phil added a comment - 05/Sep/08 10:21 PM
I've attached a file called stackTrace2.txt. I think it has what you are looking for in it.

Shay Banon added a comment - 09/Sep/08 12:33 PM
I have kicked in another nightly and trying to use another method in reflection. Can you give it a go in 30 minutes? Also, which version of Glassfish are you using?

Phil added a comment - 09/Sep/08 07:32 PM
I've attached the latest stack trace. I'm using Glassfish V2 (Sun Java System Application Server 9.1_02 (build b04-fcs)) .

Shay Banon added a comment - 10/Sep/08 07:41 AM
ok, we moved forward!. I think I found the problem we have now (stupid bug). Can you give the latest build another try? In 30 minutes there will be another nightly.

Phil added a comment - 10/Sep/08 09:17 PM
It works!

Thanks for taking the time to solve this.


Shay Banon added a comment - 11/Sep/08 06:31 AM
Great, finally . Great feature for Compass.