Problem running EJB application: NoClassDefFoundError

Hello,

I've been having a lot of trouble getting an EJB dependant application to work. This is my first time using EJB and am using Netbeans 5.5 All I'm doing right now is trying to call the session facade's find method to retrieve an element from the database. I've tried this with both SQL Server and PostgreSQL and got the same results:

If I provide a non-existant PK to the method, it executes correctly and returns nothing, as it should. But if I provide an existing PK to the method it throws an EjbException cause by a NoClassDefFoundError, which is always related to the jdbc driver. The jdbc drivers are in my classpath and the drivers were configured within the IDE. I post the full stack trace below:

StandardWrapperValve[Controller]: Servlet.service() for servlet Controller threw exception

javax.ejb.EJBException

at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:3730)

at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3630)

at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3431)

at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1247)

at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:192)

at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:118)

at $Proxy955.find(Unknown Source)

at com.adrianraine.bda.controller.Controller.processRequest(Controller.java:51)

at com.adrianraine.bda.controller.Controller.doGet(Controller.java:148)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)

at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)

at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)

at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)

at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)

Caused by: java.lang.NoClassDefFoundError: com/microsoft/sqlserver/jdbc/PLPInputStream

at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getObject(Unknown Source)

at oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform.getObjectFromResultSet(DatabasePlatform.java:759)

at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.getObject(DatabaseAccessor.java:940)

at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.fetchRow(DatabaseAccessor.java:746)

at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:510)

at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:437)

at oracle.toplink.essentials.threetier.ServerSession.executeCall(ServerSession.java:465)

at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:213)

at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:199)

at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.selectOneRow(DatasourceCallQueryMechanism.java:620)

at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectOneRowFromTable(ExpressionQueryMechanism.java:2152)

at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectOneRow(ExpressionQueryMechanism.java:2127)

at oracle.toplink.essentials.queryframework.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:350)

at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:709)

at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)

at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:677)

at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:731)

at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2218)

at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)

at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:894)

at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.findInternal(EntityManagerImpl.java:298)

at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.findInternal(EntityManagerImpl.java:274)

at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.find(EntityManagerImpl.java:130)

at com.sun.enterprise.util.EntityManagerWrapper.find(EntityManagerWrapper.java:477)

at com.adrianraine.bda.ejb.PersonaFacade.find(PersonaFacade.java:45)

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:1050)

at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)

at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2766)

at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3847)

at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:184)

... 30 more

I'm running out of ideas and have no idea of what's going on. Right now I'm attempting this with a single entity class, but when I attempt it with several and I step through the code with the debugger it always crashes in a different place. It just doesn't make much sense.

So any help at all would be extremely appreciated.

Thanks

[8054 byte] By [jr.calzadaa] at [2007-10-3 9:47:54]
# 1

Ok,

So first of all I'd advise u to try and run the code as a standalone program (just write a main method that retrieves that row from the db), because the problem u have is "environmental", that is, u r missing a class file somehow.

By the stack trace I can see u r using oracle toplink, for which u obviously have the appropriate driver, but r u sure u also have the driver classes for the actual underlaying database? In this specific case SQLServer db?

So first of all run the code as a standalone after configuring all drivers appropriately.

If that works and u r sure all drivers are defined in your appserver environment as well, make sure u don't have a classloader hierarchy issue.

That is - if the toplink driver is defined at the classpath level (system classloader) it would not be able to see classes that are located at "higher" classloaders, such as those defined in the server "lib" directory.

That's all I can think of right now, but start with isolating the problem by running the standalone program.

Good luck

urishermana at 2007-7-15 5:05:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...