Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » problem with a java class converting in web service
problem with a java class converting in web service [message #195628] Wed, 04 July 2007 11:08 Go to next message
Eclipse User
Originally posted by: bielefeld.libero.it

Hi,

I've created a java class that download in a local folder a csv file from
yahoo (containing the mib30 value) and then extract this value and return
it... Ive tried running this class and it works fine

now I want to transform this java class in a web service... I've got
eclipse, wtp and axis2 plugins, and I'm following this tutorial
(http://wso2.org/library/1719) to make the conversion of the java class in a
web service

My problem is that after i make aar file for the service and import this
into axis2, when I call http://localhost:8080/axis2/services I see that my
service is faulty, and clicking on link I see these errors



Error: org.apache.axis2.deployment.DeploymentException: Processing
Operations Modules Error in schema generating FornisciValore; nested
exception is: java.lang.ClassNotFoundException: FornisciValore; nested
exception is: org.apache.axis2.deployment.DeploymentException: Error in
schema generating FornisciValore; nested exception is:
java.lang.ClassNotFoundException: FornisciValore; nested exception is:
org.apache.axis2.deployment.DeploymentException: Processing Operations
Modules Error in schema generating FornisciValore; nested exception is:
java.lang.ClassNotFoundException: FornisciValore; nested exception is:
org.apache.axis2.deployment.DeploymentException: Error in schema generating
FornisciValore; nested exception is: java.lang.ClassNotFoundException:
FornisciValore at
org.apache.axis2.deployment.repository.util.ArchiveReader.pr ocessServiceGroup(ArchiveReader.java:139)
at
org.apache.axis2.deployment.DeploymentEngine.doDeploy(Deploy mentEngine.java:528)
at org.apache.axis2.deployment.repository.util.WSInfoList.updat e
(WSInfoList.java:196) at
org.apache.axis2.deployment.RepositoryListener.update(Reposi toryListener.java:227)
at
org.apache.axis2.deployment.RepositoryListener.checkServices (RepositoryListener.java:174)
at
org.apache.axis2.deployment.RepositoryListener.startListener (RepositoryListener.java:219)
at
org.apache.axis2.deployment.scheduler.SchedulerTask.checkRep ository(SchedulerTask.java:61)
at
org.apache.axis2.deployment.scheduler.SchedulerTask.run(Sche dulerTask.java:68)
at
org.apache.axis2.deployment.scheduler.Scheduler$SchedulerTim erTask.run(Scheduler.java:76)
at java.util.TimerThread.mainLoop(Timer.java:512) at
java.util.TimerThread.run(Timer.java:462) Caused by:
org.apache.axis2.deployment.DeploymentException: Processing Operations
Modules Error in schema generating FornisciValore; nested exception is:
java.lang.ClassNotFoundException: FornisciValore; nested exception is:
org.apache.axis2.deployment.DeploymentException: Error in schema generating
FornisciValore; nested exception is: java.lang.ClassNotFoundException:
FornisciValore at
org.apache.axis2.deployment.ServiceBuilder.populateService(S erviceBuilder.java:332)
at
org.apache.axis2.deployment.repository.util.ArchiveReader.bu ildServiceGroup(ArchiveReader.java:91)
at
org.apache.axis2.deployment.repository.util.ArchiveReader.pr ocessServiceGroup(ArchiveReader.java:133)
.... 10 more Caused by: org.apache.axis2.deployment.DeploymentException:
Error in schema generating FornisciValore; nested exception is:
java.lang.ClassNotFoundException: FornisciValore at
org.apache.axis2.deployment.ServiceBuilder.populateService(S erviceBuilder.java:307)
.... 12 more Caused by: java.lang.ClassNotFoundException: FornisciValore at
java.net.URLClassLoader$1.run(URLClassLoader.java:200) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:188) at
java.lang.ClassLoader.loadClass(ClassLoader.java:306) at
java.lang.ClassLoader.loadClass(ClassLoader.java:251) at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 ) at
java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:247) at
org.apache.ws.java2wsdl.SchemaGenerator.(SchemaGenerator.jav a:92) at
org.apache.axis2.deployment.util.Utils.fillAxisService(Utils .java:272) at
org.apache.axis2.deployment.ServiceBuilder.populateService(S erviceBuilder.java:297)
.... 12 more



Now I can't understand because my java class works fine, and when I convert
it in a web service doesn't work

Could you please help me? thanks a lot

This is the source code of my java class:


import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;


public class FornisciValore {

/**
* @param args
*/

public static int returnValore () throws IOException
{

try
{
URL url = new URL("http://tinyurl.com/2ttw75");
InputStream is = url.openStream();
System.out.flush();
FileOutputStream fos=null;
fos = new FileOutputStream("C:\\WSmib30\\quotes.csv");
int oneChar, count=0;
while ((oneChar=is.read()) != -1)
{
fos.write(oneChar);
count++;
}
is.close();
fos.close();
}
catch (MalformedURLException e)
{ System.err.println(e.toString()); }
catch (IOException e)
{ System.err.println(e.toString()); }

BufferedReader filebuffer = new BufferedReader(new
FileReader("C:\\WSmib30\\quotes.csv"));
String next,ultimo;
next=filebuffer.readLine();
filebuffer.close();
ultimo=next.substring(7,12);
System.out.println(ultimo); //print on screen mib30 value
int valore = Integer.parseInt(ultimo); //convert mib30 string in an
integer value
return(valore); // returns mib30 value

}

}
Re: problem with a java class converting in web service [message #195644 is a reply to message #195628] Wed, 04 July 2007 14:49 Go to previous messageGo to next message
Peter Moogk is currently offline Peter Moogk
Messages: 15
Registered: July 2009
Junior Member
Hi,
There is a much easier Axis2 tutorial that shows how to convert your
Java class into an Axis2 Web service. Have a look at
http://www.eclipse.org/webtools/community/tutorials/BottomUp Axis2WebService/bu_tutorial.html

Make sure that you download the latest WTP 2.0 code.

I used your code without changes to create an Axis2 Web services without a
problem.

If you are interested I also wrote a simplified version of your class that
doesn't write to a file. Here it is:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;


public class FornisciValore2 {
public static int returnValore () throws IOException
{
int result = -1;
InputStream is = null;
BufferedReader reader = null;

try
{
URL url = new URL("http://tinyurl.com/2ttw75");

is = url.openStream();
reader = new BufferedReader( new InputStreamReader( is ) );

String line = reader.readLine();
int semiIndex = line.indexOf( ';' );
int commaIndex = line.indexOf( ',' );
String value = line.substring( semiIndex + 1, commaIndex );

result = Integer.parseInt( value );

System.out.println( "line=>" + line );
System.out.println( "result=>" + result );
}
catch (MalformedURLException e)
{ System.err.println(e.toString()); }
catch (IOException e)
{ System.err.println(e.toString()); }
finally
{
try
{
if( is != null )
{
is.close();
}

if( reader != null )
{
reader.close();
}
}
catch( IOException exc )
{
exc.printStackTrace();
}
}

return result;
}
}
Re: problem with a java class converting in web service [message #195683 is a reply to message #195644] Thu, 05 July 2007 05:13 Go to previous message
Eclipse User
Originally posted by: bielefeld.libero.it

thanks a lot, I'll update all my tools (eclipse + wtp + others) and then
I'll try with the tutorial at
http://www.eclipse.org/webtools/community/tutorials/BottomUp Axis2WebService/bu_tutorial.html

best regards
Previous Topic:Failed to start Websphere 6.1 from Eclipse-WTP-All-in-one
Next Topic:JNDI browser in Webtools
Goto Forum:
  


Current Time: Fri Aug 29 08:13:37 EDT 2014

Powered by FUDForum. Page generated in 0.02271 seconds