Hello, Aaron,

sorry for my late response. Here we go:

Aaron Mulder schrieb:
> On 5/24/06, D. Strauss <[EMAIL PROTECTED]> wrote:
>> Hello, Aaron
>>
>> I've found the error: it was an initialization problem of the bean.
>> Funnily, OpenEjb didn't care to inform me about it ;)
> 
> Could you be more specific about what the initialization problem was?
> If you can give us the specific problem (and ideally, a simple test
> case) we can make sure that OpenEJB emits a more useful error message
> in the future.
> 
> Thanks,
>    Aaron
> 
> 

I can send you the 2 affected beans. The first version is the working
version, the other one is the non-working, stacktrace-producing version.
Additionally I attach 2 support classes that you may want to check out.

For the next week I'll try to implement the beans back into the WSEP
(counting of projects and users, see the non-working bean).

Best regards
/**
 * 
 */
package ds2.kert.ejb;

import java.rmi.RemoteException;
import java.util.Date;

import javax.ejb.EJBException;
import javax.ejb.FinderException;
import javax.naming.NamingException;

import ds2.kert.ejbIF.ProjektLocalHome;
import ds2.kert.ejbIF.UserLocalHome;
import ds2.kert.ejbIF.xml.BugReport;
import ds2.kert.exceptions.UnbekannterBugException;

import xd5.annotations.WsdlOperationsArt;
import xd5.annotations.ejb.XD5EjbInterfaceMethod;
import xd5.annotations.ejb.XD5EjbInternalRef;
import xd5.annotations.ejb.XD5SessionEjb;
import xd5.annotations.geronimo.XD5GeronimoSessionEjb;
import xd5.annotations.geronimo.XD5GeronimoWebservicePort;
import xd5.annotations.ws.XD5WebservicePort;
import kaeto23.j2ee.ejb.BaseSession;
import kaeto23.j2ee.webtools.WebappBeanProvider;

/**
 * @author Lex
 *
 */
@XD5SessionEjb(name="WSEP",descr="Der Webservice-Endpunkt",serviceIF="ds2.kert.ws.WSIF",ejbRefs= {
		@XD5EjbInternalRef(ejbName="Projekt",jndiName="ejb/Projekt"),
		@XD5EjbInternalRef(ejbName="User",jndiName="ejb/User")
},localIF="ds2.kert.ejbIF.WSLocal",localHomeIF="ds2.kert.ejbIF.WSLocalHome")
@XD5WebservicePort(portName="KERTPort",serviceNameID="KERTService")
@XD5GeronimoSessionEjb(localJndiName="ejb/kert/WSEP")
@XD5GeronimoWebservicePort(endpunktUrl="/services/KERTWS")
public class WSEndpoint extends BaseSession {
	private static final long serialVersionUID = 6596640982130877515L;
	private ProjektLocalHome projekthome=null;
	private UserLocalHome userhome=null;

	public WSEndpoint() {
		super("kert.ws");
	}
	@XD5EjbInterfaceMethod(descr="Liefert die Anzahl User von KERT zur\u00fcck",wsdlOperation=WsdlOperationsArt.Notification)
	public int holeAnzUsers(){
		try {
			return userhome.findAll().size();
		} catch (FinderException e) {
			schreibeException("", e);
			e.printStackTrace(System.err);
		}
		return 0;
	}
	@XD5EjbInterfaceMethod(descr="Liefert die Anzahl registrierter Projekte zur\u00fcck",wsdlOperation=WsdlOperationsArt.Notification)
	public int holeAnzProjekte(){
		try {
			return projekthome.findAll().size();
		} catch (FinderException e) {
			schreibeException("", e);
			e.printStackTrace(System.err);
		}
		return 0;
	}
	@Override
	public void ejbActivate() throws EJBException, RemoteException {
		super.ejbActivate();
		initEjb();
	}
	private void initEjb() {
		try {
			System.out.println("Init EJBs f\u00fcr den WS");
			WebappBeanProvider bp=new WebappBeanProvider("ds2.kert.ejb");
			projekthome=bp.holeLocalVonJndi("ejb/Projekt", ProjektLocalHome.class);
			userhome=bp.holeLocalVonJndi("ejb/User", UserLocalHome.class);
			System.out.println("Init successful");
		} catch (NamingException e) {
			schreibeException("",e);
			e.printStackTrace(System.err);
		}
	}
	@XD5EjbInterfaceMethod(descr="Liefert einen komplexen Typ zur\u00fcck")
	public BugReport holeBugReport(long bugId) throws UnbekannterBugException{
		BugReport rc=null;
		rc=new BugReport();
		rc.setTitel("Ein Bug");
		rc.setId(1l);
		rc.setErstellt(new Date());
		return rc;
	}
	@XD5EjbInterfaceMethod(descr="Testprozesur")
	public long holeLongWert(String p1){
		return 0l;
	}

}
/**
 * 
 */
package ds2.kert.ejb;

import ds2.kert.ejbIF.xml.BugReport;
import ds2.kert.exceptions.UnknownBugException;
import xd5.annotations.WsdlOperationsArt;
import xd5.annotations.ejb.XD5EjbInterfaceMethod;
import xd5.annotations.ejb.XD5SessionEjb;
import xd5.annotations.geronimo.XD5GeronimoSessionEjb;
import xd5.annotations.geronimo.XD5GeronimoWebservicePort;
import xd5.annotations.ws.XD5WebservicePort;
import kaeto23.j2ee.ejb.BaseSession;

/**
 * @author Lex
 *
 */
@XD5SessionEjb(name="WSEP",descr="Der Webservice-Endpunkt",serviceIF="ds2.kert.ws.WSIF")
@XD5WebservicePort(portName="KERTPort",serviceNameID="KERTService")
@XD5GeronimoSessionEjb(localJndiName="ejb/kert/WSEP")
@XD5GeronimoWebservicePort(endpunktUrl="/services/KERTWS")
public class WSEndpoint extends BaseSession {
	private static final long serialVersionUID = 6596640982130877515L;

	public WSEndpoint() {
		super("kert.ws");
	}
	@XD5EjbInterfaceMethod(descr="Liefert die Anzahl User von KERT zur\u00fcck",wsdlOperation=WsdlOperationsArt.Notification)
	public int holeAnzUsers(){
		return 23;
	}
	@XD5EjbInterfaceMethod(descr="Liefert den aktuellen Status eines Bugs zur\u00fcck!")
	public BugReport holeBugReport(long bugId) throws UnknownBugException{
		if(bugId<=0){
			throw new UnknownBugException(bugId,"Diese Bug-ID ist nicht moeglich!");
		}
		BugReport rc=new BugReport();
		rc.setBugId(bugId);
		rc.setTitel("Ein Bug in Axis");
		rc.setBeschreibung("Axis ist leider recht schlecht, was SOAPFaults angeht.");
		return rc;
	}
}
/*
 * Created on 08.04.2005
 */
package kaeto23.j2ee.ejb;

import java.rmi.RemoteException;

import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

import kaeto23.tools.DebugLogger;

/**Eine Basis fuer zukuenftige Sessionbeans.
 * @author dirk
 */
public class BaseSession extends DebugLogger implements SessionBean {
	private static final long serialVersionUID = 3257562914868311860L;
	protected SessionContext sc=null;

	public BaseSession(String name) {
		super(name);
	}

	/** (non-Javadoc)
	 * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
	 */
	public void setSessionContext(SessionContext arg0) throws EJBException,
			RemoteException {
		sc=arg0;
	}

	/** (non-Javadoc)
	 * @see javax.ejb.SessionBean#ejbRemove()
	 */
	public void ejbRemove() throws EJBException, RemoteException {
	}

	/** (non-Javadoc)
	 * @see javax.ejb.SessionBean#ejbActivate()
	 */
	public void ejbActivate() throws EJBException, RemoteException {
	}

	/** (non-Javadoc)
	 * @see javax.ejb.SessionBean#ejbPassivate()
	 */
	public void ejbPassivate() throws EJBException, RemoteException {
	}
	/**
	 * Erstellt die Bean.
	 * @throws CreateException
	 */
	public void ejbCreate() throws CreateException {
	}

}
/*
Kaeto23 Base Package - A collection of some tools, Annotations, Annotation Processors and many more
Copyright (C) 2004-2006, Dirk Strauss <[EMAIL PROTECTED]>

This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

 */
package kaeto23.j2ee.webtools;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import javax.transaction.UserTransaction;

import kaeto23.tools.DebugLogger;

/**
 * @author Lex
 *
 */
public class WebappBeanProvider extends DebugLogger {
	/**
	 * Der Context-Pfad fuer alle Webapp-Clients.
	 */
	protected String ctxBase="java:comp/env";
	/**
	 * Der Context ab ctxBase
	 */
	protected Context ctx=null;
	/**
	 * Der Basis-Context
	 */
	protected Context baseCtx=null;
	/**
	 * Ein moegliches UserTransaction-Modul.
	 */
	protected UserTransaction userTransaction=null;

	/**
	 * @param name
	 * @throws NamingException 
	 */
	public WebappBeanProvider(String name) throws NamingException {
		super(name);
		baseCtx=new InitialContext();
		ctx=(Context) baseCtx.lookup(ctxBase);
	}
	/**
	 * Liefert das lokale Objekt vom JNDI-Pfad zurueck.
	 * @param <E> eine Objektklasse
	 * @param jndiPfad der Pfad zum Objekt, ab ctxBase
	 * @param zielKlasse die Zielklasse
	 * @return das Objekt, oder null
	 * @throws NamingException
	 */
	public <E> E holeLocalVonJndi(String jndiPfad, Class<E> zielKlasse) throws NamingException{
		Object o=ctx.lookup(jndiPfad);
		if(o==null){
			return null;
		}
		if(zielKlasse==null){
			throw new NullPointerException("Es wurde keine Zielklasse angegeben!");
		}
		E rc=zielKlasse.cast(o);
		return rc;
	}
	/**
	 * Holt ein Objekt aus dem JNDI und naehert es per PortableRemote an die Zielklasse an.
	 * @param <E> der Zieltyp
	 * @param jndiPfad der JNDI-Pfad des Objektes
	 * @param zielKlasse die Zielklasse
	 * @return das Objekt, oder null
	 * @throws NamingException falls das Objekt nicht im JNDI existiert
	 */
	public <E> E holeRemoteVonJndi(String jndiPfad, Class<E> zielKlasse) throws NamingException{
		Object o=ctx.lookup(jndiPfad);
		if(o==null){
			return null;
		}
		if(zielKlasse==null){
			throw new NullPointerException("Keine Zielklasse angegeben!");
		}
		E rc=zielKlasse.cast(PortableRemoteObject.narrow(o, zielKlasse));
		return rc;
	}
	/**
	 * Liefert ein JNDI-Objekt ab der Basis zurueck.
	 * @param <E> der Zieltyp
	 * @param jndiPfad der JNDI-Pfad
	 * @param zielKlasse die Klasse des Objekts
	 * @return das Objekt, oder null
	 * @throws NamingException
	 */
	public <E> E holeVonBasisJndi(String jndiPfad, Class<E> zielKlasse) throws NamingException{
		Object o=baseCtx.lookup(jndiPfad);
		if(o==null){
			return null;
		}
		E rc=zielKlasse.cast(o);
		return rc;
	}
	/**
	 * Liefert das UserTransaction-Objekt zurueck.
	 * @return das UT-Objekt, oder null
	 */
	public UserTransaction holeUserTransaction(){
		return userTransaction;
	}
	/**
	 * Laedt das UserTransaction-Object von java:comp/UserTransaction
	 * @throws NamingException falls das Objekt nicht an der Stelle existiert
	 */
	protected void ladeUserTransaction() throws NamingException {
		userTransaction=UserTransaction.class.cast(baseCtx.lookup("java:comp/UserTransaction"));
	}

}

Reply via email to