You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by avrono <av...@neuralm.com> on 2012/12/13 19:43:29 UTC

Unable to configure MYSQL resource in tomee.xml

Hi, 

I am having a problem with configuring a database connection. I Have managed
to write to the database using   DriverManager but not with @Resource.

I have the following in my tomee.xml

<Resource id="MyDataSource" type="DataSource"> 
  JdbcDriver com.mysql.jdbc.Driver 
  JdbcUrl jdbc:mysql://localhost:3306/mydb 
  UserName myuser 
  Password mypass 
  JtaManaged true 
</Resource>


in my ManagedBean, I have 

@Resource(name="MyDataSource", type=javax.sql.DataSource.class)
Private DataSource dataSource;


I have a @PostConstruct 

with ....

try {
  connection = dataSource.getConnection();
} catch (Exception ex) {
 ex.printStackTrace();
}


The Connection does not throw an exception , however when I try write to the
connection

try {
   stmt = connection.createStatement();
   stmt.executeUpdate(insert_string)
} catch (Exception ex) {
   ex.printStackTrace()
}


I get 

Query is <INSERT INTO item values(5454,'fgfgfgfg','2012-12-13
18:15:57','2012-12-13 18:15:57','2012-12-27 18:15:57',4334.0)
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found:
ITEM
	at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
	at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
	at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
	at org.hsqldb.jdbc.JDBCStatement.executeUpdate(Unknown Source)
	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
org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor$StatementProxy.invoke(StatementDecoratorInterceptor.java:238)
	at $Proxy83.executeUpdate(Unknown Source)
	at com.prsx.ItemAdder.addItem(ItemAdder.java:101)
	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 org.apache.el.parser.AstValue.invoke(AstValue.java:278)
	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
	at
org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:70)
	at
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:68)
	at javax.faces.component.UICommand.broadcast(UICommand.java:120)
	at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1028)
	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:286)
	at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1375)
	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
	at
org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:38)
	at
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
	at
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
	at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
	at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
	at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not
found: ITEM
	at org.hsqldb.error.Error.error(Unknown Source)
	at org.hsqldb.error.Error.error(Unknown Source)
	at org.hsqldb.SchemaManager.getTable(Unknown Source)
	at org.hsqldb.ParserDQL.readTableName(Unknown Source)
	at org.hsqldb.ParserDQL.readSimpleRangeVariable(Unknown Source)
	at org.hsqldb.ParserDML.compileInsertStatement(Unknown Source)
	at org.hsqldb.ParserCommand.compilePart(Unknown Source)
	at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
	at org.hsqldb.Session.executeDirectStatement(Unknown Source)
	at org.hsqldb.Session.execute(Unknown Source)



It seems as if my mysql resource is not being correctly picked up ... any
ideas ?



--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
I will try do so ... Let you know



--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659604.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
Actually I did notice those .....


INFO: Auto-linking resource-ref 'java:comp/env/avronDB' in bean
localhost/PRSX.Comp to Resource(id=My DataSource)
14-Dec-2012 13:23:04 org.apache.openejb.config.AutoConfig processResourceRef
INFO: Auto-linking resource-ref 'java:comp/env/avronDB' in bean HelloBean to
Resource(id=My DataSource)

14-Dec-2012 13:23:04 org.apache.openejb.config.AutoConfig setJtaDataSource
INFO: Adjusting PersistenceUnit avronDBP <jta-data-source> to Resource ID
'My DataSource' from 'jdbc/testDB'
14-Dec-2012 13:23:04 org.apache.openejb.config.AutoConfig
setNonJtaDataSource
INFO: Adjusting PersistenceUnit avronDBP <non-jta-data-source> to Resource
ID 'My Unmanaged DataSource' from 'null'
.....
14-Dec-2012 13:23:04 org.apache.openejb.config.AutoConfig setJtaDataSource
INFO: Adjusting PersistenceUnit PRSX <jta-data-source> to Resource ID 'My
DataSource' from 'jdbc/testDB'
14-Dec-2012 13:23:04 org.apache.openejb.config.AutoConfig
setNonJtaDataSource
INFO: Adjusting PersistenceUnit PRSX <non-jta-data-source> to Resource ID
'My Unmanaged DataSource' from 'null'





--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659643.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Just on point, did you see a message in logs (please grep into logs/ dir)
like "Adjusting ...."
If so, could you copy/paste those lines?

JLouis


2012/12/14 Romain Manni-Bucau <rm...@gmail.com>

> ok basically
>
> create the following structure:
>
> src
>    main
>        java
>            <your classes in the right package>
>    tomee
>        conf
>           tomee.xml
>
> then install maven
> (
> http://www.apache.org/dyn/closer.cgi/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.zip
> ),
> set in your console JAVA_HOME to your java installation then M2_HOME
> to the folder where maven is (once the zip is extracted) and finally
> add to the path M2_HOME/bin.
>
> then simply run mvn clean package tomee:run
>
> if you need more help i'll be on IRC freenode.net #openejb
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2012/12/14 avrono <av...@neuralm.com>:
> > Maven looks like a minefield which I am not sure I have time to beat.
> Ode for
> > 'make' ...
> >
> > As I understand it you want me to deploy (create) a TomEE Server instance
> > with my WebApp deployed and then send that to you ?
> >
> > I have my TomEE installation /home/TomEE/
> >
> > conf is /home/TomEE/conf (obvuously)
> >
> > And then Eclipse project is /home/workspace/SOMEPRJ (with /build   /src
> > /WebContent)
> >
> >
> > I need some guidance on deploying this in a useful manner
> >
> >
> >
> > --
> > View this message in context:
> http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659635.html
> > Sent from the OpenEJB User mailing list archive at Nabble.com.
>



-- 
Jean-Louis

Re: Unable to configure MYSQL resource in tomee.xml

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

create the following structure:

src
   main
       java
           <your classes in the right package>
   tomee
       conf
          tomee.xml

then install maven
(http://www.apache.org/dyn/closer.cgi/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.zip),
set in your console JAVA_HOME to your java installation then M2_HOME
to the folder where maven is (once the zip is extracted) and finally
add to the path M2_HOME/bin.

then simply run mvn clean package tomee:run

if you need more help i'll be on IRC freenode.net #openejb

Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2012/12/14 avrono <av...@neuralm.com>:
> Maven looks like a minefield which I am not sure I have time to beat. Ode for
> 'make' ...
>
> As I understand it you want me to deploy (create) a TomEE Server instance
> with my WebApp deployed and then send that to you ?
>
> I have my TomEE installation /home/TomEE/
>
> conf is /home/TomEE/conf (obvuously)
>
> And then Eclipse project is /home/workspace/SOMEPRJ (with /build   /src
> /WebContent)
>
>
> I need some guidance on deploying this in a useful manner
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659635.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
Maven looks like a minefield which I am not sure I have time to beat. Ode for
'make' ...

As I understand it you want me to deploy (create) a TomEE Server instance
with my WebApp deployed and then send that to you ?

I have my TomEE installation /home/TomEE/ 

conf is /home/TomEE/conf (obvuously)

And then Eclipse project is /home/workspace/SOMEPRJ (with /build   /src   
/WebContent) 


I need some guidance on deploying this in a useful manner



--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659635.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
https://gist.github.com/4284311 should work,

then add tomee.xml in src/main/tomee/conf and code in src/main/java

to test it locally (once maven is installed): mvn clean package tomee:run

Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2012/12/14 avrono <av...@neuralm.com>:
> Romain,
>
> I have not used Maven before - any chance of getting a minimal pom.xml ?
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659632.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
Romain, 

I have not used Maven before - any chance of getting a minimal pom.xml ?





--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659632.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
Thanks for all your help, especially Romain ...

I have now resolved the issue. For reference

(1) persistence resource and datasource id must be the same
(2) When running in Eclipse make sure that you follow the advanced set-up 
here <http://tomee.apache.org/tomee-and-eclipse.html>   - Eclipse uses local
copies of tomee.xml which are not updated automatically (unless configured
to do so) when you update your /install/tomee/conf/tomee.xml
(3) JMX is useful for debugging. You should launch using jconsole and look
for your dataSource under openejb.managed - if it is not there then there is
something wrong

Onwards, and upwards !



--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659652.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
You should go further using:


$ cat src/main/tomee/conf/tomee.xml

<?xml version="1.0" encoding="UTF-8"?>
<tomee>


<Resource id="jdbc/testDB" type="DataSource">
  IgnoreDefaultValues true
  JdbcDriver com.mysql.jdbc.Driver
  JdbcUrl jdbc:mysql://localhost:3306/test
  UserName root
  Password pwd
  JtaManaged true
  jmxEnabled true
</Resource>


</tomee>

$ cat  src/main/webapp/WEB-INF/persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">

<persistence-unit name="PRSX" transaction-type="JTA">
    <jta-data-source>jdbc/testDB</jta-data-source>
    <class>com.TestEntity</class>
     <properties>
            <property name="openjpa.jdbc.DBDictionary" value="mysql"/>
            <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema"/>
      </properties>
  </persistence-unit>
  </persistence>


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2012/12/14 avrono <av...@neuralm.com>:
> I have put the source here  https://github.com/avrono11/openejb_issue.git
> <https://github.com/avrono11/openejb_issue.git>
>
> I was trying to launch the JSP - addItem.jsp - which has to offending
> datasource
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659644.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
I have put the source here  https://github.com/avrono11/openejb_issue.git
<https://github.com/avrono11/openejb_issue.git>  

I was trying to launch the JSP - addItem.jsp - which has to offending
datasource





--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659644.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
do you think you can reproduce the issue (with tomee-maven-plugin for
instance) and share your sample?

i just tested again and i had no issue.

Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2012/12/14 avrono <av...@neuralm.com>:
> Hi Romain,
>
> It is only in Catalina and not in openejb.mbeans .
> However in opebejb.mbeans there is an entry from web.xml and some defaults
> ....
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659624.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
Hi Romain, 

It is only in Catalina and not in openejb.mbeans . 
However in opebejb.mbeans there is an entry from web.xml and some defaults
....





--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659624.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hmm, isnt the datasource in openejb mbeans?

Please check url and all the config (check tomee didnt adjust some settings)
Le 14 déc. 2012 01:34, "avrono" <av...@neuralm.com> a écrit :

> Hi Romain,
>
> I can see the DataSource using JMX under DataSource and also under Resource
> -> Context
>
>
> Catalina:type=DataSource,context=/PRSX,host=localhost,class=javax.sql.DataSource,name="avronDB"
>
> Is there anything specific I should be looking for ?
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659608.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
Hi Romain, 

I can see the DataSource using JMX under DataSource and also under Resource
-> Context

Catalina:type=DataSource,context=/PRSX,host=localhost,class=javax.sql.DataSource,name="avronDB"

Is there anything specific I should be looking for ?



--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659608.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
can you connect through JMX to check the config of the datasource is
fine please?

maybe you'll need to add jmxEnabled = true in the properties of the
datasource definition

Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2012/12/13 avrono <av...@neuralm.com>:
> Romain,
>
> Yes it is there. I can connect using DriverManager...
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659596.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
Romain,

Yes it is there. I can connect using DriverManager...



--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659596.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by Romain Manni-Bucau <rm...@gmail.com>.
did you put mysql driver in tomee/lib?

Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2012/12/13 avrono <av...@neuralm.com>:
> Hi Neale,
>
>
> Had a similar thought. Will try another Grep ... Not found anything thus
> far.
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659560.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
Hi Neale,


Had a similar thought. Will try another Grep ... Not found anything thus
far.



--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659560.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by Neale <ne...@metawerx.net>.
Hi Avrono,

The hint for me was that I was using MySQL only, and wasn't using hsqldb - 
but the error was hsqldb.

I removed all the hsqldb references and got it working.

It looks like you already removed all the hsqldb refs from tomee.xml though, 
so that's confusing.  Maybe someone else knows where hsqldb is being 
referenced?

As far as I know:
tomee.xml
<Resource> elements
META-INF/context.xml (my preference - and I had to remove the others to get 
this to be recognised)

Romain?  Jean-Louis?

Best Regards,
Neale



----- Original Message ----- 
From: "avrono" <av...@neuralm.com>
To: <us...@openejb.apache.org>
Sent: Friday, December 14, 2012 6:18 AM
Subject: Re: Unable to configure MYSQL resource in tomee.xml


> Hi Neale,
>
> I had the same thought and tried to grep for any other DB references. I
> guess configuration is becomming a minefield. Here is the tomee.xml
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <tomee>
>
>
> <Container id="My Singleton Container" type="SINGLETON">
>  # Specifies the maximum time an invocation could wait for the
>  # singleton bean instance to become available before giving up.
>  #
>  # After the timeout is reached a
> javax.ejb.ConcurrentAccessTimeoutException
>  # will be thrown.
>  #
>  # Usable time units: nanoseconds, microsecons, milliseconds,
>  # seconds, minutes, hours, days.  Or any combination such as
>  # "1 hour and 27 minutes and 10 seconds"
>
>  AccessTimeout = 30 seconds
>
> </Container>
>
>
> <Container id="My Stateful Container" type="STATEFUL">
>  # Specifies the maximum time an invocation could wait for the
>  # stateful bean instance to become available before giving up.
>  #
>  # After the timeout is reached a
> javax.ejb.ConcurrentAccessTimeoutException
>  # will be thrown.
>  #
>  # Usable time units: nanoseconds, microsecons, milliseconds,
>  # seconds, minutes, hours, days.  Or any combination such as
>  # "1 hour and 27 minutes and 10 seconds"
>
>  AccessTimeout = 30 seconds
>
>  #  The passivator is responsible for writing beans to disk
>  #  at passivation time. Different passivators can be used
>  #  by setting this property to the fully qualified class name
>  #  of the PassivationStrategy implementation. The passivator
>  #  is not responsible for invoking any callbacks or other
>  #  processing, its only responsibly is to write the bean state
>  #  to disk.
>  #
>  #  Known implementations:
>  #     org.apache.openejb.core.stateful.RAFPassivater
>  #     org.apache.openejb.core.stateful.SimplePassivater
>
>  Passivator   org.apache.openejb.core.stateful.SimplePassivater
>
>  #  Specifies the time to wait between invocations. This
>  #  value is measured in minutes. A value of 5 would
>  #  result in a time-out of 5 minutes between invocations.
>  #  A value of zero would mean no timeout.
>
>  TimeOut  20
>
>  # Specifies the frequency (in seconds) at which the bean cache is checked
> for
>  # idle beans.
>
>  Frequency 60
>
>  #  Specifies the size of the bean pools for this
>  #  stateful SessionBean container.
>
>  Capacity  1000
>
>  #  Property name that specifies the number of instances
>  #  to passivate at one time when doing bulk passivation.
>  #  Must be less than the PoolSize.
>
>  BulkPassivate  100
>
> </Container>
>
>
> <Container id="My Stateless Container" type="STATELESS">
>
>  # Specifies the time an invokation should wait for an instance
>  # of the pool to become available.
>  #
>  # After the timeout is reached, if an instance in the pool cannot
>  # be obtained, the method invocation will fail.
>  #
>  # Usable time units: nanoseconds, microsecons, milliseconds,
>  # seconds, minutes, hours, days.  Or any combination such as
>  # "1 hour and 27 minutes and 10 seconds"
>
>  AccessTimeout = 30 seconds
>
>  # Specifies the size of the bean pools for this stateless
>  # SessionBean container.  If StrictPooling is not used, instances
>  # will still be created beyond this number if there is demand, but
>  # they will not be returned to the pool and instead will be
>  # immediately destroyed.
>
>  MaxSize = 10
>
>  # Specifies the minimum number of bean instances that should be in
>  # the pool for each bean.  Pools are prefilled to the minimum on
>  # startup.  Note this will create start order dependencies between
>  # other beans that also eagerly start, such as other @Stateless
>  # beans with a minimum or @Singleton beans using @Startup.  The
>  # @DependsOn annotation can be used to appropriately influence
>  # start order.
>  #
>  # The minimum pool size is rigidly maintained.  Instances in the
>  # minimum side of the pool are not eligible for IdleTimeout or
>  # GarbageCollection, but are subject to MaxAge and flushing.
>  #
>  # If the pool is flushed it is immediately refilled to the minimum
>  # size with MaxAgeOffset applied.  If an instance from the minimum
>  # side of the pool reaches its MaxAge, it is also immediately
>  # replaced.  Replacement is done in a background queue using the
>  # number of threads specified by CallbackThreads.
>
>  MinSize = 0
>
>  # StrictPooling tells the container what to do when the pool
>  # reaches it's maximum size and there are incoming requests that
>  # need instances.
>  #
>  # With strict pooling, requests will have to wait for instances to
>  # become available. The pool size will never grow beyond the the
>  # set MaxSize value.  The maximum amount of time a request should
>  # wait is specified via the AccessTimeout setting.
>  #
>  # Without strict pooling, the container will create temporary
>  # instances to meet demand. The instances will last for just one
>  # method invocation and then are removed.
>  #
>  # Setting StrictPooling to false and MaxSize to 0 will result in
>  # no pooling. Instead instances will be created on demand and live
>  # for exactly one method call before being removed.
>
>  StrictPooling = true
>
>  # Specifies the maximum time that an instance should live before
>  # it should be retired and removed from use.  This will happen
>  # gracefully.  Useful for situations where bean instances are
>  # designed to hold potentially expensive resources such as memory
>  # or file handles and need to be periodically cleared out.
>  #
>  # Usable time units: nanoseconds, microsecons, milliseconds,
>  # seconds, minutes, hours, days.  Or any combination such as
>  # "1 hour and 27 minutes and 10 seconds"
>
>  MaxAge = 0 hours
>
>  # Specifies the maximum time that an instance should be allowed to
>  # sit idly in the pool without use before it should be retired and
>  # removed.
>  #
>  # Usable time units: nanoseconds, microsecons, milliseconds,
>  # seconds, minutes, hours, days.  Or any combination such as
>  # "1 hour and 27 minutes and 10 seconds"
>
>  IdleTimeout = 0 minutes
>
> </Container>
>
>
>
>
> <Resource id="avronDB" type="DataSource">
>  JdbcDriver com.mysql.jdbc.Driver
>  JdbcUrl jdbc:mysql:localhost:3306/testDB
>  UserName root
>  Password milena11
>  JtaManaged true
> </Resource>
>
>
>
> <Deployments dir="apps/" />
>
> </tomee>
>
>
>
> --
> View this message in context: 
> http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659554.html
> Sent from the OpenEJB User mailing list archive at Nabble.com. 


Re: Unable to configure MYSQL resource in tomee.xml

Posted by avrono <av...@neuralm.com>.
Hi Neale, 

I had the same thought and tried to grep for any other DB references. I
guess configuration is becomming a minefield. Here is the tomee.xml



<?xml version="1.0" encoding="UTF-8"?>
<tomee>


<Container id="My Singleton Container" type="SINGLETON">
  # Specifies the maximum time an invocation could wait for the
  # singleton bean instance to become available before giving up.
  #
  # After the timeout is reached a
javax.ejb.ConcurrentAccessTimeoutException
  # will be thrown.
  #
  # Usable time units: nanoseconds, microsecons, milliseconds,
  # seconds, minutes, hours, days.  Or any combination such as
  # "1 hour and 27 minutes and 10 seconds"

  AccessTimeout = 30 seconds

</Container>


<Container id="My Stateful Container" type="STATEFUL">
  # Specifies the maximum time an invocation could wait for the
  # stateful bean instance to become available before giving up.
  #
  # After the timeout is reached a
javax.ejb.ConcurrentAccessTimeoutException
  # will be thrown.
  #
  # Usable time units: nanoseconds, microsecons, milliseconds,
  # seconds, minutes, hours, days.  Or any combination such as
  # "1 hour and 27 minutes and 10 seconds"

  AccessTimeout = 30 seconds

  #  The passivator is responsible for writing beans to disk
  #  at passivation time. Different passivators can be used
  #  by setting this property to the fully qualified class name
  #  of the PassivationStrategy implementation. The passivator
  #  is not responsible for invoking any callbacks or other
  #  processing, its only responsibly is to write the bean state
  #  to disk.
  #
  #  Known implementations:
  #     org.apache.openejb.core.stateful.RAFPassivater
  #     org.apache.openejb.core.stateful.SimplePassivater

  Passivator   org.apache.openejb.core.stateful.SimplePassivater

  #  Specifies the time to wait between invocations. This
  #  value is measured in minutes. A value of 5 would
  #  result in a time-out of 5 minutes between invocations.
  #  A value of zero would mean no timeout.

  TimeOut  20

  # Specifies the frequency (in seconds) at which the bean cache is checked
for
  # idle beans.

  Frequency 60

  #  Specifies the size of the bean pools for this
  #  stateful SessionBean container.

  Capacity  1000

  #  Property name that specifies the number of instances
  #  to passivate at one time when doing bulk passivation.
  #  Must be less than the PoolSize.

  BulkPassivate  100

</Container>


<Container id="My Stateless Container" type="STATELESS">

  # Specifies the time an invokation should wait for an instance
  # of the pool to become available.
  #
  # After the timeout is reached, if an instance in the pool cannot
  # be obtained, the method invocation will fail.
  #
  # Usable time units: nanoseconds, microsecons, milliseconds,
  # seconds, minutes, hours, days.  Or any combination such as
  # "1 hour and 27 minutes and 10 seconds"

  AccessTimeout = 30 seconds

  # Specifies the size of the bean pools for this stateless
  # SessionBean container.  If StrictPooling is not used, instances
  # will still be created beyond this number if there is demand, but
  # they will not be returned to the pool and instead will be
  # immediately destroyed.

  MaxSize = 10

  # Specifies the minimum number of bean instances that should be in
  # the pool for each bean.  Pools are prefilled to the minimum on
  # startup.  Note this will create start order dependencies between
  # other beans that also eagerly start, such as other @Stateless
  # beans with a minimum or @Singleton beans using @Startup.  The
  # @DependsOn annotation can be used to appropriately influence
  # start order.
  #
  # The minimum pool size is rigidly maintained.  Instances in the
  # minimum side of the pool are not eligible for IdleTimeout or
  # GarbageCollection, but are subject to MaxAge and flushing.
  #
  # If the pool is flushed it is immediately refilled to the minimum
  # size with MaxAgeOffset applied.  If an instance from the minimum
  # side of the pool reaches its MaxAge, it is also immediately
  # replaced.  Replacement is done in a background queue using the
  # number of threads specified by CallbackThreads.

  MinSize = 0

  # StrictPooling tells the container what to do when the pool
  # reaches it's maximum size and there are incoming requests that
  # need instances.
  #
  # With strict pooling, requests will have to wait for instances to
  # become available. The pool size will never grow beyond the the
  # set MaxSize value.  The maximum amount of time a request should
  # wait is specified via the AccessTimeout setting.
  #
  # Without strict pooling, the container will create temporary
  # instances to meet demand. The instances will last for just one
  # method invocation and then are removed.
  #
  # Setting StrictPooling to false and MaxSize to 0 will result in
  # no pooling. Instead instances will be created on demand and live
  # for exactly one method call before being removed.

  StrictPooling = true

  # Specifies the maximum time that an instance should live before
  # it should be retired and removed from use.  This will happen
  # gracefully.  Useful for situations where bean instances are
  # designed to hold potentially expensive resources such as memory
  # or file handles and need to be periodically cleared out.
  #
  # Usable time units: nanoseconds, microsecons, milliseconds,
  # seconds, minutes, hours, days.  Or any combination such as
  # "1 hour and 27 minutes and 10 seconds"

  MaxAge = 0 hours

  # Specifies the maximum time that an instance should be allowed to
  # sit idly in the pool without use before it should be retired and
  # removed.
  #
  # Usable time units: nanoseconds, microsecons, milliseconds,
  # seconds, minutes, hours, days.  Or any combination such as
  # "1 hour and 27 minutes and 10 seconds"

  IdleTimeout = 0 minutes

</Container>




<Resource id="avronDB" type="DataSource">
  JdbcDriver com.mysql.jdbc.Driver
  JdbcUrl jdbc:mysql:localhost:3306/testDB
  UserName root 
  Password milena11
  JtaManaged true
</Resource>



<Deployments dir="apps/" />

</tomee>



--
View this message in context: http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538p4659554.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Unable to configure MYSQL resource in tomee.xml

Posted by Neale <ne...@metawerx.net>.
Hi Avron,

Can you paste your entire tomee.xml?

I had the same problem when I started using TomEE because of the default 
database definitions in there.  If you remove the other definitions, it 
should use the database you defined.

Best Regards,
Neale

----- Original Message ----- 
From: "avrono" <av...@neuralm.com>
To: <us...@openejb.apache.org>
Sent: Friday, December 14, 2012 5:43 AM
Subject: Unable to configure MYSQL resource in tomee.xml


> Hi,
>
> I am having a problem with configuring a database connection. I Have 
> managed
> to write to the database using   DriverManager but not with @Resource.
>
> I have the following in my tomee.xml
>
> <Resource id="MyDataSource" type="DataSource">
>  JdbcDriver com.mysql.jdbc.Driver
>  JdbcUrl jdbc:mysql://localhost:3306/mydb
>  UserName myuser
>  Password mypass
>  JtaManaged true
> </Resource>
>
>
> in my ManagedBean, I have
>
> @Resource(name="MyDataSource", type=javax.sql.DataSource.class)
> Private DataSource dataSource;
>
>
> I have a @PostConstruct
>
> with ....
>
> try {
>  connection = dataSource.getConnection();
> } catch (Exception ex) {
> ex.printStackTrace();
> }
>
>
> The Connection does not throw an exception , however when I try write to 
> the
> connection
>
> try {
>   stmt = connection.createStatement();
>   stmt.executeUpdate(insert_string)
> } catch (Exception ex) {
>   ex.printStackTrace()
> }
>
>
> I get
>
> Query is <INSERT INTO item values(5454,'fgfgfgfg','2012-12-13
> 18:15:57','2012-12-13 18:15:57','2012-12-27 18:15:57',4334.0)
> java.sql.SQLSyntaxErrorException: user lacks privilege or object not 
> found:
> ITEM
> at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
> at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
> at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
> at org.hsqldb.jdbc.JDBCStatement.executeUpdate(Unknown Source)
> 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
> org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor$StatementProxy.invoke(StatementDecoratorInterceptor.java:238)
> at $Proxy83.executeUpdate(Unknown Source)
> at com.prsx.ItemAdder.addItem(ItemAdder.java:101)
> 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 org.apache.el.parser.AstValue.invoke(AstValue.java:278)
> at 
> org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
> at
> org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:70)
> at
> org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:68)
> at javax.faces.component.UICommand.broadcast(UICommand.java:120)
> at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1028)
> at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:286)
> at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1375)
> at 
> javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
> at
> org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:38)
> at
> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
> at
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> at
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
> at
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
> at
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: org.hsqldb.HsqlException: user lacks privilege or object not
> found: ITEM
> at org.hsqldb.error.Error.error(Unknown Source)
> at org.hsqldb.error.Error.error(Unknown Source)
> at org.hsqldb.SchemaManager.getTable(Unknown Source)
> at org.hsqldb.ParserDQL.readTableName(Unknown Source)
> at org.hsqldb.ParserDQL.readSimpleRangeVariable(Unknown Source)
> at org.hsqldb.ParserDML.compileInsertStatement(Unknown Source)
> at org.hsqldb.ParserCommand.compilePart(Unknown Source)
> at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
> at org.hsqldb.Session.executeDirectStatement(Unknown Source)
> at org.hsqldb.Session.execute(Unknown Source)
>
>
>
> It seems as if my mysql resource is not being correctly picked up ... any
> ideas ?
>
>
>
> --
> View this message in context: 
> http://openejb.979440.n4.nabble.com/Unable-to-configure-MYSQL-resource-in-tomee-xml-tp4659538.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.