Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@WebMethod not found

 
ahsan mir
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
i am writing a simple echo server(just the webservice).When i try to compile the 'build.xml' file , i get the following error.


*********************************************************************
C:\javaeetutorial5\examples\jaxws\helloservice>asant -f build.xml
Buildfile: build.xml

-pre-init:

init:

default-ear:

-pre-compile:

bpp-actual-compilation:
[echo] Compiling helloservice
[mkdir] Created dir: C:\javaeetutorial5\examples\jaxws\helloservice\build\we
b\WEB-INF\classes
[javac] Compiling 1 source file to C:\javaeetutorial5\examples\jaxws\hellose
rvice\build\web\WEB-INF\classes
[javac] C:\javaeetutorial5\examples\jaxws\helloservice\src\java\helloservice
\endpoint\Hello.java:31: package javax.jws does not exist
[javac] import javax.jws.WebMethod;
[javac] ^
[javac] C:\javaeetutorial5\examples\jaxws\helloservice\src\java\helloservice
\endpoint\Hello.java:32: package javax.jws does not exist
[javac] import javax.jws.WebService;
[javac] ^
[javac] C:\javaeetutorial5\examples\jaxws\helloservice\src\java\helloservice
\endpoint\Hello.java:35: cannot find symbol
[javac] symbol: class WebService
[javac] @WebService
[javac] ^
[javac] C:\javaeetutorial5\examples\jaxws\helloservice\src\java\helloservice
\endpoint\Hello.java:39: cannot find symbol
[javac] symbol : class WebMethod
[javac] location: class helloservice.endpoint.Hello
[javac] @WebMethod
[javac] ^
[javac] 4 errors

BUILD FAILED
C:\javaeetutorial5\examples\bp-project\command-line-ant-tasks.xml:89: Compile fa
iled; see the compiler error output for details.

Total time: 4 seconds

C:\javaeetutorial5\examples\jaxws\helloservice>

*************************************************************************

The following is my webservice:

//////////////////////////////////////////////////////////////////////
package helloservice.endpoint;

import javax.jws.WebMethod;
import javax.jws.WebService;


@WebService
public class Hello {
private String message = new String("Hello, ");

@WebMethod
public String sayHello(String name) {
return message + name + ".";
}
}

///////////////////////////////////////////////////////////////////

Any help would be appreciated.

Thanks
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My next action would be to determine which JAR contains the javax.jws package (with the WebService and WebMethod annotations) and determine whether that JAR is in the relevant class and/or build paths.

You haven't mentioned the SOAP stack that you are using. It's likely that you are using Axis 2.* but there are others that support JSR 181: Web Services Metadata for the Java(tm)Platform outside of JSR 224: JavaTM API for XML-Based Web Services (JAX-WS) 2.0.
 
ahsan mir
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
the problem seemed to be related to what you mentioned.I was using J2ee SDK 1.4 and the sun application server 8 .I then tested it on the new J2ee SDK 5 and sun application server 9, & it did compiled.
have not worked in apache axis , is it easier to use and are ther any online tutorials like for the j2ee server and the Sun WSDP 2.


Thanks.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ahsan mir:
I was using J2ee SDK 1.4 and the sun application server 8.


Well, annotations aren't supported until Java 5 (1.5). So strictly speaking J2EE 1.4 doesn't support it. That being said SUN did sneak the Java 5 Core into later versions of the J2EE SDK 1.4.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic