Jump to content

Deploying Java web services with Axis2

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
ludvig

ludvig

    Newbie

  • Members
  • Pip
  • 2 posts
I have a rather simple java - class looking somewhat like this (See under), and was wondering how to deploy it using Jetty and Axis2. I have tried to follow simple examples as this (Sorry, couldnt post link to apace site), and I got the example itself up and running, but haven't managed to do the same with the example-code below. The main difference is of course that I'm including some libraries. I am also unsure of how to write the services.xml - file.

Hope someone can help, thanks in advance.

-Ludvig-
package services;

import java.io.FileInputStream;
import java.io.IOException;

import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.InfModel;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.reasoner.Reasoner;
import com.hp.hpl.jena.reasoner.ReasonerRegistry;


public class OntologyService {
	public static final String defaultNameSpace = "namespaceurl";
	
	public OntologyService(){
	
	}

	public String getSomeInfo(String thing){
      ...
		return finalResult;
  }
	
	
	public String getSomeInfo2(String thing){
      ...
		return finalResult;
	}
	
	
	public String getSomeInfo3(String thing){
      ...
		return finalResult;
	}
	
	
	public String getSomeInfo4(String thing, int limit){
      ...
		return finalResult;	
	}

}

Edited by WingedPanther, 14 November 2009 - 10:30 AM.
add code tags (the # button)


#2
ludvig

ludvig

    Newbie

  • Members
  • Pip
  • 2 posts
I figured out my initial problem (using Axis2 Service Archiver plugin for eclipse), but have encountered a new one. The methods works fine run locally, but published as services I get a nullpointer. ("Model is a nullpointer")

See code under:
/* This is the constructor and can not be called directly as web service, but is used by the methods that can, see example method under the constructor.*/
public FotballOntologyServices(){
		try {

			Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
			model = ModelFactory.createOntologyModel();
			FileInputStream dataStream = new FileInputStream("../turtle/fotballOntology.turtle");
			model.read(dataStream, null, "TURTLE");
			reasoner = reasoner.bindSchema(model);
			inferenceModel = ModelFactory.createInfModel(reasoner, model);
			dataStream.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

public static String getTeamInfoService(String teamName){
		FotballOntologyServices serviceObject = new FotballOntologyServices();
		return serviceObject.getTeamInfo(teamName);
	}
Any ideas? I suspect that it has something to do with the FileInputStream, but I'm not sure.

Regards,
Ludvig

Edited by WingedPanther, 14 November 2009 - 10:30 AM.
add code tags (the # button)