aspose file tools
The moose likes JBoss and the fly likes cannot point to existing table in database: no such entity! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Products » JBoss
Reply Bookmark "cannot point to existing table in database: no such entity!" Watch "cannot point to existing table in database: no such entity!" New topic
Author

cannot point to existing table in database: no such entity!

vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
Hi, I am using JBoss 4.0.3 with NetBeans 5.0 beta 2. It is linked up with MS SQL SERVER 2000. I'm using CMP beans to map to existing table inside database. However when I run the application, I'm getting a FinderException: No such entity!

I suspect the entity bean cannot access the table.
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
This is my code which calls the CMP beans:


The print out I get in console is:
15:47:38,125 INFO [STDOUT] null
15:47:38,125 INFO [STDOUT] No such entity!
15:47:38,125 ERROR [LogInterceptor] RuntimeException in method: public abstract java.lang.String Session1.myFacadeRemoteBusiness.testSession(int) throws javax.ejb.FinderException,java.rmi.RemoteException:
java.lang.NullPointerException
at Session1.myFacadeBean.testSession(myFacadeBean.java:7 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Metho at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:2 at java.lang.reflect.Method.invoke(Method.java:58 at org.jboss.invocation.Invocation.performCall(Invocation.java:34 at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:21 at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:14 at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:15 at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:5 at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:4 at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:10 at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:33 at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:16 at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:15 at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:19 at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:12 at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:62 at org.jboss.ejb.Container.invoke(Container.java:87 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Metho at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:2 at java.lang.reflect.Method.invoke(Method.java:58 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:14 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:8 at org.jboss.mx.server.Invocation.invoke(Invocation.java:7 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:24 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:64 at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:15 at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:10 at org.jboss.invocation.InvokerInterceptor.invokeMarshalled(InvokerInterceptor.java:20 at org.jboss.invocation.MarshallingInvokerInterceptor.invoke(MarshallingInvokerInterceptor.java:3 at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:4 at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:5 at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:9 at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:8 at $Proxy142.testSession(Unknown Sourc at web.Servlet1.processRequest(Servlet1.java:3 at web.Servlet1.doGet(Servlet1.java:5 at javax.servlet.http.HttpServlet.service(HttpServlet.java:69 at javax.servlet.http.HttpServlet.service(HttpServlet.java:81 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:25 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:17 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:8 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:20 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:17 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:21 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:17 at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:3 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:15 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:5 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:12 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:10 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:14 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:85 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:74 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:52 at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:11 at java.lang.Thread.run(Thread.java:5915:47:38,531 WARN [[Servlet1]] Servlet.service() for servlet Servlet1 threw exception
java.rmi.ServerException: RuntimeException; nested exception is:
java.lang.NullPointerExcepti at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:38 at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:19 at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:12 at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:62 at org.jboss.ejb.Container.invoke(Container.java:87 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Metho at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:2 at java.lang.reflect.Method.invoke(Method.java:58 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:14 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:8 at org.jboss.mx.server.Invocation.invoke(Invocation.java:7 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:24 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:64 at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:15 at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:10 at org.jboss.invocation.InvokerInterceptor.invokeMarshalled(InvokerInterceptor.java:20 at org.jboss.invocation.MarshallingInvokerInterceptor.invoke(MarshallingInvokerInterceptor.java:3 at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:4 at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:5 at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:9 at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:8 at $Proxy142.testSession(Unknown Sourc at web.Servlet1.processRequest(Servlet1.java:3 at web.Servlet1.doGet(Servlet1.java:5 at javax.servlet.http.HttpServlet.service(HttpServlet.java:69 at javax.servlet.http.HttpServlet.service(HttpServlet.java:81 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:25 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:17 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:8 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:20 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:17 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:21 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:17 at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:3 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:15 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:5 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:12 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:10 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:14 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:85 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:74 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:52 at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:11 at java.lang.Thread.run(Thread.java:59Caused by: java.lang.NullPointerException
at Session1.myFacadeBean.testSession(myFacadeBean.java:7 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Metho at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:2 at java.lang.reflect.Method.invoke(Method.java:58 at org.jboss.invocation.Invocation.performCall(Invocation.java:34 at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:21 at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:14 at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:15 at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:5 at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:4 at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:10 at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:33 at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:16 at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:15 at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:19 ... 44 mo15:55:01,046 INFO [Server] LifeThread.run exits!
15:55:01,046 INFO [Server] Shutting down the JVM now!

Do I need to configure any of my xml files? Any suggestion is welcomed! Thanks in advance
[ January 05, 2006: Message edited by: vivien siu ]
Tom Marrs
Author
Ranch Hand

Joined: Sep 20, 2000
Posts: 67
Vivien,
I haven't used CMP with EJB 2, but I have used it recently on EJB 3 and ran into a similar problem. When I searched for an Entity that wasn't found, I got an exception. I think this is somewhere in the EJB spec, but don't quote me on it. Anyway, in EJB 3, this was considered normal behavior.

I didn't agree with this, so I modified my code to catch the Finder/NullPointerException. The catch clause just returned a null value. After all, "Not Found" really shouldn't generate an error.

So, I don't think you're doing anything wrong. Just catch the exception and return a null.

Tom Marrs
Lead Author, JBoss at Work: A Practical Guide
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
Thanks Tom, but how do I solve the problem? Yes it is returning null and I'm getting "No such entity" message when it thrown the FinderException. We would really like to use JBoss for our EJBs but we seem to be running into this problem.

FYI I'm using NetBeans 5.0 Beta 2 to generate the CMP entity beans. I installed the full version of JBoss latest installer. Yes I'm using EJB 2. But can it return null where the primary key I passed in exists in the table?
Tom Marrs
Author
Ranch Hand

Joined: Sep 20, 2000
Posts: 67
Vivien,
Oops!! I missed the fact that the Primary Key exists in your database, and that you can't find it with the CMP EJB finder method.

Hmmmm....
There are a few of the things that you could check.
Do you have any deployment errors? If so, then the EJB won't work. There could be a problem with the *-ds.xml for the DataSource or with the CMP EJB deployment descriptor. OR, both of these files could OK, but somehow there's a mismatch on the DataSource name in your CMP EJB deployment descriptor.

If everything is deploying OK, then I'm stumped.

Tom
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
Hi Tom,

Can you please tell me what is CMP Deployment Descriptior? What kind of file name I should be cheking for?

Many thanks!
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 292

The CMP deployment descriptor file is jbosscmp-jdbc.xml

What is your contents of this file?
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
is it this one:


[ January 10, 2006: Message edited by: vivien siu ]

[Editied to fix formatting - Paul Sturrock]
[ January 12, 2006: Message edited by: Paul Sturrock ]
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
Hello guys, for the no such entity error above, I double checked my database and found out it's creating a new table automatially for me with the name exactly same as my Entity Bean class name. If I put data inside the newly created table then it works fine! But I want it to point to existing table. Why is this happening?

so I went to my jboss folder and changed the <create-table> tags to false instead. Now the "no such entity" error has gone, so is the application does not auto-create new tables for me. But now I got the following exception instead:
Find failed: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'StudentDataBean'


I did the EJB application by using NetBeans. So the codes are mostly auto-generated by NetBeans itself. Besides that do I need to setup database pooling to make it work? Because I have not set up pooling yet.
[ January 08, 2006: Message edited by: vivien siu ]
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
Hi, can anybody please help me take a look at my codes?

Does anyone have problems similiar like mine as well when using NetBeans with JBoss?
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
I've seen this before. The problem has to do with who owns the table versus the user you connect as. JBoss particularly tends to have this problem, both with sqlserver and with Oracle. It behaves as though it pays attention to the catalog info during CMP deployment, but ignores it during actual CMP use (or vice versa).


Reid - SCJP2 (April 2002)
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
really? this is interesting. Then how can we solve this problem?
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
The solution for Oracle is easy. You just change your grants so the schema you are connecting to can't see into the second schema that has a table of the same name. I don't remember the exact fix for sqlserver, but I do remember that it had something to do with the security settings of the user when they connect.
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
ok cool! So how to change the schema exactly in Oracle by the way? Can you please show me the steps?
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
You need to have the appropriate perms. Let us say you are connecting to schema A and want your table in A. There is a schema B that is visible to you, and is causing problems.

Login to schema B, and revoke the grants that were made to A. The Oracle SQL Reference doc shows exactly how to do this.

Not sure what happens if you have a database with grants set up to make everything visible to everybody. You would have to talk to a DBA if that is the case.
Tom Clifford
Greenhorn

Joined: Oct 16, 2004
Posts: 2
Good evening everyone.

I've had the same issue with CMP's I've tried to make work.

The beans deploy fine, I can instantiate them fine with:

studentHome = (StudentHome) PortableRemoteObject.narrow(
ctx.lookup("java:/Student"), StudentHome.class);

but when I go to do a findById or findByPrimaryKey, I get the
same error as shown in previous posts.

I added the following to \server\default\config\log4j.xml:

<category name="org.jboss.ejb.plugins.cmp">
<priority value="TRACE" class="org.jboss.ejb.plugins.cmp"/>
</category>

to get a more detailed log, and got:

2006-10-25 22:08:19,041 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.Student#findById] Executing SQL: SELECT t0_a.id FROM STUDENT t0_a WHERE (t0_a.id = ?)
2006-10-25 22:08:19,061 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.Student#findById] Executing SQL: SELECT t0_a.id FROM STUDENT t0_a WHERE (t0_a.id = ?)

...the entry for my <query>....<sql-ql> in my ejb-jar.xml is:

<ejb-ql>
<![CDATA[SELECT OBJECT(a) FROM student a WHERE a.id = ?1]]>
</ejb-ql>

...which seems appropriate. The table name is 'student', and
the main key is 'id'. For some reason, the '?1' is not getting
replaced by the key value I'm trying to look up, according to
what this says.....?

I'm using a laptop with JBoss 4.0.4GA, I have mssql-ds.xml set up with a
datasource pointing to my locally-running MSDE sql server,
the ejb-jar.xml and jboss.xml both have <resource-ref> sections
pointing to the database. Everything seems right, but the
query above does not seem to be getting set up right by the
container (or me, somehow.....).

Does this ring any bells for anyone ?

Thanks.......
Tom Clifford
Greenhorn

Joined: Oct 16, 2004
Posts: 2
Hi.....me again. The Saloon noob.

I discovered by playing around that the 'no such entity' error
will occur if there is no entry in the table with the key
you specify in a findBy...
However, you can also get that error or something like it if
you have the incorrect name in the <abstract-schema-name>
tag, or if that name is not the right case, e.g. using
'PRODUCT' when the table name is 'product' or 'Product'.

Go Tigers
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: cannot point to existing table in database: no such entity!
 
Similar Threads
creating .hbm.xml file
EJB create not using default value for not null column
J2EE CMP beans
How to auto generate Oracle Tables and Sequences?
Design question