This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Jeff Pavlocak

Greenhorn
+ Follow
since Apr 26, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Jeff Pavlocak

I got it to work.

I did have a previous version of Java installed in another set of directories. I completely removed those directories and everything works fine now.

Thanks for the help.

Jeff
13 years ago
I'm having a problem getting the String classes replace method to work.

I'm using the the J2SE 1.5.0 SDK and the API spec states that the String class now has an overloaded replace(CharSequence target, CharSequence replacement) method.

When I use this method, I can't get the program to compile. Here's a sample:

public class TestReplace
{
public static void main(String[] args)
{
String s = "aaa";
CharSequence csTarget = "aa";
CharSequence csReplace = "b";
String s2 = s.replace(csTarget, csReplace);
System.out.println(s2);
}
}

Compiling this yields the following error:

C:\dev\src>javac TestReplace.java
TestReplace.java:9: replace(char,char) in java.lang.String cannot be applied to
(java.lang.CharSequence,java.lang.CharSequence)
String s2 = s.replace(csTarget, csReplace);
^
1 error

My CLASSPATH is: c:\jdk1.5.0;.

Any ideas??

Jeff
13 years ago
The log4j-1.2.8.jar is in the %CATALINA_HOME%/webapps/axis/web-inf/lib directory.

Does it need to be somewhere else?

I tried putting it in the %CATALINA_HOME%/common/lib directory, but then Tomcat aborts during the startup scripts.

Is there an xml or properties file that needs adjusted?
13 years ago
I am trying to install Axis 1_1 with Tomcat 5.0.16, but tomcat keeps running into install errors when it tries to install the Axis application. All the other web apps install just fine. I have been using Tomcat 5.0.16 for a couple months now without really experiencing any problems that I couldn't resolve on my own, but this one has me stumped.

I followed the steps outlined in the Axis installation guide.

I copied the axis directory and it's sub-dirs from the axis-1_1 distro to tomcat's webapps directory.

I made sure that xercesImpl.jar, jaxrpc.jar, and saaj.jar were added to the CLASSPATH in the catalina.bat DOS script.

Actual CLASSPATH value:
c:\xml\xercesImpl.jar;c:\xml\xerces-api.jar;c:\axis-1_1\lib\axis.jar;
c:\axis-1_1\lib\jaxrpc.jar;c:\axis-1_1\lib\saaj.jar;
c:\axis-1_1\lib\commons-logging.jar;c:\axis-1_1\lib\commons-discovery.jar;
C:\j2sdk_nb\j2sdk1.4.2\lib\tools.jar;C:\jakarta-tomcat-5.0.16\bin\bootstrap.jar

However, when I startup the webserver I get the following error:


Nov 10, 2004 1:04:19 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /axis from URL file:C:\jakarta-
tomcat-5.0.16\webapps\axis

Nov 10, 2004 1:04:20 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Error installing
org.apache.commons.logging.LogConfigurationException:
org.apache.commons.logging.LogConfigurationException:
No suitable Log constructor [Ljava.lang.Class;@3257b8 for org.apache.commons.logging.impl.Log4JLogger
(Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)
(Caused by org.apache.commons.logging.LogConfigurationException:
No suitable Log constructor [Ljava.lang.Class;@3257b8 for org.apache.commons.logging.impl.Log4JLogger
(Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.apache.catalina.session.ManagerBase.<init>(ManagerBase.java:107)
at org.apache.catalina.session.StandardManager.<init>(StandardManager.java:111)
at org.apache.catalina.startup.ContextConfig.managerConfig(ContextConfig.java:350)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:655)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:254)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4212)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:850)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:316)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:859)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:723)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:473)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:393)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)

--- The dump continues on after this. Let me know if you need it all ---

The installation instructions are for Tomcat 4.x. Doesn't Axis 1_1 work with Tomcat 5.x? Are their additional jar files needed? Do I need to change a tomcat config file?

Please help.

Thanks,

Jeff
13 years ago
I have been given the task of writing a client program to interact with a web service. I was able to download some sample code from the company that hosts the web service. The sample code uses a JSP to call on a servlet that interacts with the web service.

I've written JSP pages before, but I have never written client programs to interact with web services using SOAP. I've gone to a number of SOAP recources on the web, and I have been able to get their tutorials to work just fine. But, none of the "hello world" tutorials operate quite like the sample code I have.

I keep getting a Parsing Exception from Tomcat when the servlet tries to create a SOAPConnection. Any ideas as to what might be going wrong?

This is getting really frustrating now. Any help would be greatly appreciated.

Thanks,

Jeff

I am using tomcat-jwsdp-1.4
My classpath is :
"C:\tomcat-jwsdp-1.4\common\lib\axis.jar;C:\xml\xerces.jar;
c:\soap-2_3_1\webapps\soap;c:\soap-2_3_1\lib\soap.jar;
c:\soap-2_3_1\lib\mail.jar;c:\soap-2_3_1\lib\activation.jar;
C:\j2sdk_nb\j2sdk1.4.2\lib\tools.jar;c:\tomcat-jwsdp-1.4\bin\bootstrap.jar"

The exact error I get is:

exception

javax.servlet.ServletException: javax/mail/internet/ParseException
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:822)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:755)
org.apache.jsp.TestUpc_jsp._jspService(TestUpc_jsp.java:106)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:268)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:258)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:205)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.NoClassDefFoundError: javax/mail/internet/ParseException
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
java.lang.Class.getConstructor0(Class.java:1922)
java.lang.Class.newInstance0(Class.java:278)
java.lang.Class.newInstance(Class.java:261)
javax.xml.soap.FactoryFinder.newInstance(Unknown Source)
javax.xml.soap.FactoryFinder.find(Unknown Source)
javax.xml.soap.MessageFactory.newInstance(Unknown Source)
com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.<init>(HttpSOAPConnection.java:53)
com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory.createConnection(HttpSOAPConnectionFactory.java:25)
com.serviceobjects.dots.upc.UpcExample.getGetUPCInfo(UpcExample.java:167)
com.serviceobjects.dots.upc.UpcExample.invokeUPCInfo(UpcExample.java:34)
org.apache.jsp.TestUpc_jsp._jspService(TestUpc_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:268)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:258)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:205)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

The code that is giving me the problem is below:

private String getGetUPCInfo(String UPCCode, String key) {

String upcInfoXml = null;
String SERVICE_URI =
"http://ws2.theSite.net/upc/UPC.asmx";

try {

SOAPConnectionFactory soapConFac =
SOAPConnectionFactory.newInstance();

// The next line is the one kicking off the parsing exception
SOAPConnection soapCon = soapConFac.createConnection();
MessageFactory msgFac = MessageFactory.newInstance();
SOAPMessage soapMsg = msgFac.createMessage();
SOAPPart soapPart = soapMsg.getSOAPPart();
SOAPEnvelope soapEnv = soapPart.getEnvelope();
SOAPHeader soapHead = soapEnv.getHeader();
SOAPBody soapBody = soapEnv.getBody();
soapHead.detachNode();
13 years ago
Try the following:

SELECT table_a.studentid, MAX(studentnumber), sname
FROM table_a, table_b
WHERE table_a.studentid = table_b.studentid
GROUP BY studentid, sname;
Can you print out the value of tempNode before you enter the do loop? This way you can see if it really is a null and not a problem with the logic in your loop.
13 years ago
Can you post the code for your loop? Also your opening and closing connections code.
satya,

Your code looked good to me, so I copied your code from the top thread and compiled it. The code compiled fine and ran fine.

Double check that your code matches exactly what is in the thread and you should be good. Or better yet, do what I did and copy it from the thread and paste it into your text editor.

Remember Java is case sensitive.

Also, you don't need to compile the B.java file before the A.java file. The compiler will take care of that for you.

Good luck,

Jeff Pavlocak
13 years ago
Hey Joe,

There may be a decent online tutorial for this, but in case you're interested, in the book "Head First Java" by Kathy Sierra and Bert Bates, they have a real good explanation of packages.

good luck,

Jeff
13 years ago
Packages help you to add structure and organization to your applications. Whenever you create applications you usually don't have all your code in one file. You'll write a class that uses other classes(objects) among other things to accomplish a task.

Packages enable you to organize your classes so that you can package similar objects together. By putting the "package somePackageName;" at the top of your class source file, you are stating that the class belongs to the somePackageName package.

If you also put the same "package somePackageName;" at the top of another class source file, you are also including that class in the same package as the other one.

Later, in another java program, you can import the somePackageName package and be able to use both of the objects(classes) in your program.

Packages can also include other things like interfaces, which is another discussion.

Hope this helps.

Jeff Pavlocak
13 years ago
Are you using the DOS command line or some GUI tool to compile your code?

If it's a GUI tool which one, and is it the same tool at home as at work?

Jeff
13 years ago
The package statement allows you to group several classes and interfaces together into a "package". You can then reference the classes you created in that package in other java programs by importing the package.

Example:

package com.myNewPackage;

import com.javaranch.*;

public class myNewClass
{
PostServlet ps = new PostServlet();

// more code...
}
13 years ago
Check out the EJB Certification (SCBCD) forum, "error in compilation" post updated April 26th 2004.
I believe the link below will take you there, but if not use the above. The answer is in there.

http://www.coderanch.com/t/159160/java-EJB-SCBCD/certification/error-compilation
Hope this helps.
Jeff
Please excuse my previous post where I stipulated one line instead of two. The was my first post and the editor had wrapped the lines. I didn't realize that they would be intact as one line once posted.
jpp