23 Haziran 2009 Salı

some notes on Jbossws + Eclipse

I want to make effective use of metro web service stack and eclipse ide (together). Netbeans support for jaxws is excellent but i have a limitation that all code will be developped with eclipse, so lets move..


My environment is Eclipse Ganymede + Jboss 5.0.0. app. server + Sun jdk on x64 linux machine (open suse).

The steps:
1) Download and install Jboss 5.0.0


3) In jbossws package (extracted) copy ant.properties.example as ant.properties

4) change the server location as follows (appropriately):
jboss500.home=/usr/share/myprograms/ECLIPSEHOME/ECLIPSEHOME/server/jboss-5.0.0.GA

5) execute ant deploy-jboss500 command. ant must be installed and the command must be executed inside the package structure(since build.xml is at that path..)
at this point, jbossws is installed at jboss app server..
btw, jboss server does not work properly with ibm jdk, so use sun jdk instead..

6) open eclipse and add the jboss v5.0 server you installed jbossws on top of.
while trying to do this this error message may appear:
 Missing classpath entry /home/hilal.tarakci/ECLIPSEHOME/server/jboss-5.0.0.GA/server/default/lib/mail.jar
This is due to this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=257823
One of the workarounds: copy mail.jar from jboss-5.0.0.GA/common/lib to /jboss-5.0.0.GA/server/default/lib.
i started the server for test purpose and got the following warning:
11:52:49,509 WARN  [AbstractDeploymentContext] Unable to register deployment mbean vfszip:/home/hilal.tarakci/ECLIPSEHOME/server/jboss-5.0.0.GA/server/default/deployers/jbossws.deployer/jaxb-xjc.jar/1.0/
javax.management.InstanceAlreadyExistsException: jboss.deployment:id="vfszip:/home/hilal.tarakci/ECLIPSEHOME/server/jboss-5.0.0.GA/server/default/deployers/jbossws.deployer/jaxb-xjc.jar/1.0/",type=SubDeployment already registered.
at org.jboss.mx.server.registry.BasicMBeanRegistry.add(BasicMBeanRegistry.java:767)
i just ignored the warning..

7) create a dynamic web project with jboss v5 as target runtime. 

8) add the sample TestWs.java to the project. (The sample code is at JBossWs Code sample with annotations: (TestWs.java)  part at http://www.javabeat.net/articles/40-creating-webservice-using-jboss-and-eclipse-europa-2.html )


10) start jboss inside eclipse. deploy the created project (by adding project to the server.)
Doing this, the following error may appear if project workspace and eclipse are on seperate disks:
Publish failed using Ant publisher
  Could not replace with temp file /tmp/tmp27108.MF.
So, put them on the same disk..

the deployed web service should appear in this list: http://localhost:8080/jbossws/services and wsdl at http://127.0.0.1:8080/JbossWsEval/TestWs?wsdl
Now, it is time to create a client for this web service. 

12) create another dynamic web project, this will include client. right click the project and select new Web Service Client (under Web Services) enter the above wsdl as service definition.
the generated stubs are under src.

13) a sample client code is as follows:
import java.rmi.RemoteException;

import com.test.dhanago.TestWs;
import com.test.dhanago.TestWsProxy;

public class TheClient {
public static void main(String[] args) {
try {
TestWsProxy aProxy = new TestWsProxy();
TestWs service = aProxy.getTestWs();
System.out.println(service.greet(" Stranger"));
} catch (RemoteException e) {
e.printStackTrace();
}
}
}

If this java app prints "Hello Stranger" , then fine :)

Hiç yorum yok:

Yorum Gönder