• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with exceptions

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting a error " Every method in interface must have a corresponding method have a public method in bean class. Please help what changes should I make in Interface method declaration test1 so that the test1 method works.

package examples.webservices.rpc.MySessionBean;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface TestSession extends EJBObject
{
public String test1(String str1) throws RemoteException;
}
-------------------------------------------------------
package examples.webservices.rpc.MySessionBean;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.io.*;
import java.net.*;
import java.util.*;
public class TestSessionBean implements SessionBean
{
private static final boolean VERBOSE = true;
private SessionContext ctx;
private int tradeLimit;
private void log(String s) {
if (VERBOSE) System.out.println(s);
}
public void ejbActivate() {
log("ejbActivate called");
}
public void ejbRemove() {
log("ejbRemove called");
}
public void ejbPassivate() {
log("ejbPassivate called");
}
public void setSessionContext(SessionContext ctx) {
log("setSessionContext called");
this.ctx = ctx;
}
public void ejbCreate () throws CreateException {
log("ejbCreate called");
try {
InitialContext ic = new InitialContext();
} catch (NamingException ne) {
throw new CreateException("Failed to find environment value "+ne);
}
}
public String test1(String str1) {
StringBuffer inputLineBuf= new StringBuffer();
try{
String st = str1;
String urlname = "http://localhost:7001/testperl.pl?" ;
char ch = '&';
char nl = '\n';
URL url = new URL(urlname);
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
PrintWriter out = new PrintWriter(
connection.getOutputStream());
out.print("cust_num="+ URLEncoder.encode(cust_num));
out.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
inputLineBuf.append(inputLine);
}
in.close();
}catch(IOException e){ System.out.println("error edit");}
return inputLineBuf.toString() ;
}
}
 
peter brews
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cuaght my error. In my program the method name was test1 in interface. But in bean calls it was tste1. I corrected this to test and it worked
 
reply
    Bookmark Topic Watch Topic
  • New Topic