You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "asif.tmcp" <as...@gmail.com> on 2013/11/02 06:20:44 UTC

MySQL resource in Tomee 1.5.2

I am putting resources.xml in the WEB-INF Folder, with a resource
configuration.

<Resource id="jdbc/localDB" type="javax.sql.DataSource">
               JdbcDriver com.mysql.jdbc.Driver
               JdbcUrl jdbc:mysql://localhost:3306/localdb
               MaxActive 100 
               MaxIdle 30 
               MaxWait 10000
               UserName username
               Password password 
	</Resource>

Unfortunately, tomee single mindedly tries to load the hsqldb and then
report a vague issue

java.sql.SQLSyntaxErrorException: user lacks privilege or object not found:
USERS
	at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
	at org.hsqldb.jdbc.Util.sqlException(Unknown Source)

If I put the resource in the tomee.xml in conf folder "Sometimes" it works.

Environment: Windows 7 ; Eclipse : Tomee 1.5.2

Tested as a war on tomee 1.5.2  - the error still exists.

A similar problem is reported here 
http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-td4659538i20.html
and here
https://issues.apache.org/jira/browse/TOMEE-924

- any ideas? Resolutions?

Thanks and Regards.



--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by "asif.tmcp" <as...@gmail.com>.
I believe this is the same bug reported in 
https://issues.apache.org/jira/browse/TOMEE-924

I will try in 1.6.0 snapshot and check.




--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4666006.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

If default database is created you have a config issue somewhere or it
is a bug (I have to admit i didn't use 1.5.2 that much but only 1.5;1
and 1.6.0-SNAPSHOT). the file where you can define the datasource are
(by order of preference):
1) conf/tomee.xml
2) WEB-INF/resources.xml

there are quite others config but this is the info you are looking for I think
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2013/11/6 asif.tmcp <as...@gmail.com>:
> Just read your blog - you can ignore my previous post here.
>
> But my problem remains.
>
> Does the file naming convention has something to do with it?
> Does the file has to be named openejb.xml or resource.xml ???
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665994.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by "asif.tmcp" <as...@gmail.com>.
Just read your blog - you can ignore my previous post here.

But my problem remains.

Does the file naming convention has something to do with it?
Does the file has to be named openejb.xml or resource.xml ???




--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665994.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by "asif.tmcp" <as...@gmail.com>.
I tried that - I still get the error.

I noticed one line in the Tomee startup logs


INFO: Configuring Service(id=Default JDBC Database, type=Resource,
provider-id=Default JDBC Database)

-- does this mean, it is loading the default Database??





--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665992.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by Romain Manni-Bucau <rm...@gmail.com>.
if you war is called foo.war and your resource id is bar the jndi name
was openejb:Resource/foo/bar IIRC
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2013/11/5 asif.tmcp <as...@gmail.com>:
> So if I understand you correctly the resource id should be same as the war
> name ????
>
>
> Are you suggesting this ?
>
> <Resource id=&quot;jdbc/&lt;&lt;b>WAR-NAME*>" type="javax.sql.DataSource">
>         JdbcDriver com.mysql.jdbc.Driver
>                  JdbcUrl jdbc:mysql://localhost:3306/localdb
>                  MaxActive 100
>                  MaxIdle 30
>                  MaxWait 10000 </Resource>
>
>
> Could you please elaborate it a bit? I am new to this , and it is really not
> working if I put the resource xml in the WEB-INF folder
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665980.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by "asif.tmcp" <as...@gmail.com>.
So if I understand you correctly the resource id should be same as the war
name ????


Are you suggesting this ?

<Resource id=&quot;jdbc/&lt;&lt;b>WAR-NAME*>" type="javax.sql.DataSource">
        JdbcDriver com.mysql.jdbc.Driver
                 JdbcUrl jdbc:mysql://localhost:3306/localdb
                 MaxActive 100
                 MaxIdle 30
                 MaxWait 10000 </Resource>


Could you please elaborate it a bit? I am new to this , and it is really not
working if I put the resource xml in the WEB-INF folder



--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665980.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

It was the app id (war name by default). In all cases it is written in the
logs when the resource is created
Le 3 nov. 2013 13:04, "asif.tmcp" <as...@gmail.com> a écrit :

> Hi Romain,
>
> If I understand you correctly, you are saying that id and resource name do
> not match
>
> Here :-
> <Resource id=&quot;&lt;b>jdbc/localDB*" type="javax.sql.DataSource">
>        JdbcDriver com.mysql.jdbc.Driver
>                 JdbcUrl jdbc:mysql://localhost:3306/localdb
>                 MaxActive 100
>                 MaxIdle 30
>                 MaxWait 10000
>
> and
> <resource-ref>
>                 <description>MySQL Connection</description>
>                 <res-ref-name>*jdbc/localDB*</res-ref-name>
>                 <res-type>javax.sql.DataSource</res-type>
>                 <res-auth>Container</res-auth>
>         </resource-ref>
>
> isn't resourcename = jdbc/localDB same as id="jdbc/localDB"
>
> What exactly is the prefix that you are mentioning to be added in
> resources.xml?
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665891.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: MySQL resource in Tomee 1.5.2

Posted by "asif.tmcp" <as...@gmail.com>.
Hi Romain,

If I understand you correctly, you are saying that id and resource name do
not match

Here :-
<Resource id=&quot;&lt;b>jdbc/localDB*" type="javax.sql.DataSource">
       JdbcDriver com.mysql.jdbc.Driver
                JdbcUrl jdbc:mysql://localhost:3306/localdb
                MaxActive 100
                MaxIdle 30
                MaxWait 10000 

and 
<resource-ref>
                <description>MySQL Connection</description>
                <res-ref-name>*jdbc/localDB*</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
        </resource-ref>

isn't resourcename = jdbc/localDB same as id="jdbc/localDB"

What exactly is the prefix that you are mentioning to be added in
resources.xml?  




--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665891.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by "asif.tmcp" <as...@gmail.com>.
Just so that I am understanding this correctly, would it be possible for you
to provide a resources.xml sample, the web.xml snippet and a small code for
datasource from initialcontext lookup - ??

Mine are here :-

Resources.xml ( in WEB-INF folder of deployed war)
	<Resource id="jdbc/localDB" type="javax.sql.DataSource">
		JdbcDriver com.mysql.jdbc.Driver
	    JdbcUrl jdbc:mysql://localhost:3306/localdatabase
	    MaxActive 100 
	    MaxIdle 30 
	    MaxWait 10000
	    UserName username
	    Password password
	</Resource>

web.xml (  in WEB-INF folder of deployed war)

<resource-ref>
		<description>MySQL Connection</description>
		<res-ref-name>jdbc/locallDB</res-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>
	

Code to lookup and use datasource

InitialContext ic = new InitialContext();
Context envCtx = (Context) ic.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/localDB");




--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665892.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Ps: in 1.5.2 lookup of resource in resources.xml needed to add a prefix.
Thats ok on trunk
Le 2 nov. 2013 20:40, "Romain Manni-Bucau" <rm...@gmail.com> a écrit :

> Cause id and resource name are different
> Le 2 nov. 2013 20:34, "asif.tmcp" <as...@gmail.com> a écrit :
>
>> Nope, it just mentions creating a default database, although resources.xml
>> exists:-
>>
>> Nov 02, 2013 3:27:08 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher
>> validateJarFile
>> WARNING: jar
>>
>> 'D:\dev_wksd\eclipse-wksd\devel\Sentinel\war\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final.jar'
>> contains offending class: javax.persistence.Entity. It will be ignored.
>> Nov 02, 2013 3:27:08 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher
>> validateJarFile
>> WARNING: jar
>>
>> 'D:\dev_wksd\eclipse-wksd\devel\Sentinel\war\WEB-INF\lib\persistence-api-1.0.jar'
>> contains offending class: javax.persistence.Entity. It will be ignored.
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.config.ConfigurationFactory
>> configureApplication
>> INFO: Configuring enterprise application:
>> D:\dev_wksd\eclipse-wksd\devel\Sentinel\war
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.config.ConfigurationFactory
>> configureService
>> INFO: Configuring Service(id=Default JDBC Database, type=Resource,
>> provider-id=Default JDBC Database)
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.config.AutoConfig
>> logAutoCreateResource
>> INFO: Auto-creating a Resource with id 'Default JDBC Database' of type
>> 'javax.sql.DataSource for 'Sentinel'.
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.assembler.classic.Assembler
>> createRecipe
>> INFO: Creating Resource(id=Default JDBC Database)
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.config.AppInfoBuilder build
>> INFO: Enterprise application "D:\dev_wksd\eclipse-wksd\devel\Sentinel\war"
>> loaded.
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.assembler.classic.Assembler
>> createApplication
>> INFO: Assembling app: D:\dev_wksd\eclipse-wksd\devel\Sentinel\war
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.CdiBuilder initSingleton
>> INFO: Existing thread singleton service in SystemInstance():
>> org.apache.openejb.cdi.ThreadSingletonServiceImpl@42e3f9e3
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.OpenEJBLifecycle
>> startApplication
>> INFO: OpenWebBeans Container is starting...
>> Nov 02, 2013 3:27:09 PM org.apache.webbeans.plugins.PluginLoader startUp
>> INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
>> Nov 02, 2013 3:27:09 PM org.apache.webbeans.plugins.PluginLoader startUp
>> INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.BeansDeployer
>> validateInjectionPoints
>> INFO: All injection points are validated successfully.
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.OpenEJBLifecycle
>> startApplication
>> INFO: OpenWebBeans Container has started, it took 3 ms.
>> Nov 02, 2013 3:27:09 PM org.apache.openejb.assembler.classic.Assembler
>> createApplication
>> INFO: Deployed
>> Application(path=D:\dev_wksd\eclipse-wksd\devel\Sentinel\war)
>> Nov 02, 2013 3:27:10 PM org.apache.catalina.core.ApplicationContext log
>> INFO: Initializing Shiro environment
>> Nov 02, 2013 3:27:10 PM org.apache.catalina.startup.HostConfig
>> deployDirectory
>> INFO: Deploying web application directory
>> D:\dev_wksd\eclipse-wksd\devel\server\apache-tomee-plus-1.5.2\webapps\docs
>> Nov 02, 2013 3:27:10 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
>>
>>
>>
>> --
>> View this message in context:
>> http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665882.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>

Re: MySQL resource in Tomee 1.5.2

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Cause id and resource name are different
Le 2 nov. 2013 20:34, "asif.tmcp" <as...@gmail.com> a écrit :

> Nope, it just mentions creating a default database, although resources.xml
> exists:-
>
> Nov 02, 2013 3:27:08 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher
> validateJarFile
> WARNING: jar
>
> 'D:\dev_wksd\eclipse-wksd\devel\Sentinel\war\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final.jar'
> contains offending class: javax.persistence.Entity. It will be ignored.
> Nov 02, 2013 3:27:08 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher
> validateJarFile
> WARNING: jar
>
> 'D:\dev_wksd\eclipse-wksd\devel\Sentinel\war\WEB-INF\lib\persistence-api-1.0.jar'
> contains offending class: javax.persistence.Entity. It will be ignored.
> Nov 02, 2013 3:27:09 PM org.apache.openejb.config.ConfigurationFactory
> configureApplication
> INFO: Configuring enterprise application:
> D:\dev_wksd\eclipse-wksd\devel\Sentinel\war
> Nov 02, 2013 3:27:09 PM org.apache.openejb.config.ConfigurationFactory
> configureService
> INFO: Configuring Service(id=Default JDBC Database, type=Resource,
> provider-id=Default JDBC Database)
> Nov 02, 2013 3:27:09 PM org.apache.openejb.config.AutoConfig
> logAutoCreateResource
> INFO: Auto-creating a Resource with id 'Default JDBC Database' of type
> 'javax.sql.DataSource for 'Sentinel'.
> Nov 02, 2013 3:27:09 PM org.apache.openejb.assembler.classic.Assembler
> createRecipe
> INFO: Creating Resource(id=Default JDBC Database)
> Nov 02, 2013 3:27:09 PM org.apache.openejb.config.AppInfoBuilder build
> INFO: Enterprise application "D:\dev_wksd\eclipse-wksd\devel\Sentinel\war"
> loaded.
> Nov 02, 2013 3:27:09 PM org.apache.openejb.assembler.classic.Assembler
> createApplication
> INFO: Assembling app: D:\dev_wksd\eclipse-wksd\devel\Sentinel\war
> Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.CdiBuilder initSingleton
> INFO: Existing thread singleton service in SystemInstance():
> org.apache.openejb.cdi.ThreadSingletonServiceImpl@42e3f9e3
> Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.OpenEJBLifecycle
> startApplication
> INFO: OpenWebBeans Container is starting...
> Nov 02, 2013 3:27:09 PM org.apache.webbeans.plugins.PluginLoader startUp
> INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
> Nov 02, 2013 3:27:09 PM org.apache.webbeans.plugins.PluginLoader startUp
> INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
> Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.BeansDeployer
> validateInjectionPoints
> INFO: All injection points are validated successfully.
> Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.OpenEJBLifecycle
> startApplication
> INFO: OpenWebBeans Container has started, it took 3 ms.
> Nov 02, 2013 3:27:09 PM org.apache.openejb.assembler.classic.Assembler
> createApplication
> INFO: Deployed
> Application(path=D:\dev_wksd\eclipse-wksd\devel\Sentinel\war)
> Nov 02, 2013 3:27:10 PM org.apache.catalina.core.ApplicationContext log
> INFO: Initializing Shiro environment
> Nov 02, 2013 3:27:10 PM org.apache.catalina.startup.HostConfig
> deployDirectory
> INFO: Deploying web application directory
> D:\dev_wksd\eclipse-wksd\devel\server\apache-tomee-plus-1.5.2\webapps\docs
> Nov 02, 2013 3:27:10 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665882.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: MySQL resource in Tomee 1.5.2

Posted by "asif.tmcp" <as...@gmail.com>.
Nope, it just mentions creating a default database, although resources.xml
exists:-

Nov 02, 2013 3:27:08 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher
validateJarFile
WARNING: jar
'D:\dev_wksd\eclipse-wksd\devel\Sentinel\war\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final.jar'
contains offending class: javax.persistence.Entity. It will be ignored.
Nov 02, 2013 3:27:08 PM org.apache.tomee.catalina.TomEEClassLoaderEnricher
validateJarFile
WARNING: jar
'D:\dev_wksd\eclipse-wksd\devel\Sentinel\war\WEB-INF\lib\persistence-api-1.0.jar'
contains offending class: javax.persistence.Entity. It will be ignored.
Nov 02, 2013 3:27:09 PM org.apache.openejb.config.ConfigurationFactory
configureApplication
INFO: Configuring enterprise application:
D:\dev_wksd\eclipse-wksd\devel\Sentinel\war
Nov 02, 2013 3:27:09 PM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=Default JDBC Database, type=Resource,
provider-id=Default JDBC Database)
Nov 02, 2013 3:27:09 PM org.apache.openejb.config.AutoConfig
logAutoCreateResource
INFO: Auto-creating a Resource with id 'Default JDBC Database' of type
'javax.sql.DataSource for 'Sentinel'.
Nov 02, 2013 3:27:09 PM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=Default JDBC Database)
Nov 02, 2013 3:27:09 PM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "D:\dev_wksd\eclipse-wksd\devel\Sentinel\war"
loaded.
Nov 02, 2013 3:27:09 PM org.apache.openejb.assembler.classic.Assembler
createApplication
INFO: Assembling app: D:\dev_wksd\eclipse-wksd\devel\Sentinel\war
Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance():
org.apache.openejb.cdi.ThreadSingletonServiceImpl@42e3f9e3
Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.OpenEJBLifecycle
startApplication
INFO: OpenWebBeans Container is starting...
Nov 02, 2013 3:27:09 PM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
Nov 02, 2013 3:27:09 PM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.BeansDeployer
validateInjectionPoints
INFO: All injection points are validated successfully.
Nov 02, 2013 3:27:09 PM org.apache.openejb.cdi.OpenEJBLifecycle
startApplication
INFO: OpenWebBeans Container has started, it took 3 ms.
Nov 02, 2013 3:27:09 PM org.apache.openejb.assembler.classic.Assembler
createApplication
INFO: Deployed Application(path=D:\dev_wksd\eclipse-wksd\devel\Sentinel\war)
Nov 02, 2013 3:27:10 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Shiro environment
Nov 02, 2013 3:27:10 PM org.apache.catalina.startup.HostConfig
deployDirectory
INFO: Deploying web application directory
D:\dev_wksd\eclipse-wksd\devel\server\apache-tomee-plus-1.5.2\webapps\docs
Nov 02, 2013 3:27:10 PM org.apache.tomee.catalina.TomcatWebAppBuilder init



--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665882.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Do you have logs saying a resource is adjusted?
Le 2 nov. 2013 17:16, "asif.tmcp" <as...@gmail.com> a écrit :

> Sorry the code got messed up. The java code is as follows:-
>
>         InitialContext ic = new InitialContext();
>         Context envCtx = (Context) ic.lookup("java:comp/env");
>         DataSource ds = (DataSource)envCtx.lookup("jdbc/SentinelDB");
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665879.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: MySQL resource in Tomee 1.5.2

Posted by "asif.tmcp" <as...@gmail.com>.
Sorry the code got messed up. The java code is as follows:-

	InitialContext ic = new InitialContext();
	Context envCtx = (Context) ic.lookup("java:comp/env");
	DataSource ds = (DataSource)envCtx.lookup("jdbc/SentinelDB");
	



--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665879.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by "asif.tmcp" <as...@gmail.com>.
Hi Romain, 


Thanks for taking a look. But I am Not sure what you meant .. could you
please elaborate.

I have the resource configuration in tomee.xml and the following in web.xml.

<resource-ref>
		<description>MySQL Connection</description>
		<res-ref-name>jdbc/localDB</res-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>
	
In the code , I try to access it with 
	InitialContext ic = new InitialContext();
	DataSource ds = (DataSource)envCtx.lookup("jdbc/SentinelDB");
	

If I put the resources in tomee.xml , it works fine. However, if I put it in
resources.xml in the WEB-INF folder for the app, then I get the error.




--
View this message in context: http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872p4665878.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: MySQL resource in Tomee 1.5.2

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

The error is linked to the binding of the resource: either an injection or
a datasource name in persistence.xml
Le 2 nov. 2013 08:50, "asif.tmcp" <as...@gmail.com> a écrit :

> I am putting resources.xml in the WEB-INF Folder, with a resource
> configuration.
>
> <Resource id="jdbc/localDB" type="javax.sql.DataSource">
>                JdbcDriver com.mysql.jdbc.Driver
>                JdbcUrl jdbc:mysql://localhost:3306/localdb
>                MaxActive 100
>                MaxIdle 30
>                MaxWait 10000
>                UserName username
>                Password password
>         </Resource>
>
> Unfortunately, tomee single mindedly tries to load the hsqldb and then
> report a vague issue
>
> java.sql.SQLSyntaxErrorException: user lacks privilege or object not found:
> USERS
>         at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
>         at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
>
> If I put the resource in the tomee.xml in conf folder "Sometimes" it works.
>
> Environment: Windows 7 ; Eclipse : Tomee 1.5.2
>
> Tested as a war on tomee 1.5.2  - the error still exists.
>
> A similar problem is reported here
>
> http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-td4659538i20.html
> and here
> https://issues.apache.org/jira/browse/TOMEE-924
>
> - any ideas? Resolutions?
>
> Thanks and Regards.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/MySQL-resource-in-Tomee-1-5-2-tp4665872.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>