I have a question that doesn't seem to be too common on the message boards. If anyone has any ideas, please feel free to share them! =)
I have a table in my database called Person. The primary key is personseq, an integer value.
I am trying to (for the sake of experimentation) run the equivalent of this SQL query: ------------------------------- select max(personseq) from Person -------------------------------
I'm running EJB 2.0 and Orion/oc4j. I wanted to do this in an ejbSelect method, because I only want one field returned - not the entire list of objects that an EJB find would return. I've read that 2.0 supports the aggregate functions.
So I have a Person entity bean, and that entity bean has an abstract method: ejbSelectMaxPersonseq(), which returns a Long, and throws a FinderException.
The ejb-ql I've written for this method is as follows: ------------------------------- select max (o.personseq) from Person o -------------------------------
This compiled fine, but broke upon deployment with this error: <snip> 06/07/31 17:25:01 WARNING: EJBContainer.postInit Error generating wrappers for file: <filename here>
java.lang.NullPointerException at com.sun.enterprise.deployment.QueryDescriptor.getSQLAsPrintableString(QueryDescriptor.java:158) at com.evermind.server.ejb.compilation.SelectMethodCompilation.compile(SelectMethodCompilation.java:67) at com.evermind.server.ejb.compilation.CMPObjectCompilation.verifyMethods(CMPObjectCompilation.java:775) at com.evermind.server.ejb.compilation.CMPObjectCompilation.<init>(CMPObjectCompilation.java:56) at com.evermind.server.ejb.compilation.PersistenceManagerCompilation.<init>(PersistenceManagerCompilation.java:30) at com.evermind.server.ejb.compilation.EntityBeanCompilation.<init>(EntityBeanCompilation.java:121) at com.evermind.server.ejb.compilation.Compilation.generateAnyOldStyle(Compilation.java:1590) at com.evermind.server.ejb.compilation.Compilation.compile(Compilation.java:182) at com.evermind.server.ejb.compilation.Compilation.doGenerateCode(Compilation.java:250) at com.evermind.server.ejb.EJBContainer.postInit(EJBContainer.java:891) at com.evermind.server.ApplicationStateRunning.initializeApplication(ApplicationStateRunning.java:210) at com.evermind.server.Application.setConfig(Application.java:391) at com.evermind.server.Application.setConfig(Application.java:308) at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1771) at oracle.oc4j.admin.internal.ApplicationDeployer.addApplication(ApplicationDeployer.java:507) at oracle.oc4j.admin.internal.ApplicationDeployer.doDeploy(ApplicationDeployer.java:191) at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:93) at com.evermind.server.administration.DefaultApplicationServerAdministrator.internalDeploy(DefaultApplicationServerAdministrator.java:446) at com.evermind.server.administration.DefaultApplicationServerAdministrator.deploy(DefaultApplicationServerAdministrator.java:347) 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:585) at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:53) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595)
Jul 31, 2006 5:25:01 PM com.evermind.server.ejb.EJBContainer postInit WARNING: Error generating wrappers for file:<jar file name here>
I assumed that my ejb-ql was incorrect, so I abandoned the aggregate, and made it a simpler one-field select, and tried this ejb-ql (jobId and personseq are both cmp fields w/Long values in the entity bean): ------------------------------- select o.jobId from Person o where o.personseq = 13543 -------------------------------
This compiled fine, and deployed with no errors.
Is there a glaring error in my max ejb-ql I'm not seeing? Has anyone run across this problem before?
If so, any insight would be appreciated! =)
Thanks to all! =) -Em
p.s. I encountered the original "max" problem while developing a different app I was creating in Toplink, and the error message was different (a NPE way down in Toplink's UOWManager). This Orion version is me attempting to see if I can get it working "the old way", hoping the solution might translate to Toplink. So if you've solved a similar issue in Toplink, that'll be helpful too!
Aggregates are not supported in EJB2.0 but in EJB2.1. Just check the exact version supported by the oc4j container.
Joined: Jul 31, 2006
Thanks so much for the reply!
I'm simultaneously testing this via JDeveloper and a command-line deploy, since sometimes JDev flakes out on me. Like you guessed - I was in fact running 2.0. I've changed 2.0 to be 2.1 in my JDev deployment descriptor. I've also scanned through my ejb-jar.xml, and made sure any 2.0s are now 2.1s: -------------------- <ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee"> ------------------------
My J2ee server is running version 10.1.3.0.0, which I believe supports EJB v2.1.
I'm still getting the exact same error, both when I deploy via JDev and also when I try it via command-line.
I've noticed that JDev generates the ejb beans to have the following tag:
Do you think perhaps I should change the 2.x s to be 2.1?
Thanks again for the initial reply - I needed a break from pounding my head into the wall!
Joined: May 24, 2003
I checked the OC4J doc to ensure it supports 2.1. It does. But I am not sure what the error message is and I don't work on OC4j. It's painfull to install the server. Did you check the OTN doc sites? Sorry couldn't help much.
PS: 2.x in cmp-version should do. [ August 02, 2006: Message edited by: Purushothaman Thambu ]
Thanks again for both of your replies. I got my co-worker to create & test an ejbSelect in her own app (via Toplink, the source of the original problem), and it magically worked for her, using the same procedure I was using to create my own ejbSelects. So in a mute fury I went back to my own computer and tried it again, hoping that since JDev is so flaky, maybe this one time it would work.
It did. Go figure. 2 days of my life gone, and no explanation as to why or how all of a sudden it works. I found a post on this topic that's pretty recent, perhaps they'll figure it out.