Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Pete Helgren
user lacks privilege or object not found: error
December 7, 2012 9:27 AM
Answer

Pete Helgren

Rank: Regular Member

Posts: 126

Join Date: April 7, 2011

Recent Posts

I have a portlet created by service builder that provides services to other portlets. That service builder portlet uses a different database that the main Liferay database (HSQLDemoticon In testing a method in the portlet and it seems to be connecting to the liferay DB rather than the MSSQL database that I have defined in the context.xml in Tomcat. So I have two questions:

1) As I am debugging, what property can I inspect to see what database the query is executing against? I drilled down to the ORM Session object and can see
_session, jdbcContext, connectionManager, connection but then I get lost. Can I pull the datasource and database more directly from the session or query object so that I can figure out just what database the query is running against?

2) What am I missing in the configuration that is not pointing to the correct DB in the portlet? I have the correct jndi settings in server.xml and referenced in context.xml (I think). The portlet has a hibernate.cfg.xml file in the classes folder that points to the correct connection. I have a ext-spring.xml that also has correct references to the jndi resource

Thanks
Pete Helgren
RE: user lacks privilege or object not found: wrong database used
December 10, 2012 3:06 PM
Answer

Pete Helgren

Rank: Regular Member

Posts: 126

Join Date: April 7, 2011

Recent Posts

Can anyone help here?

This is as much as I know on this particular issue (and I really need some assistance):

I have a JNDI resource defined in server.xml and a resource link in context.xml in my Tomcat 7 /conf folder. I KNOW the JNDI resource is being loaded because I see the validation query being run as the server starts up. So far so good.

I have a portlet that just provides services to other portlets. In in that portlet I have a hibernate.cfg.xml which has a session-factory that also points to the JDBC resource (don't know if this is needed or not but I am not sure). I also have an ext-spring.xml file that has the following:

<bean id="liferayHibernateSessionFactory" class="com.liferay.portal.spring.hibernate.PortletHibernateConfiguration" >
<property name="dataSource" ref="MyJDBCResource" />
</bean>

<bean id="MyJDBCResource" class="org.springframework.jndi.JndiObjectFactoryBean" >
<property name="jndiName" value="java:comp/env/jdbc/MyJDBCResource" />
</bean>

Adding the above in ext-spring.xml fixed an issue with a bean error upon deployment. In that service builder built portlet, a service jar was created and I put that service jar in the Tomcat_Home/lib/ext folder so that I could use the services provided by the portlet in my portlet. So far so good. But, when I invoke the portlet method which calls the services provided by the other portlet with the JNDI references, I get the "user lacks privilege or object not found" error. It is *definitely* object not found. When the query is run I see absolutely NO activity on the JDBC connection specified by the JNDI resource entry and in drilling down on the connection properties I only see the HSQLDB driver in use.

SO WHAT AM I DOING WRONG? Do I need to add some configuration entries in the portlet that *invokes* the services?

This seems so simple in reading the many posts that give instruction on using JNDI/JDBC resources. Even the issues listed in the forum have been resolved by steps I seem to have taken correctly but I am still stumped. Is there some trick to using JNDI/JDBC resources in LR 6.1.1 and Tomcat 7 that I have missed/

Thanks (and really hoping for some answers!).
Pete Helgren
RE: user lacks privilege or object not found: wrong database used
December 13, 2012 6:45 AM
Answer

Pete Helgren

Rank: Regular Member

Posts: 126

Join Date: April 7, 2011

Recent Posts

This is a fruitless task I guess. There is just no way to get this product to work or to understand how it works with anything but the most elementary "Hello World" app....

Between beanLocator errors and weird issues like this, all that the magic provided by Spring and the LR framework is just obfuscation.
Pete Helgren
RE: user lacks privilege or object not found: wrong database used
December 13, 2012 7:53 AM
Answer

Pete Helgren

Rank: Regular Member

Posts: 126

Join Date: April 7, 2011

Recent Posts

And one last shred of evidence that *might* light up a bulb for someone:

Here is the deployment trace from MyEclipse;

09:32:27,691 INFO [pool-2-thread-1][HotDeployImpl:178] Deploying MyService-portlet from queue
09:32:27,693 INFO [pool-2-thread-1][PluginPackageUtil:1033] Reading plugin package for MyService-portlet
Loading file:/C:/Other%20Programs/LR611-TC/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/temp/0-MyService-portlet/WEB-INF/classes/portlet.properties
Loading file:/C:/Other%20Programs/LR611-TC/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/temp/0-MyService-portlet/WEB-INF/classes/service.properties
Loading file:/C:/Other%20Programs/LR611-TC/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/temp/0-MyService-portlet/WEB-INF/classes/portlet.properties
Dec 13, 2012 9:32:27 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Loading file:/C:/Other%20Programs/LR611-TC/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/temp/0-MyService-portlet/WEB-INF/classes/service.properties
09:32:36,084 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:177] Processing MyService-portlet-6.1.1.1.war
09:32:36,086 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][PortletAutoDeployListener:77] Copying portlets for C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\deploy\MyService-portlet-6.1.1.1.war
09:32:36,087 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][BaseDeployer:763] Deploying MyService-portlet-6.1.1.1.war
09:32:36,088 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][BaseDeployer:859] Updating BSFCentral from version 6.1.1.1 to version 6.1.1.1
Expanding: C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\deploy\MyService-portlet-6.1.1.1.war into C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp\20121213093236090
Copying 1 file to C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp\20121213093236090\WEB-INF
Copying 1 file to C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp\20121213093236090\WEB-INF\classes
Copying 1 file to C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp\20121213093236090\WEB-INF\classes
Copying 1 file to C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp\20121213093236090\WEB-INF\jsp
09:32:37,229 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][BaseDeployer:2083] Modifying Servlet 2.4 C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp\20121213093236090\WEB-INF\web.xml
Copying 564 files to C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\webapps\MyService-portlet
Copying 1 file to C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\webapps\MyService-portlet
Deleting directory C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp\20121213093236090
09:32:47,926 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][PortletAutoDeployListener:87] Portlets for C:\Other Programs\LR611-TC\liferay-portal-6.1.1-ce-ga2\deploy\MyService-portlet-6.1.1.1.war copied successfully. Deployment will start in a few seconds.
09:32:56,781 INFO [pool-2-thread-1][DialectDetector:71] Determine dialect for Microsoft SQL Server 9
09:32:56,788 INFO [pool-2-thread-1][DialectDetector:136] Found dialect com.liferay.portal.dao.orm.hibernate.SQLServer2005Dialect
Loading file:/C:/Other%20Programs/LR611-TC/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/temp/0-MyService-portlet/WEB-INF/classes/service.properties
Loading file:/C:/Other%20Programs/LR611-TC/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/temp/0-MyService-portlet/WEB-INF/classes/portlet.properties

NOTE the info messages relating to the DialectDetector: MSSQL NOT HSSQL so I know as the portlet loads ift IS finding the global jndi resource which points to MSSQL. Yet when I hit the methods in the services portlet I see this stack trace (snippet):

Caused by: java.sql.SQLException: user lacks privilege or object not found: TBL_LECTURE_RECORDINGS
at org.hsqldb.jdbc.Util.sqlException(Util.java:232)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(JDBCPreparedStatement.java:3893)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(JDBCConnection.java:643)
at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:213)
at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376)
at $Proxy4.prepareStatement(Unknown Source)
at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.jdbc.BorrowedConnectionProxy.invoke(BorrowedConnectionProxy.java:74)
at $Proxy261.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1700)

at org.hibernate.loader.Loader.doQuery(Loader.java:801)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2542)

NOTE that the JDBCConnection object is from HSQLDB NOT MSSQL. I have no idea why the portlet is trying to query against the HSQLDB since the service builder databsource name wouldn't match anything but the jndi resource defined in server.xml.

OR perhaps the hsqldb object is just a proxy to be passed to the MSSQL database driver....in any case, the table DOES exist in the MSSQL database and the defined user does have permission (as verified by SQuirreL).

Anyone?
Pete Helgren
RE: user lacks privilege or object not found: wrong database used
January 3, 2013 3:08 PM
Answer

Pete Helgren

Rank: Regular Member

Posts: 126

Join Date: April 7, 2011

Recent Posts

Not certain of the solution but I have been able to move past this. A couple of things didn't add up so I did some comparing of what worked and what didn't. The two most notable things:

No reference to the jdbc jndi resource in web.xml in the service portlet.

Incorrect entries in the ext-spring.xml (Glassfish wants the jndi resource defined one way, tomcat wants it a different way.)

Still working through some other issues but I am getting closer....