Hello
Before digging deeper in your problem a small note on this one: since you
encounter some issue with the doc I would love you to try to enrich/rewrite
some part of it to make it smoother for next newcomer. Would it be possible?
Next about your issue:
- you don't need to set class-name which is intended for custom resources
(DataSource are "known" resources)
- unusedProperty is one word cause it is a method name (we can surely
enrich the message BTW). Means you set a property but this one doesn't
exist on the created instance (the connection pool there). That's one
smooth way to say the configuration is wrong but doesn't prevent to run.
- using jdbc/sus2 you can use @Resource(name = "jdbc/sus2") DataSource ds;
or do a lookup on openejb:Resource/jdbc/sus2 or java:openejb/Resource/
jdbc/sus2
- about maven: ${user.home}/.m2/repository is the default base, you can
override it to openejb.m2.home system property (in conf/system.properties
for instance). If this folder doesn't exist we'll read the default
settings.xml to get the localRespository value.
- about your "strange" error: tomee Resource attributes are about the
resource factory and body of Resource tag is the list of properties used to
set instance attributes. Tomcat put everything as attributes. This is why
you got this error.
- last point: we support some bridge between historical tomee definitions
and tomcat datasources (to make the migration smooth) so you can still use
JdbcDriver, UserName, Password, JdbcUrl:
<Resource id="jdbc/sus2" type="DataSource" classpath="mvn:oracle:ojdbc6:
11.2.0.3">
JdbcDriver = oracle.jdbc.driver.OracleDriver
MaxActive = 5
MaxIdle = 2
MaxWait = 10000
JdbcUrl = jdbc:oracle:thin:@<host>:1521:<sid>
UserName = <userid>
Password = <password>
</Resource>
Advantage of keeping these properties is the same definition will run with
openejb (understand tomee without tomcat and embedded) which is a great way
to debug a weird case reusing the same data as in tomee.
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>
2016-08-03 1:21 GMT+02:00 KARR, DAVID <[email protected]>:
> I may be making some progress. Working from
> http://tomee.apache.org/tomee-and-eclipse.html , it appears that the
> "tomeee.xml" file that I edited in the Tomee distro is not used in
> Eclipse. I used the "Import" feature as described to copy the file into
> the server defined in Eclipse. At that point, I got an error like this:
> ---------------------
> org.apache.openejb.OpenEJBException:
> Unable to read OpenEJB configuration file at
> <workspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\tomee.xml:
> Unsupported Attribute(s): maxActive, maxIdle, maxWait, driverClassName,
> url, username, password.
> Supported Attributes are: type, jar, provider, id, class-name,
> constructor, factory-name, classpath, jndi, aliases, properties-provider,
> property-provider, depends-on. If the setting is a configuration property
> it must be placed inside the element body.
> ---------------------
>
> Really strange.
>
> I then modified the imported "tomee.xml" file, resulting in the following
> approximate Resource definition:
> --------------------
> <Resource id="jdbc/sus2" type="DataSource"
> classpath="mvn:oracle:ojdbc6:11.2.0.3"
> class-name="oracle.jdbc.driver.OracleDriver">
> maxActive = 5
> maxIdle = 2
> maxWait = 10000
> url = jdbc:oracle:thin:@<host>:1521:<sid>
> username = <userid>
> password = <password>
> </Resource>
> --------------
>
> When I start up the server, I see the following in the console:
> ------------------
> Aug 02, 2016 4:13:03 PM org.apache.openejb.config.ConfigurationFactory
> configureService
> INFO: Configuring Service(id=jdbc/sus2, type=Resource,
> provider-id=jdbc/sus2)
> Aug 02, 2016 4:13:03 PM org.apache.openejb.util.OptionsLog info
> INFO: Using 'openejb.deployments.classpath=false'
> Aug 02, 2016 4:13:03 PM org.apache.openejb.assembler.classic.Assembler
> createRecipe
> INFO: Creating TransactionManager(id=Default Transaction Manager)
> Aug 02, 2016 4:13:03 PM org.apache.openejb.assembler.classic.Assembler
> createRecipe
> INFO: Creating SecurityService(id=Tomcat Security Service)
> Aug 02, 2016 4:13:03 PM org.apache.openejb.assembler.classic.Assembler
> createRecipe
> INFO: Creating Resource(id=jdbc/sus2)
> Aug 02, 2016 4:13:03 PM org.apache.openejb.assembler.classic.Assembler
> unusedProperty
> WARNING: unusedProperty maxActive - jdbc/sus2
> Aug 02, 2016 4:13:03 PM org.apache.openejb.assembler.classic.Assembler
> unusedProperty
> WARNING: unusedProperty maxIdle - jdbc/sus2
> Aug 02, 2016 4:13:03 PM org.apache.openejb.assembler.classic.Assembler
> unusedProperty
> WARNING: unusedProperty maxWait - jdbc/sus2
> Aug 02, 2016 4:13:03 PM org.apache.openejb.assembler.classic.Assembler
> unusedProperty
> WARNING: unusedProperty url - jdbc/sus2
> Aug 02, 2016 4:13:03 PM org.apache.openejb.assembler.classic.Assembler
> unusedProperty
> WARNING: unusedProperty username - jdbc/sus2
> Aug 02, 2016 4:13:03 PM org.apache.openejb.assembler.classic.Assembler
> unusedProperty
> WARNING: unusedProperty password - jdbc/sus2
> -----------------
>
> I don't understand what "unusedProperty" means (weird that it's just one
> word).
>
> When I later try to reference that resource, I get the following:
> --------------------
> javax.naming.NameNotFoundException: Name [jdbc/sus2] is not bound in this
> Context. Unable to find [jdbc].
> --------------------
>
> It's not clear to me whether that Resource definition put anything into
> the JNDI context, or whether I'm just using the wrong JNDI path to
> reference it.
>
> -----Original Message-----
> From: Daniel Cunha [mailto:[email protected]]
> Sent: Tuesday, August 02, 2016 2:10 PM
> To: TomEE Users <[email protected]>
> Subject: Re: Define datasource, reference JDBC driver, and see init in
> console
>
> Hi David,
>
> yea, resources on TomEE is a mix (XML/Properties) Your definition should
> following the pattern:
> <Resource id="jdbc/sus2" type="DataSource">
> maxActive = 5
> maxIdle = 2
> maxWait = 10000
> driverClassName = oracle.jdbc.driver.OracleDriver
> url = jdbc:oracle:thin:@<host>:1521:<sid>
> username = <user>
> password = <password>
> </Resource>
>
> References you can see here:
> http://tomee.apache.org/datasource-config.html
> About maven, should be enough have the configuration in your settings.xml.
> :)
>
> On Tue, Aug 2, 2016 at 5:52 PM, KARR, DAVID <[email protected]> wrote:
>
> > (I posted this first to tomcat-user, but I realized technically it
> > should go to tomee-user. I apologize if this is a duplicate for you.
> > In any case, this note has a little more info than the first note.)
> >
> > I'm attempting to use Tomcat(tomee) to run a REST service that will
> > return some data from some SQL queries (Oracle). I've installed Tomee
> > 7.0.1, which uses Tomcat 8.5.3.
> >
> > The JDBC driver is available from a private enterprise maven repo.
> > I'd prefer to get it from there, as opposed to storing it locally. I
> > noticed at http://tomee.apache.org/configuring-datasources.html ,
> > there is the possible notation of "mvn:g:a:v" for the "classpath"
> > attribute. However, I don't see any way to configure the Maven
> repositories this will reference.
> > How do I tell it to look in a particular repo for this? Would it just
> > implicitly use my $HOME/.m2/settings.xml file?
> >
> > My Resource definition in "conf/tomee.xml" looks something like this:
> > -----------------------
> > <Resource id="jdbc/sus2" type="DataSource"
> > maxActive="5" maxIdle="2" maxWait="10000"
> > driverClassName="oracle.jdbc.driver.OracleDriver"
> > url="jdbc:oracle:thin:@<host>:1521:<sid>"
> > username="<user>" password="<password>"/>
> > ----------------
> >
> > Does this look correct? I find the Tomcat docs confusing, with
> > respect to the required syntax for this. It's not clear whether a
> > pure XML syntax is required, or a mixed XML/property syntax.
> >
> > If I start the instance, should I see any default output that will
> > show Tomcat connecting to this datasource? If it doesn't show this by
> > default, is there a way to turn this on?
> >
> > I tried writing the code to obtain the JNDI resource (Spring context
> > references), but it just says it can't find it (fails at "jdbc"), so
> > perhaps my Resource definition was ignored, or my JNDI path is wrong.
> >
>
>
>
> --
> Daniel Cunha
> https://twitter.com/dvlc_
> http://www.tomitribe.com
> http://www.tomitribe.io
>