Fw: Re: Help needed - JPA probem - No connection specified with project

2017-10-08 Thread Karen Goh
Hi,

I have been trying to get a reply on this but seems like nobody can help me on 
this.
Till today, no matter what I did, I still get a JPA - no connection specified 
with project.

Can someone give me a tutorial that uses Javax JPA that works with JDBC mysql ?

Thanks!

--- On Mon, 10/2/17, Karen Goh <karenwo...@yahoo.com> wrote:

> From: Karen Goh <karenwo...@yahoo.com>
> Subject: Re: Help needed - JPA probem - No connection specified with project
> To: knst.koli...@gmail.com
> Cc: "Tomcat Users List" <users@tomcat.apache.org>
> Date: Monday, October 2, 2017, 4:01 PM
> 
> 
> On Fri, 9/29/17, Konstantin Kolinko
> <knst.koli...@gmail.com>
> wrote:
> 
>  Subject: Re: Help needed - JPA probem
> - No connection specified with project
>  To: "Karen Goh" <karenwo...@yahoo.com>
>  Cc: "Tomcat Users List" <users@tomcat.apache.org>
>  Date: Friday, September 29, 2017, 9:16
> PM
>  
>  >>
>  >>  1. See a link to Eclipse
> IDE FAQ
>  here:
>  >>
>  >>  https://wiki.apache.org/tomcat/FAQ/Developing#Q6
>  
>  The actual Tomcat
>  configuration that is running is in
> 
> ".metadata/.plugins/org.eclipse.wst.server.core"
>  directory (the
>  Eclipse Web Tools FAQ should
>  provide more pointers). There may be
>  situations when it becomes stale.
>  
>  >>  2. See the
>  >>  following thread on how to
> turn on
>  "Publish module
>  >>  context to
>  separate XML files" option in
> Eclipse.
>  >>
>  >>  By
>  default
>  >>  (without that option)
>  Eclipse IDE places 
>  >>  elements into server.xml,
> which is a
>  rather
>  >>  discourage practice.
>  >>
>  >>  http://markmail.org/message/7zkyocvph56b6t6q
>  >
>  > OK.  I managed to
>  turn on "Publish module context..but
> my problem of
>  context not bound is still there.
>  >
>  >>  3.
>  >> 
>  Documentation on Context:
>  >>
>  >>  http://tomcat.apache.org/tomcat-8.0-doc/config/context.html
>  >>
>  >>  The
>   element in
>  >>  your
>  context.xml has a lot of attributes
> that
>  >>  should not be there,
> starting
>  with
>  >>  "debug". What
>  (bad) example were
>  >>  they copied
>  from?
>  >
>  >  4. The
>  current version of
>  >  Tomcat 8.0 is
>  8.0.46.
>  >  There were security
>  >  fixes in Java as well (8u141
> was a
>  security update
>  >  in July 2017)
>  >
>  >  Also EOL date for
>  Tomcat 8.0 has been
>  >  announced. Users
>  are advised to
>  >  migrate to
>  >  8.5.
>  >  http://tomcat.apache.org/tomcat-80-eol.html
>  >
>  > Hi kolinko, I have
>  now installed Tomcat 8.5.20 but same
> problem.
>  
>  Even if it is "the same
>  problem", it 'd better if you provide
> the
>  actual log messages and stacktraces.
> Those
>  differ between versions.
>  
> Here's my latest error in which I
> really don't know what have cause the JPA no connection is
> specified :
> 
> INFO: Starting service Catalina
> Oct 02, 2017 3:53:51 PM
> org.apache.catalina.core.StandardEngine startInternal
> INFO: Starting Servlet Engine: Apache
> Tomcat/8.0.29
> Oct 02, 2017 3:53:52 PM
> org.apache.catalina.startup.HostConfig deployDescriptor
> INFO: Deploying configuration
> descriptor C:\Users\Karen Goh Seow
> Hui\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\conf\Catalina\localhost\Hi5S.xml
> Oct 02, 2017 3:53:53 PM
> org.apache.catalina.startup.SetContextPropertiesRule begin
> WARNING:
> [SetContextPropertiesRule]{Context} Setting property
> 'source' to 'org.eclipse.jst.jee.server:Hi5S' did not find a
> matching property.
> Oct 02, 2017 3:53:57 PM
> org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory
> getObjectInstance
> INFO: Name = hi5 Ignoring unknown
> property: value of "" for "description" property
> Oct 02, 2017 3:53:57 PM
> org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory
> getObjectInstance
> INFO: Name = hi5 Ignoring unknown
> property: value of "" for "mappedName" property
> Oct 02, 2017 3:53:58 PM
> org.apache.jasper.servlet.TldScanner scanJars
> INFO: At least one JAR was scanned for
> TLDs yet contained no TLDs. Enable debug logging for this
> logger for a complete list of JARs that were scanned but no
> TLDs were found in them. Skipping unneeded JARs during
> scanning can improve startup time and JSP compilation t

Re: Help needed - JPA probem - No connection specified with project

2017-10-02 Thread Karen Goh


On Fri, 9/29/17, Konstantin Kolinko <knst.koli...@gmail.com> wrote:

 Subject: Re: Help needed - JPA probem - No connection specified with project
 To: "Karen Goh" <karenwo...@yahoo.com>
 Cc: "Tomcat Users List" <users@tomcat.apache.org>
 Date: Friday, September 29, 2017, 9:16 PM
 
 >>
 >>  1. See a link to Eclipse IDE FAQ
 here:
 >>
 >>  https://wiki.apache.org/tomcat/FAQ/Developing#Q6
 
 The actual Tomcat
 configuration that is running is in
 ".metadata/.plugins/org.eclipse.wst.server.core"
 directory (the
 Eclipse Web Tools FAQ should
 provide more pointers). There may be
 situations when it becomes stale.
 
 >>  2. See the
 >>  following thread on how to turn on
 "Publish module
 >>  context to
 separate XML files" option in Eclipse.
 >>
 >>  By
 default
 >>  (without that option)
 Eclipse IDE places 
 >>  elements into server.xml, which is a
 rather
 >>  discourage practice.
 >>
 >>  http://markmail.org/message/7zkyocvph56b6t6q
 >
 > OK.  I managed to
 turn on "Publish module context..but my problem of
 context not bound is still there.
 >
 >>  3.
 >> 
 Documentation on Context:
 >>
 >>  http://tomcat.apache.org/tomcat-8.0-doc/config/context.html
 >>
 >>  The
  element in
 >>  your
 context.xml has a lot of attributes that
 >>  should not be there, starting
 with
 >>  "debug". What
 (bad) example were
 >>  they copied
 from?
 >
 >  4. The
 current version of
 >  Tomcat 8.0 is
 8.0.46.
 >  There were security
 >  fixes in Java as well (8u141 was a
 security update
 >  in July 2017)
 >
 >  Also EOL date for
 Tomcat 8.0 has been
 >  announced. Users
 are advised to
 >  migrate to
 >  8.5.
 >  http://tomcat.apache.org/tomcat-80-eol.html
 >
 > Hi kolinko, I have
 now installed Tomcat 8.5.20 but same problem.
 
 Even if it is "the same
 problem", it 'd better if you provide the
 actual log messages and stacktraces. Those
 differ between versions.
 
Here's my latest error in which I really don't know what have cause the JPA no 
connection is specified :

INFO: Starting service Catalina
Oct 02, 2017 3:53:51 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.29
Oct 02, 2017 3:53:52 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\Users\Karen Goh Seow 
Hui\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\conf\Catalina\localhost\Hi5S.xml
Oct 02, 2017 3:53:53 PM org.apache.catalina.startup.SetContextPropertiesRule 
begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 
'org.eclipse.jst.jee.server:Hi5S' did not find a matching property.
Oct 02, 2017 3:53:57 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory 
getObjectInstance
INFO: Name = hi5 Ignoring unknown property: value of "" for "description" 
property
Oct 02, 2017 3:53:57 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory 
getObjectInstance
INFO: Name = hi5 Ignoring unknown property: value of "" for "mappedName" 
property
Oct 02, 2017 3:53:58 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug 
logging for this logger for a complete list of JARs that were scanned but no 
TLDs were found in them. Skipping unneeded JARs during scanning can improve 
startup time and JSP compilation time.
2017-10-02 15:53:59,962 localhost-startStop-1 ERROR Error processing element 
Configuration ([Configuration: null]): CLASS_NOT_FOUND
2017-10-02 15:54:00,324 localhost-startStop-1 ERROR No ConnectionSource 
provided: connectionSource
2017-10-02 15:54:00,327 localhost-startStop-1 ERROR Unable to inject fields 
into builder class for plugin type class 
org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender, element Jdbc. 
org.apache.logging.log4j.core.config.ConfigurationException: Arguments given 
for element Jdbc are invalid
at 
org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:198)
at 
org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
at 
org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:952)
at 
org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:892)
at 
org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:884)
at 
org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:508)
at 
org.apache.logging.log4j.core.config.AbstractConfiguratio

Re: Help needed - JPA probem - No connection specified with project

2017-09-29 Thread Konstantin Kolinko
>>
>>  1. See a link to Eclipse IDE FAQ here:
>>
>>  https://wiki.apache.org/tomcat/FAQ/Developing#Q6

The actual Tomcat configuration that is running is in
".metadata/.plugins/org.eclipse.wst.server.core" directory (the
Eclipse Web Tools FAQ should provide more pointers). There may be
situations when it becomes stale.

>>  2. See the
>>  following thread on how to turn on "Publish module
>>  context to separate XML files" option in Eclipse.
>>
>>  By default
>>  (without that option) Eclipse IDE places 
>>  elements into server.xml, which is a rather
>>  discourage practice.
>>
>>  http://markmail.org/message/7zkyocvph56b6t6q
>
> OK.  I managed to turn on "Publish module context..but my problem of context 
> not bound is still there.
>
>>  3.
>>  Documentation on Context:
>>
>>  http://tomcat.apache.org/tomcat-8.0-doc/config/context.html
>>
>>  The  element in
>>  your context.xml has a lot of attributes that
>>  should not be there, starting with
>>  "debug". What (bad) example were
>>  they copied from?
>
>  4. The current version of
>  Tomcat 8.0 is 8.0.46.
>  There were security
>  fixes in Java as well (8u141 was a security update
>  in July 2017)
>
>  Also EOL date for Tomcat 8.0 has been
>  announced. Users are advised to
>  migrate to
>  8.5.
>  http://tomcat.apache.org/tomcat-80-eol.html
>
> Hi kolinko, I have now installed Tomcat 8.5.20 but same problem.

Even if it is "the same problem", it 'd better if you provide the
actual log messages and stacktraces. Those differ between versions.

>>  5. Your
>>  META-INF/context.xml is broken: [...]
>>
>
> I have changed my context.xml as follows :
>
> 
> 

"path" and "docBase" should not be here.

>  name="jdbc/hi5"
> auth="Container"
> type="javax.sql.DataSource"
> maxTotal="8"
> maxActive="100"
> maxIdle="30"
> maxWait="-1"
> username="root"
> singleton="true"
> override="true"
> factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
> password="password"
>alternateUsernameAllowed="true"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost:3306/hi5" />
>
>
> And my web.xml ;
>
> 
> http://www.w3.org/2001/XMLSchema-instance; 
> xmlns="http://xmlns.jcp.org/xml/ns/javaee; 
> xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
> http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd; version="3.1">
>   Hi5S
>   
> Index.jsp

Are you sure? Usually the name of a welcome file is "index.jsp" (lowercase).

>   
>   
> MySQL dataSource
> JDBC/hi5

"JDBC/hi5" here != "jdbc/hi5" used in your Resource

Case matters.

> javax.sql.DataSource
> Container
>   
>
> util.HibernateSessionFactoryListener 
> // I do not know if this is necessary.  Wld like to have your comments. Tks.
> 
> 

Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Help needed - JPA probem - No connection specified with project

2017-09-29 Thread Guang Chao
On Fri, Sep 22, 2017 at 6:35 PM, Karen Goh 
wrote:

> Hi expert,
>
> I have been trying very hard to nail the above problem including asking
> various forums like CodeRanch, dream in code etc but to no avail.
>
> As such, I am hoping to get help from the Apache Tomcat user support.
>
> Tools and setting : Eclipse Mars, Tomcat 1.8, MySQL, OS : Windows 7,
> Maven, Java JPA with Hibernate framework 5.1.0
>
> The MySQL setting is confirmed correct, as I have managed to insert the
> data via single JDBC connection.
>
> Project summary : J2ee servlet with JSP, Java JPA in Hibernate framework.
> (Hibernate is for pure insertion of data - many to many relationship)
>
> My purpose is to get the JNDI datasource working but till now I can't just
> get it work.
>
> Here's my context.xml :
>
> 
>  antiResourceLocking="true" debug="1">
>  type="javax.sql.DataSource"/>
> 
> name="jdbc/hi5"
> auth="Container"
> type="javax.sql.DataSource"
> maxTotal="8"
> maxActive="100"
> maxIdle="30"
> maxWait="-1"
> username="root"
> singleton="true"
> override="true"
> factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
> password="password"
>   alternateUsernameAllowed="true"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost:3306/hi5" />
>   
>   
>
>
I review again original, can you remove the factory here and try?
 factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"


> Here's my web.xml:
>
> 
> http://www.w3.org/2001/XMLSchema-instance; xmlns="
> http://xmlns.jcp.org/xml/ns/javaee; xsi:schemaLocation="http://
> xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/
> javaee/web-app_3_1.xsd" version="3.1">
>   Hi5S
>   
> Index.jsp
>   
>   
> MySQL Datasource
> jdbc/hi5
> javax.sql.DataSource
> Container
>   
>
> 
>
> And my singletonDatasource class:
>
> package util;
>
>
> import java.sql.Connection;
> import java.sql.SQLException;
>
> import javax.annotation.Resource;
> import javax.naming.Context;
> import javax.naming.InitialContext;
> import javax.naming.NamingException;
> import javax.sql.DataSource;
>
>
> @Resource(name = "jdbc/hi5")
> public class SingletonDBConnection{
>
> private static SingletonDBConnection singleInstance;
> private static DataSource dataSource;
> private static Connection dbConnect;
>
> private SingletonDBConnection() {
> try {
> Context initContext = new InitialContext();
> Context envContext = (Context) initContext.lookup("java:/
> comp/env");
> dataSource = (DataSource) envContext.lookup("jdbc/hi5");
>
> try {
> dbConnect = dataSource.getConnection();
> } catch (SQLException e) {
> e.printStackTrace();
> }
> } catch (NamingException e) {
> e.printStackTrace();
> }
> }
>
>
> public static DataSource getMySQLDataSource() { // using apacheDBCP
> if (singleInstance == null) {
> synchronized (SingletonDBConnection.class) {
> if (singleInstance == null) {
> singleInstance = new SingletonDBConnection();
> }
> }
> }
>
> return (DataSource) singleInstance;
> }
>
> public static DataSource getConnInst() {
> try {
> dbConnect = dataSource.getConnection();
> } catch (SQLException e1) {
> e1.printStackTrace();
> }
>
> if (dbConnect == null) {
> try {
> Context initContext = new InitialContext();
> Context envContext = (Context) initContext.lookup("java:/
> comp/env");
> dataSource = (DataSource) envContext.lookup("jdbc/hi5");
>
> try {
> dbConnect = dataSource.getConnection();
> } catch (SQLException e) {
> e.printStackTrace();
> }
> } catch (NamingException e) {
> e.printStackTrace();
> }
> }
>
> return dataSource;
> }
>
> }
>
>
> And the persistence.xml ;
>
> 
> http://xmlns.jcp.org/xml/ns/persistence;
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="
> http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/
> persistence/persistence_2_1.xsd">
> 
> model.Subject
> model.Tutor
>
> 
> 
>value="java:comp/env/jdbc/hi5"/>
>
> 
> 
>
> 
>
> As the mailing list does not allow large error attachment, therefore, I am
> appending the error below :
>
> Sep 22, 2017 5:59:46 PM org.apache.tomcat.util.digester.SetPropertiesRule
> begin
> WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting
> property 'debug' to '1' did not find a matching property.
> Sep 22, 2017 5:59:46 PM org.apache.tomcat.util.digester.SetPropertiesRule
> begin
> WARNING: 

Re: Help needed - JPA probem - No connection specified with project

2017-09-28 Thread Karen Goh


On Thu, 9/28/17, Guang Chao <guang.chao.1...@gmail.com> wrote:

 Subject: Re: Help needed - JPA probem - No connection specified with project
 To: "Tomcat Users List" <users@tomcat.apache.org>, "Karen Goh" 
<karenwo...@yahoo.com>
 Date: Thursday, September 28, 2017, 1:25 PM
 
 On Thu, Sep 28, 2017 at 12:57 PM,
 Karen Goh <karenwo...@yahoo.com.invalid>
 wrote:
 
 >
 >
 
 > On Tue, 9/26/17, Konstantin Kolinko <knst.koli...@gmail.com>
 wrote:
 >
 >  Subject:
 Re: Help needed - JPA probem - No connection specified
 with
 > project
 >  To:
 "Tomcat Users List" <users@tomcat.apache.org>
 >  Date: Tuesday, September 26, 2017, 8:52
 AM
 >
 >  2017-09-25
 18:02 GMT+03:00 Karen
 >  Goh <karenwo...@yahoo.com>:
 >  > Hi Kolinko,
 > 
 >
 >  > I have now removed the
 ResourceLink and
 >  left with Resource
 in my context.xml which is resided at
 > 
 WebContent/META-INF.
 >  >
 >  > And this is C:\Program
 Files\Apache
 >  Software
 Foundation\Tomcat 8.0\conf\context.xml
 >  >
 >  >
   version="1.0"
 encoding="UTF-8"?>
 >  >
 
 >  >
 >  >    
 
 >  >     
 >  >
 > 
 WEB-INF/web.xml
 >  >
 > 
 ${catalina.base}/conf/web.xml
 >  >
 >  >    
 
 >  >     
 > 
 >
 >  >     
 >  >    
 
 >  >
 > 
 
 >  >
 >  >
 >  And
 here's my web.xml :
 >  >
 >  >   encoding="UTF-8"?>
 >  >
 >  http://www.w3.org/2001/XMLSchema-instance;
 >  xmlns="http://xmlns.jcp.org/xml/ns/javaee;
 >  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
 > http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd;
 >  version="3.1">
 >  >
 > 
 Hi5S
 >  >   
 >  >
 > 
 Index.jsp
 >  >   
 >  >   
 >  >     MySQL
 >  Datasource
 >  >
 > 
 jdbc/hi5
 >  >
 > 
 javax.sql.DataSource
 >  >
 > 
 Container
 >  >   
 >  >
 >  >
 
 >  >
 >  > The error remains the
 >  same and my Tomcat failed to start,
 despite I cleaned them
 >  etc etc.
 >  >
 >  > SEVERE:
 A
 >  child container failed during
 start
 >  >
 > 
 java.util.concurrent.ExecutionException:
 >  org.apache.catalina.LifecycleException:
 Failed to start
 >  component
 > 
 [StandardEngine[Catalina].StandardHost[localhost]]
 >  >
 >  > Could
 you advise how
 >  to go about making it
 work ?
 >
 >  Mailing
 list rules:
 >  http://tomcat.apache.org/lists.html#tomcat-users
 >  -> Top-posting is bad.
 >
 > Ok. Tks, now I follow
 your requirements.
 >
 >
 >  1. See a link to
 Eclipse IDE FAQ here:
 >
 >  https://wiki.apache.org/tomcat/FAQ/Developing#Q6
 >
 >
 >  2. See the
 > 
 following thread on how to turn on "Publish module
 >  context
 >  to
 separate XML files" option
 >  in
 Eclipse.
 >
 >  By
 default
 >  (without that option) Eclipse
 IDE places 
 > 
 elements
 >  into server.xml, which is a
 rather
 >  discourage practice.
 >
 >  http://markmail.org/message/7zkyocvph56b6t6q
 >
 >
 >
 OK.  I managed to turn on "Publish module context..but
 my problem of
 > context not bound is
 still there.
 >
 > 
 3.
 >  Documentation on Context:
 >
 >  http://tomcat.apache.org/tomcat-8.0-doc/config/context.html
 >
 >  The 
 element in
 >  your context.xml has a lot
 of attributes that
 >  should not be
 there, starting with
 > 
 "debug". What (bad) example were
 >  they copied from?
 >
 >
 >  4. The current version of
 >  Tomcat 8.0 is 8.0.46.
 >  There were security
 >  fixes in Java as well (8u141 was a
 security update
 >  in July 2017)
 >
 >  Also EOL date for
 Tomcat 8.0 has been
 >  announced. Users
 are advised to
 >  migrate to
 >  8.5.
 >  http://tomcat.apache.org/tomcat-80-eol.html
 >
 > Hi kolinko, I have
 now installed Tomcat 8.5.20 but same problem.
 >
 >
 >
 >
 >  5. Your
 > 
 META-INF/context.xml is broken:
 > 
 [[[
 >    // here is
 rogue
 >  ">", thus your
 Resource has no name (all
 >  the
 following is plain text, not attributes)
 >  and thus NPE happens
 >
 > 
 name="jdbc/hi5"
 >
 >  auth="Container"
 >
 > 
 type="javax.sql.DataSource"
 >
 > 
 maxTotal="8"
 >
 >  maxActive="100"
 >
 > 
 maxIdle="30"
 >
 >  maxWait="-1"
 >
 > 
 username="root"
 >
 >  singleton="true"
 >
 > 
 override="true"
 >
 > 
 factory="or

Re: Help needed - JPA probem - No connection specified with project

2017-09-27 Thread Guang Chao
On Thu, Sep 28, 2017 at 12:57 PM, Karen Goh <karenwo...@yahoo.com.invalid>
wrote:

>
> 
> On Tue, 9/26/17, Konstantin Kolinko <knst.koli...@gmail.com> wrote:
>
>  Subject: Re: Help needed - JPA probem - No connection specified with
> project
>  To: "Tomcat Users List" <users@tomcat.apache.org>
>  Date: Tuesday, September 26, 2017, 8:52 AM
>
>  2017-09-25 18:02 GMT+03:00 Karen
>  Goh <karenwo...@yahoo.com>:
>  > Hi Kolinko,
>  >
>  > I have now removed the ResourceLink and
>  left with Resource in my context.xml which is resided at
>  WebContent/META-INF.
>  >
>  > And this is C:\Program Files\Apache
>  Software Foundation\Tomcat 8.0\conf\context.xml
>  >
>  >   version="1.0" encoding="UTF-8"?>
>  > 
>  >
>  > 
>  > 
>  >
>  WEB-INF/web.xml
>  >
>  ${catalina.base}/conf/web.xml
>  >
>  > 
>  > 
>  >
>  > 
>  > 
>  >
>  
>  >
>  >
>  And here's my web.xml :
>  >
>  >   encoding="UTF-8"?>
>  >
>  http://www.w3.org/2001/XMLSchema-instance;
>  xmlns="http://xmlns.jcp.org/xml/ns/javaee;
>  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
> http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd;
>  version="3.1">
>  >
>  Hi5S
>  >   
>  >
>  Index.jsp
>  >   
>  >   
>  > MySQL
>  Datasource
>  >
>  jdbc/hi5
>  >
>  javax.sql.DataSource
>  >
>  Container
>  >   
>  >
>  > 
>  >
>  > The error remains the
>  same and my Tomcat failed to start, despite I cleaned them
>  etc etc.
>  >
>  > SEVERE: A
>  child container failed during start
>  >
>  java.util.concurrent.ExecutionException:
>  org.apache.catalina.LifecycleException: Failed to start
>  component
>  [StandardEngine[Catalina].StandardHost[localhost]]
>  >
>  > Could you advise how
>  to go about making it work ?
>
>  Mailing list rules:
>  http://tomcat.apache.org/lists.html#tomcat-users
>  -> Top-posting is bad.
>
> Ok. Tks, now I follow your requirements.
>
>
>  1. See a link to Eclipse IDE FAQ here:
>
>  https://wiki.apache.org/tomcat/FAQ/Developing#Q6
>
>
>  2. See the
>  following thread on how to turn on "Publish module
>  context
>  to separate XML files" option
>  in Eclipse.
>
>  By default
>  (without that option) Eclipse IDE places 
>  elements
>  into server.xml, which is a rather
>  discourage practice.
>
>  http://markmail.org/message/7zkyocvph56b6t6q
>
>
> OK.  I managed to turn on "Publish module context..but my problem of
> context not bound is still there.
>
>  3.
>  Documentation on Context:
>
>  http://tomcat.apache.org/tomcat-8.0-doc/config/context.html
>
>  The  element in
>  your context.xml has a lot of attributes that
>  should not be there, starting with
>  "debug". What (bad) example were
>  they copied from?
>
>
>  4. The current version of
>  Tomcat 8.0 is 8.0.46.
>  There were security
>  fixes in Java as well (8u141 was a security update
>  in July 2017)
>
>  Also EOL date for Tomcat 8.0 has been
>  announced. Users are advised to
>  migrate to
>  8.5.
>  http://tomcat.apache.org/tomcat-80-eol.html
>
> Hi kolinko, I have now installed Tomcat 8.5.20 but same problem.
>
>
>
>
>  5. Your
>  META-INF/context.xml is broken:
>  [[[
>// here is rogue
>  ">", thus your Resource has no name (all
>  the following is plain text, not attributes)
>  and thus NPE happens
>
>  name="jdbc/hi5"
>
>  auth="Container"
>
>  type="javax.sql.DataSource"
>
>  maxTotal="8"
>
>  maxActive="100"
>
>  maxIdle="30"
>
>  maxWait="-1"
>
>  username="root"
>
>  singleton="true"
>
>  override="true"
>
>  factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
>  password="password"
>
>  alternateUsernameAllowed="true"
>
>driverClassName="com.mysql.jdbc.Driver"
>
>  url="jdbc:mysql://localhost:3306/hi5" />  //
>  You either use /> or
>  ,
>  not both.
>
>  ]]]
>
>
> I have changed my context.xml as follows :
>
> 
>  >
>  name="jdbc/hi5"
> auth="Container"
> type="java

Re: Help needed - JPA probem - No connection specified with project

2017-09-27 Thread Karen Goh


On Tue, 9/26/17, Konstantin Kolinko <knst.koli...@gmail.com> wrote:

 Subject: Re: Help needed - JPA probem - No connection specified with project
 To: "Tomcat Users List" <users@tomcat.apache.org>
 Date: Tuesday, September 26, 2017, 8:52 AM
 
 2017-09-25 18:02 GMT+03:00 Karen
 Goh <karenwo...@yahoo.com>:
 > Hi Kolinko,
 >
 > I have now removed the ResourceLink and
 left with Resource in my context.xml which is resided at
 WebContent/META-INF.
 >
 > And this is C:\Program Files\Apache
 Software Foundation\Tomcat 8.0\conf\context.xml
 >
 > 
 > 
 >
 >     
 >     
 >    
 WEB-INF/web.xml
 >    
 ${catalina.base}/conf/web.xml
 >
 >     
 >     
 >
 >     
 >     
 >
 
 >
 >
 And here's my web.xml :
 >
 > 
 >
 http://www.w3.org/2001/XMLSchema-instance;
 xmlns="http://xmlns.jcp.org/xml/ns/javaee;
 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd;
 version="3.1">
 >  
 Hi5S
 >   
 >    
 Index.jsp
 >   
 >   
 >     MySQL
 Datasource
 >    
 jdbc/hi5
 >    
 javax.sql.DataSource
 >    
 Container
 >   
 >
 > 
 >
 > The error remains the
 same and my Tomcat failed to start, despite I cleaned them
 etc etc.
 >
 > SEVERE: A
 child container failed during start
 >
 java.util.concurrent.ExecutionException:
 org.apache.catalina.LifecycleException: Failed to start
 component
 [StandardEngine[Catalina].StandardHost[localhost]]
 >
 > Could you advise how
 to go about making it work ?
 
 Mailing list rules:
 http://tomcat.apache.org/lists.html#tomcat-users
 -> Top-posting is bad.

Ok. Tks, now I follow your requirements.

 
 1. See a link to Eclipse IDE FAQ here:
 
 https://wiki.apache.org/tomcat/FAQ/Developing#Q6
 
 
 2. See the
 following thread on how to turn on "Publish module
 context
 to separate XML files" option
 in Eclipse.

 By default
 (without that option) Eclipse IDE places 
 elements
 into server.xml, which is a rather
 discourage practice.
 
 http://markmail.org/message/7zkyocvph56b6t6q


OK.  I managed to turn on "Publish module context..but my problem of context 
not bound is still there. 
 
 3.
 Documentation on Context:
 
 http://tomcat.apache.org/tomcat-8.0-doc/config/context.html
 
 The  element in
 your context.xml has a lot of attributes that
 should not be there, starting with
 "debug". What (bad) example were
 they copied from?
 
 
 4. The current version of
 Tomcat 8.0 is 8.0.46.
 There were security
 fixes in Java as well (8u141 was a security update
 in July 2017)
 
 Also EOL date for Tomcat 8.0 has been
 announced. Users are advised to
 migrate to
 8.5.
 http://tomcat.apache.org/tomcat-80-eol.html

Hi kolinko, I have now installed Tomcat 8.5.20 but same problem.
 


 
 5. Your
 META-INF/context.xml is broken:
 [[[
   // here is rogue
 ">", thus your Resource has no name (all
 the following is plain text, not attributes)
 and thus NPE happens
    
 name="jdbc/hi5"
    
 auth="Container"
    
 type="javax.sql.DataSource"
    
 maxTotal="8"
    
 maxActive="100"
    
 maxIdle="30"
    
 maxWait="-1"
    
 username="root"
    
 singleton="true"
    
 override="true"
    
 factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
     password="password"
      
 alternateUsernameAllowed="true"
  
   driverClassName="com.mysql.jdbc.Driver"
    
 url="jdbc:mysql://localhost:3306/hi5" />  //
 You either use /> or
 ,
 not both.
   
 ]]]
 
 
I have changed my context.xml as follows :



   


And my web.xml ;


http://www.w3.org/2001/XMLSchema-instance; 
xmlns="http://xmlns.jcp.org/xml/ns/javaee; 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd; version="3.1">
  Hi5S
  
Index.jsp
  
  
MySQL dataSource
JDBC/hi5
javax.sql.DataSource
Container
  
   
util.HibernateSessionFactoryListener 
// I do not know if this is necessary.  Wld like to have your comments. Tks.



 Best
 regards,
 Konstantin Kolinko
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 
 

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Help needed - JPA probem - No connection specified with project

2017-09-25 Thread Konstantin Kolinko
2017-09-25 18:02 GMT+03:00 Karen Goh :
> Hi Kolinko,
>
> I have now removed the ResourceLink and left with Resource in my context.xml 
> which is resided at WebContent/META-INF.
>
> And this is C:\Program Files\Apache Software Foundation\Tomcat 
> 8.0\conf\context.xml
>
> 
> 
>
> 
> 
> WEB-INF/web.xml
> ${catalina.base}/conf/web.xml
>
> 
> 
>
> 
> 
> 
>
> And here's my web.xml :
>
> 
> http://www.w3.org/2001/XMLSchema-instance; 
> xmlns="http://xmlns.jcp.org/xml/ns/javaee; 
> xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
> http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd; version="3.1">
>   Hi5S
>   
> Index.jsp
>   
>   
> MySQL Datasource
> jdbc/hi5
> javax.sql.DataSource
> Container
>   
>
> 
>
> The error remains the same and my Tomcat failed to start, despite I cleaned 
> them etc etc.
>
> SEVERE: A child container failed during start
> java.util.concurrent.ExecutionException: 
> org.apache.catalina.LifecycleException: Failed to start component 
> [StandardEngine[Catalina].StandardHost[localhost]]
>
> Could you advise how to go about making it work ?

Mailing list rules:
http://tomcat.apache.org/lists.html#tomcat-users
-> Top-posting is bad.

1. See a link to Eclipse IDE FAQ here:

https://wiki.apache.org/tomcat/FAQ/Developing#Q6


2. See the following thread on how to turn on "Publish module context
to separate XML files" option in Eclipse.

By default (without that option) Eclipse IDE places  elements
into server.xml, which is a rather discourage practice.

http://markmail.org/message/7zkyocvph56b6t6q


3. Documentation on Context:

http://tomcat.apache.org/tomcat-8.0-doc/config/context.html

The  element in your context.xml has a lot of attributes that
should not be there, starting with "debug". What (bad) example were
they copied from?


4. The current version of Tomcat 8.0 is 8.0.46.
There were security fixes in Java as well (8u141 was a security update
in July 2017)

Also EOL date for Tomcat 8.0 has been announced. Users are advised to
migrate to 8.5.
http://tomcat.apache.org/tomcat-80-eol.html


5. Your META-INF/context.xml is broken:
[[[
  // here is rogue ">", thus your Resource has no name (all
the following is plain text, not attributes) and thus NPE happens
name="jdbc/hi5"
auth="Container"
type="javax.sql.DataSource"
maxTotal="8"
maxActive="100"
maxIdle="30"
maxWait="-1"
username="root"
singleton="true"
override="true"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
password="password"
  alternateUsernameAllowed="true"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/hi5" />  // You either use /> or
, not both.
  
]]]


Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Help needed - JPA probem - No connection specified with project

2017-09-25 Thread Karen Goh
Hi Kolinko,

I have now removed the ResourceLink and left with Resource in my context.xml 
which is resided at WebContent/META-INF.

And this is C:\Program Files\Apache Software Foundation\Tomcat 
8.0\conf\context.xml






WEB-INF/web.xml
${catalina.base}/conf/web.xml








And here's my web.xml :


http://www.w3.org/2001/XMLSchema-instance; 
xmlns="http://xmlns.jcp.org/xml/ns/javaee; 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd; version="3.1">
  Hi5S
  
Index.jsp
  
  
MySQL Datasource
jdbc/hi5
javax.sql.DataSource
Container
  
  


The error remains the same and my Tomcat failed to start, despite I cleaned 
them etc etc.

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: 
org.apache.catalina.LifecycleException: Failed to start component 
[StandardEngine[Catalina].StandardHost[localhost]]

Could you advise how to go about making it work ?

Hope to hear from you soon.

On Fri, 9/22/17, Konstantin Kolinko <knst.koli...@gmail.com> wrote:

 Subject: Re: Help needed - JPA probem - No connection specified with project
 To: "Tomcat Users List" <users@tomcat.apache.org>, "Karen Goh" 
<karenwo...@yahoo.com>
 Date: Friday, September 22, 2017, 10:00 PM
 
 2017-09-22 13:35 GMT+03:00 Karen
 Goh <karenwo...@yahoo.com.invalid>:
 > Hi expert,
 >
 > I have been trying very hard to nail the
 above problem including asking various forums like
 CodeRanch, dream in code etc but to no avail.
 >
 > As such, I am hoping
 to get help from the Apache Tomcat user support.
 >
 > Tools and setting :
 Eclipse Mars, Tomcat 1.8, MySQL, OS : Windows 7, Maven, Java
 JPA with Hibernate framework 5.1.0
 
 There is no such version as "Tomcat
 1.8". I assume that you meant some
 version of Tomcat 8.0.x.
 
 
 > The MySQL setting is
 confirmed correct, as I have managed to insert the data via
 single JDBC connection.
 >
 > Project summary : J2ee servlet with JSP,
 Java JPA in Hibernate framework. (Hibernate is for pure
 insertion of data - many to many relationship)
 >
 > My purpose is to get
 the JNDI datasource working but till now I can't just
 get it work.
 >
 >
 Here's my context.xml :
 >
 > 
 >
 
 >
 
 > 
 >   
  name="jdbc/hi5"
 >    
 auth="Container"
 >    
 type="javax.sql.DataSource"
 > 
    maxTotal="8"
 >    
 maxActive="100"
 >    
 maxIdle="30"
 >    
 maxWait="-1"
 >    
 username="root"
 >    
 singleton="true"
 >    
 override="true"
 >    
 factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
 >     password="password"
 >      
 alternateUsernameAllowed="true"
 >    
 driverClassName="com.mysql.jdbc.Driver"
 >    
 url="jdbc:mysql://localhost:3306/hi5" />
 >   
 >   
 
 The META-INF/context.xml file of a web
 application must have only one
 of
 <Resource, ResourceLink> elements with the same value
 of "name"
 attribute.
 
 
 If you have a
 ResourceLink in context.xml, it means that your Resource
 element must go into GlobalNamingResources
 element of conf/server.xml
 file.
 http://tomcat.apache.org/tomcat-8.5-doc/config/globalresources.html
 
 
 BTW, you
 should not modify conf/context.xml file. It is the
 defaults
 file shared by all web
 applications. (Modifying it is a common
 configuration mistake).
 
 
 Best regards,
 Konstantin Kolinko
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 
 

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Fw: Re: Help needed - JPA probem - No connection specified with project

2017-09-23 Thread Karen Goh
Hi all,

I'd like to add that I did not add EclipseLink cos I learnt that you cannot mix 
Hibernate with EclipseLink.

Tks & rgds,
Karen

--- On Sat, 9/23/17, Karen Goh <karenwo...@yahoo.com> wrote:

> From: Karen Goh <karenwo...@yahoo.com>
> Subject: Re: Help needed - JPA probem - No connection specified with project
> To: "Tomcat Users List" <users@tomcat.apache.org>, knst.koli...@gmail.com
> Date: Saturday, September 23, 2017, 1:03 PM
> Hi all,
> 
> My apologies, my Tomcat server version
> is Apache Tomcat 8.0.29 Server.
> The JDK is 1.8
> 
> Hope to get some advice what went wrong
> in regards to the No connection specified with project.
> 
> Tks & rgds,
> Karen
> 
> On Fri, 9/22/17, Konstantin Kolinko
> <knst.koli...@gmail.com>
> wrote:
> 
>  Subject: Re: Help needed - JPA probem
> - No connection specified with project
>  To: "Tomcat Users List" <users@tomcat.apache.org>,
> "Karen Goh" <karenwo...@yahoo.com>
>  Date: Friday, September 22, 2017,
> 10:00 PM
>  
>  2017-09-22 13:35 GMT+03:00 Karen
>  Goh <karenwo...@yahoo.com.invalid>:
>  > Hi expert,
>  >
>  > I have been trying very hard to
> nail the
>  above problem including asking various
> forums like
>  CodeRanch, dream in code etc but to no
> avail.
>  >
>  > As such, I am hoping
>  to get help from the Apache Tomcat
> user support.
>  >
>  > Tools and setting :
>  Eclipse Mars, Tomcat 1.8, MySQL, OS :
> Windows 7, Maven, Java
>  JPA with Hibernate framework 5.1.0
>  
>  There is no such version as "Tomcat
>  1.8". I assume that you meant some
>  version of Tomcat 8.0.x.
>  
>  
>  > The MySQL setting is
>  confirmed correct, as I have managed
> to insert the data via
>  single JDBC connection.
>  >
>  > Project summary : J2ee servlet
> with JSP,
>  Java JPA in Hibernate framework.
> (Hibernate is for pure
>  insertion of data - many to many
> relationship)
>  >
>  > My purpose is to get
>  the JNDI datasource working but till
> now I can't just
>  get it work.
>  >
>  >
>  Here's my context.xml :
>  >
>  >   encoding="UTF-8"?>
>  >
>   docBase="Hi5S"
>  crossContext="true" reloadable="true"
>  antiResourceLocking="true"
>  debug="1">
>  >
>name="jdbc/hi5"
>  type="javax.sql.DataSource"/>
>  > 
>  >   
>   name="jdbc/hi5"
>  >    
>  auth="Container"
>  >    
>  type="javax.sql.DataSource"
>  > 
>     maxTotal="8"
>  >    
>  maxActive="100"
>  >    
>  maxIdle="30"
>  >    
>  maxWait="-1"
>  >    
>  username="root"
>  >    
>  singleton="true"
>  >    
>  override="true"
>  >    
> 
> factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
>  >     password="password"
>  >      
>  alternateUsernameAllowed="true"
>  >    
> 
> driverClassName="com.mysql.jdbc.Driver"
>  >    
>  url="jdbc:mysql://localhost:3306/hi5"
> />
>  >   
>  >   
>  
>  The META-INF/context.xml file of a
> web
>  application must have only one
>  of
>  <Resource, ResourceLink>
> elements with the same value
>  of "name"
>  attribute.
>  
>  
>  If you have a
>  ResourceLink in context.xml, it means
> that your Resource
>  element must go into
> GlobalNamingResources
>  element of conf/server.xml
>  file.
>  http://tomcat.apache.org/tomcat-8.5-doc/config/globalresources.html
>  
>  
>  BTW, you
>  should not modify conf/context.xml
> file. It is the
>  defaults
>  file shared by all web
>  applications. (Modifying it is a
> common
>  configuration mistake).
>  
>  
>  Best regards,
>  Konstantin Kolinko
>  
> 
> -
>  To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>  For additional commands, e-mail: users-h...@tomcat.apache.org
>  
>  

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Help needed - JPA probem - No connection specified with project

2017-09-22 Thread Karen Goh
Hi all,

My apologies, my Tomcat server version is Apache Tomcat 8.0.29 Server.
The JDK is 1.8

Hope to get some advice what went wrong in regards to the No connection 
specified with project.

Tks & rgds,
Karen

On Fri, 9/22/17, Konstantin Kolinko <knst.koli...@gmail.com> wrote:

 Subject: Re: Help needed - JPA probem - No connection specified with project
 To: "Tomcat Users List" <users@tomcat.apache.org>, "Karen Goh" 
<karenwo...@yahoo.com>
 Date: Friday, September 22, 2017, 10:00 PM
 
 2017-09-22 13:35 GMT+03:00 Karen
 Goh <karenwo...@yahoo.com.invalid>:
 > Hi expert,
 >
 > I have been trying very hard to nail the
 above problem including asking various forums like
 CodeRanch, dream in code etc but to no avail.
 >
 > As such, I am hoping
 to get help from the Apache Tomcat user support.
 >
 > Tools and setting :
 Eclipse Mars, Tomcat 1.8, MySQL, OS : Windows 7, Maven, Java
 JPA with Hibernate framework 5.1.0
 
 There is no such version as "Tomcat
 1.8". I assume that you meant some
 version of Tomcat 8.0.x.
 
 
 > The MySQL setting is
 confirmed correct, as I have managed to insert the data via
 single JDBC connection.
 >
 > Project summary : J2ee servlet with JSP,
 Java JPA in Hibernate framework. (Hibernate is for pure
 insertion of data - many to many relationship)
 >
 > My purpose is to get
 the JNDI datasource working but till now I can't just
 get it work.
 >
 >
 Here's my context.xml :
 >
 > 
 >
 
 >
 
 > 
 >   
  name="jdbc/hi5"
 >    
 auth="Container"
 >    
 type="javax.sql.DataSource"
 > 
    maxTotal="8"
 >    
 maxActive="100"
 >    
 maxIdle="30"
 >    
 maxWait="-1"
 >    
 username="root"
 >    
 singleton="true"
 >    
 override="true"
 >    
 factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
 >     password="password"
 >      
 alternateUsernameAllowed="true"
 >    
 driverClassName="com.mysql.jdbc.Driver"
 >    
 url="jdbc:mysql://localhost:3306/hi5" />
 >   
 >   
 
 The META-INF/context.xml file of a web
 application must have only one
 of
 <Resource, ResourceLink> elements with the same value
 of "name"
 attribute.
 
 
 If you have a
 ResourceLink in context.xml, it means that your Resource
 element must go into GlobalNamingResources
 element of conf/server.xml
 file.
 http://tomcat.apache.org/tomcat-8.5-doc/config/globalresources.html
 
 
 BTW, you
 should not modify conf/context.xml file. It is the
 defaults
 file shared by all web
 applications. (Modifying it is a common
 configuration mistake).
 
 
 Best regards,
 Konstantin Kolinko
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 
 

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Help needed - JPA probem - No connection specified with project

2017-09-22 Thread Konstantin Kolinko
2017-09-22 13:35 GMT+03:00 Karen Goh :
> Hi expert,
>
> I have been trying very hard to nail the above problem including asking 
> various forums like CodeRanch, dream in code etc but to no avail.
>
> As such, I am hoping to get help from the Apache Tomcat user support.
>
> Tools and setting : Eclipse Mars, Tomcat 1.8, MySQL, OS : Windows 7, Maven, 
> Java JPA with Hibernate framework 5.1.0

There is no such version as "Tomcat 1.8". I assume that you meant some
version of Tomcat 8.0.x.


> The MySQL setting is confirmed correct, as I have managed to insert the data 
> via single JDBC connection.
>
> Project summary : J2ee servlet with JSP, Java JPA in Hibernate framework. 
> (Hibernate is for pure insertion of data - many to many relationship)
>
> My purpose is to get the JNDI datasource working but till now I can't just 
> get it work.
>
> Here's my context.xml :
>
> 
>  antiResourceLocking="true" debug="1">
> 
> 
> name="jdbc/hi5"
> auth="Container"
> type="javax.sql.DataSource"
> maxTotal="8"
> maxActive="100"
> maxIdle="30"
> maxWait="-1"
> username="root"
> singleton="true"
> override="true"
> factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
> password="password"
>   alternateUsernameAllowed="true"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost:3306/hi5" />
>   
>   

The META-INF/context.xml file of a web application must have only one
of  elements with the same value of "name"
attribute.


If you have a ResourceLink in context.xml, it means that your Resource
element must go into GlobalNamingResources element of conf/server.xml
file.
http://tomcat.apache.org/tomcat-8.5-doc/config/globalresources.html


BTW, you should not modify conf/context.xml file. It is the defaults
file shared by all web applications. (Modifying it is a common
configuration mistake).


Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Help needed - JPA probem - No connection specified with project

2017-09-22 Thread Karen Goh
Hi expert,

I have been trying very hard to nail the above problem including asking various 
forums like CodeRanch, dream in code etc but to no avail.

As such, I am hoping to get help from the Apache Tomcat user support.

Tools and setting : Eclipse Mars, Tomcat 1.8, MySQL, OS : Windows 7, Maven, 
Java JPA with Hibernate framework 5.1.0

The MySQL setting is confirmed correct, as I have managed to insert the data 
via single JDBC connection.

Project summary : J2ee servlet with JSP, Java JPA in Hibernate framework. 
(Hibernate is for pure insertion of data - many to many relationship)

My purpose is to get the JNDI datasource working but till now I can't just get 
it work.

Here's my context.xml :





name="jdbc/hi5"
auth="Container" 
type="javax.sql.DataSource"
maxTotal="8" 
maxActive="100" 
maxIdle="30" 
maxWait="-1"
username="root"
singleton="true" 
override="true"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
password="password" 
  alternateUsernameAllowed="true"
driverClassName="com.mysql.jdbc.Driver" 
url="jdbc:mysql://localhost:3306/hi5" />  
  


Here's my web.xml:


http://www.w3.org/2001/XMLSchema-instance; 
xmlns="http://xmlns.jcp.org/xml/ns/javaee; 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd; version="3.1">
  Hi5S
  
Index.jsp
  
  
MySQL Datasource
jdbc/hi5
javax.sql.DataSource
Container
  
  


And my singletonDatasource class:

package util;


import java.sql.Connection;
import java.sql.SQLException;

import javax.annotation.Resource;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;


@Resource(name = "jdbc/hi5")
public class SingletonDBConnection{

private static SingletonDBConnection singleInstance;
private static DataSource dataSource;
private static Connection dbConnect;

private SingletonDBConnection() {
try {
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
dataSource = (DataSource) envContext.lookup("jdbc/hi5");

try {
dbConnect = dataSource.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (NamingException e) {
e.printStackTrace();
}
}


public static DataSource getMySQLDataSource() { // using apacheDBCP
if (singleInstance == null) {
synchronized (SingletonDBConnection.class) {
if (singleInstance == null) {
singleInstance = new SingletonDBConnection();
}
}
}

return (DataSource) singleInstance;
}

public static DataSource getConnInst() {
try {
dbConnect = dataSource.getConnection();
} catch (SQLException e1) {
e1.printStackTrace();
}

if (dbConnect == null) {
try {
Context initContext = new InitialContext();
Context envContext = (Context) 
initContext.lookup("java:/comp/env");
dataSource = (DataSource) envContext.lookup("jdbc/hi5");

try {
dbConnect = dataSource.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (NamingException e) {
e.printStackTrace();
}
}

return dataSource;
}

}


And the persistence.xml ;


http://xmlns.jcp.org/xml/ns/persistence; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence 
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd;>

model.Subject
model.Tutor


  

  





As the mailing list does not allow large error attachment, therefore, I am 
appending the error below :

Sep 22, 2017 5:59:46 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting 
property 'debug' to '1' did not find a matching property.
Sep 22, 2017 5:59:46 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting 
property 'source' to 'org.eclipse.jst.jee.server:Hi5S' did not find a matching 
property.
Sep 22, 2017 5:59:46 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:Apache Tomcat/8.0.29
Sep 22, 2017 5:59:46 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:  Nov 20 2015 09:18:00 UTC
Sep 22, 2017 5:59:46 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.29.0
Sep 22, 2017 5:59:46 PM