Mary Taylor

Ranch Hand
+ Follow
since Sep 11, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mary Taylor

Trying that now. Thanks. Attached screen shot shows the url correct when created by the wizard. When I test the connection in Eclipse when creating the DataSource, the ping works. This seems to be the problem when accessing the same DataSource in code:

javax.naming.NameNotFoundException: Name [java.naming.InitialContext] is not bound in this Context. Unable to find [java.naming.InitialContext].


Same result after modifying the context.xml; must be something else going on. I did stop and restart the server after adding the port.


Modified context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- The contents of this file will be loaded for each web application -->

<Context crossContext="true">

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<Resource name="jdbc/customers" auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root"
password=""
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/customers"/>


</Context>
I just deleted Tomcat and downloaded a newer version which worked just fine. Thank you for looking at this.
9 years ago
Environment:
MySql: 5.6.17 and using mysql-connector-java-5.1.33-bin.jar
Tomcat: 7.0.56
Java: 6
Eclipse: Eclipse Java EE IDE for Web Developers Version: Indigo Service Release 2
Mac OS X: 10.9.5

When I create a DataSource in Eclipse, I can successfully ping the database. However, when I try to use that DataSource programmatically, I get the attached StackTrace ( not allowed to attach StackTrace as it is in a .txt file). I will include a few lines here:

javax.naming.NameNotFoundException: Name [java.naming.InitialContext] is not bound in this Context. Unable to find [java.naming.InitialContext].
at org.apache.naming.NamingContext.list(NamingContext.java:370)
at org.apache.naming.NamingContext.list(NamingContext.java:394)
at org.apache.naming.SelectorContext.list(SelectorContext.java:352)
at javax.naming.InitialContext.list(InitialContext.java:436)
at com.schwartz.dao.MySql_Utils.MySqlConn(MySql_Utils.java:20)
at com.schwartz.customerProject.status.V1_status.returnDatabaseStatus(V1_status.java:38)

I have created and used a DataSource in Java code; that worked using the instructions at http://theopentutorials.com/examples/java-ee/servlet/servlet-jndi-datasource-in-tomcat/.

Do I need to modify the context.xml to use this DataSource created with the wizard? I added a resource-ref to the web.xml although the tutorial I was following did not indicate that was necessary.

This is the tutorial I used to create the DataSource with the wizard provided by Eclipse:
http://theopentutorials.com/tutorials/eclipse/dtp/eclipse-dtp-configure-mysql-datasource-data-source-explorer/

---------------------------------------------------------------------------------------------------

Partial web.xml:
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.schwartz.customerProject</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/customers/*</url-pattern>
</servlet-mapping>

<resource-ref>
<description>DB connection</description>
<res-ref-name>jdbc/customers</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

----------------------------------------------------------------------------
/WEB-INF/context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- The contents of this file will be loaded for each web application -->

<Context crossContext="true">

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<Resource name="jdbc/customers" auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root"
password=""
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/customers"/>

</Context>

Thank you for your time.
I just deleted the server and downloaded the latest. Let me see if I have the same problem when I get to that point in the tutorial. Thanks for now.
9 years ago
I added some code to a Java file that resulted in a message stating the Dispatcher class was needed. I found that would be in the Tomcat-util.jar so added that jar file. The next step was the Method Missing error when trying to start the server. I will have to back up and recreate the class now as I am not exactly sure which step caused the server not to start. I wasn't taking detailed enough notes. It was a very simple tutorial or so I thought!
9 years ago
Here is the contents of /conf/catalina.properties:

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# List of comma-separated packages that start with or equal this string
# will cause a security exception to be thrown when
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.
#
# List of comma-separated packages that start with or equal this string
# will cause a security exception to be thrown when
# passed to checkPackageDefinition unless the
# corresponding RuntimePermission ("defineClassInPackage."+package) has
# been granted.
#
# by default, no packages are restricted for definition, and none of
# the class loaders supplied with the JDK call checkPackageDefinition.
#
package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.

#
#
# List of comma-separated paths defining the contents of the "common"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
# If left as blank,the JVM system loader will be used as Catalina's "common"
# loader.
# Examples:
# "foo": Add this folder as a class repository
# "foo/*.jar": Add all the JARs of the specified folder as class
# repositories
# "foo/bar.jar": Add bar.jar as a class repository
common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar

#
# List of comma-separated paths defining the contents of the "server"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
# If left as blank, the "common" loader will be used as Catalina's "server"
# loader.
# Examples:
# "foo": Add this folder as a class repository
# "foo/*.jar": Add all the JARs of the specified folder as class
# repositories
# "foo/bar.jar": Add bar.jar as a class repository
server.loader=

#
# List of comma-separated paths defining the contents of the "shared"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_BASE path or absolute. If left as blank,
# the "common" loader will be used as Catalina's "shared" loader.
# Examples:
# "foo": Add this folder as a class repository
# "foo/*.jar": Add all the JARs of the specified folder as class
# repositories
# "foo/bar.jar": Add bar.jar as a class repository
# Please note that for single jars, e.g. bar.jar, you need the URL form
# starting with file:.
shared.loader=

# List of JAR files that should not be scanned for configuration information
# such as web fragments, TLD files etc. It must be a comma separated list of
# JAR file names.
# The JARs listed below include:
# - Tomcat Bootstrap JARs
# - Tomcat API JARs
# - Catalina JARs
# - Jasper JARs
# - Tomcat JARs
# - Common non-Tomcat JARs
# - Sun JDK JARs
# - Apple JDK JARs
tomcat.util.scan.DefaultJarScanner.jarsToSkip=\
bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\
annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,\
catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-tribes.jar,\
jasper.jar,jasper-el.jar,ecj-*.jar,\
tomcat-api.jar,tomcat-util.jar,tomcat-coyote.jar,tomcat-dbcp.jar,\
tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\
tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\
tomcat-jdbc.jar,\
commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\
commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\
commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\
commons-math*.jar,commons-pool*.jar,\
jstl.jar,\
geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\
ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\
jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,\
xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\
dnsns.jar,ldapsec.jar,localedata.jar,sunjce_provider.jar,sunmscapi.jar,\
sunpkcs11.jar,jhall.jar,tools.jar,\
sunec.jar,zipfs.jar,\
apple_provider.jar,AppleScriptEngine.jar,CoreAudio.jar,dns_sd.jar,\
j3daudio.jar,j3dcore.jar,j3dutils.jar,jai_core.jar,jai_codec.jar,\
mlibwrapper_jai.jar,MRJToolkit.jar,vecmath.jar,\
junit.jar,junit-*.jar,ant-launcher.jar

#
# String cache configuration.
tomcat.util.buf.StringCache.byte.enabled=true
#tomcat.util.buf.StringCache.char.enabled=true
#tomcat.util.buf.StringCache.trainThreshold=500000
#tomcat.util.buf.StringCache.cacheSize=5000
9 years ago
Tomcat was starting until I added functionality that required a util.jar which I added to the Lib directory.
I just can't seem to find the correct Tomcat-util.jar, however.

Environment: Mac OS X 10.9.5
Eclipse: Indigo
Tomcat 7.0.26
Tomcat-util.jar October 16, 2013

Here is the output when I start Tomcat at the command line:

Using CATALINA_BASE: /Users/betty80906/Tools/Tomcat_7.0.26/apache-tomcat-7.0.26
Using CATALINA_HOME: /Users/betty80906/Tools/Tomcat_7.0.26/apache-tomcat-7.0.26
Using CATALINA_TMPDIR: /Users/betty80906/Tools/Tomcat_7.0.26/apache-tomcat-7.0.26/temp
Using JRE_HOME: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
Using CLASSPATH: /Users/betty80906/Tools/Tomcat_7.0.26/apache-tomcat-7.0.26/bin/bootstrap.jar:/Users/betty80906/Tools/Tomcat_7.0.26/apache-tomcat-7.0.26/bin/tomcat-juli.jar

When I issue this command, I see Tomcat is not running:

ps -ef | grep Tomcat
501 816 315 0 11:33AM ttys000 0:00.00 grep Tomcat

Here is catalina.out:

java.lang.NoSuchMethodError: org.apache.tomcat.util.digester.Digester.setRulesValidation(Z)V
at org.apache.catalina.startup.Catalina.createStartDigester(Catalina.java:293)
at org.apache.catalina.startup.Catalina.load(Catalina.java:512)
at org.apache.catalina.startup.Catalina.load(Catalina.java:619)
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.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:449)


When I start Tomcat within Eclipse, this output is logged in the Console:
java.lang.NoSuchMethodError: org.apache.tomcat.util.digester.Digester.setRulesValidation(Z)V
at org.apache.catalina.startup.Catalina.createStartDigester(Catalina.java:293)
at org.apache.catalina.startup.Catalina.load(Catalina.java:512)
at org.apache.catalina.startup.Catalina.load(Catalina.java:619)
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.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:449)

I have tried a couple of util.jar files but can't seem to find one with the missing method.
I currently have the Tomcat-util.jar from October 16, 2013.
Has anyone solved this problem?

9 years ago
You're almost there on the JAVA_HOME; but you want to look in /System/Library/Java/JavaVirtualMachines. I just read this path is deprecated so I'm not sure what the current information really is.

Take a look at:
http://stackoverflow.com/questions/6614380/jdk-on-osx-10-7-lion

It is confusing; but there is some information there that could be helpful.
9 years ago
The exams you speak of are not available for a Mac user; what would you suggest a Mac user do to prepare for the real exam?
The Master Exam from the Bates and Sierra book is not platform independent. The CD provided with the book contains only a Windows application. Even the extra master exam provided online is a downloadable .exe. I'm disappointed not to be able to utilize the 3 full master exams advertised on the front of the SCJP Study Guide by Bates and Sierra. The book is so good.
If you remain confused, you might consider taking the WhizLabs online SCJP6 preparation course.
It is very helpful, especially regarding these things.
Page 832 of the Bates and Sierra book published in 2008:

Software requires Windows 98 or higher and Internet Explorer 5.0 or above and 20MB of hard disk space for full installation.

The MasterExam.exe has a lot of dependencies on the DVD provided; seems like a lot of steps to get this to work on a Mac if it is at all possible.

I was hoping there is an online version somewhere for Mac users since it seems most developers use a Mac any more.

Is the CD containing the Master Exam only available for the Windows platform? I assumed there would be some access to the Master Exams online for those using a Mac; but I have emailed McGraw-Hill and LearnKey with no positive response yet. I hear the Master Exam is good preparation for the actual exam. It's too bad if it is not available for Mac users. Does anyone know where I might find the Master Exam? I bought the book which indicated it was included; only then did I discover it was for Windows only.

Thank you for your help.
I'm wondering how much longer the OCPJP 6 exam will be available to take?
Thanks for letting me know to remove the continuation characters and execute the query as one long line; I had done so as an experiment the last time I ran the script producing the following output:


mysql> source /Users/userName/WorkspaceForResourceProject/Scripts/ResourceTableCreate.sqlQuery OK, 0 rows affected (0.28 sec)

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
mysql>


Here is the query executed: CREATE TABLE resources (resourceId INT(3) auto_increment primary key, aCategory VARCHAR (20), url VARCHAR (200), title VARCHAR (25), createdDateTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, UNIQUE (url) )ENGINE=MyISAM;
 
Thanks for taking a look at this.