Ciao a tutti,
Premetto che sono alle prime armi con gli EJB. Ho creato un EJB SESSION con ecplise e come application server JBOSS v. (jboss-4.2.2.GA) usando XDOCLET V1.2.3.
Ho creato una classe Main e il tutto mi funziona correttamente. Il mio problema sta quando creo un progetto di tipo "Dynamic web Project". In sostanza ho creato una servlet dove chiamo un metodo dell'interfaccia Remota. Quando provo a lanciare la servlet mi genera il seguente errore ERROR [LogInterceptor] EJBException in method: public abstract
Di seguito il codice della mia servlet e i 2 file web.xml e jboss-web.xml che si trovano dentro la cartella WEB-INF del progetto web.
Classe Servlet:
package com.ejb;
import java.io.IOException;
import java.rmi.RemoteException;
import java.util.Properties;
import javax.ejb.CreateException;
import javax.ejb.RemoveException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class for Servlet: Miaa
*
* @web.servlet
* name="Miaa"
* display-name="Miaa"
*
* @web.servlet-mapping
* url-pattern="/Miaa"
*
*/
public class Miaa extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
static final long serialVersionUID = 1L;
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public Miaa() {
super();
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRe quest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
Context c;
try {
Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.namingrg.jnp.interfaces");
c = new InitialContext(env);
Object o = c.lookup ("Hello");
HelloHome home =
(HelloHome)PortableRemoteObject.narrow (o,HelloHome.class);
Hello hello = home.create();
System.out.println (hello.getName("ciao"));
hello.remove();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoveException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/* (non-Javadoc)
* @see javax.servlet.Servlet#getServletInfo()
*/
public String getServletInfo() {
// TODO Auto-generated method stub
return super.getServletInfo();
}
}
WEB.XML
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="web-app_1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>test_web</display-name>
<distributable/>
<!--
To use non XDoclet filters, create a filters.xml file that
contains the additional filters (eg Sitemesh) and place it in your
project's merge dir. Don't include filter-mappings in this file,
include them in a file called filter-mappings.xml and put that in
the same directory.
-->
<!--
To use non XDoclet filter-mappings, create a filter-mappings.xml file that
contains the additional filter-mappings and place it in your
project's merge dir.
-->
<!--
To use non XDoclet listeners, create a listeners.xml file that
contains the additional listeners and place it in your
project's merge dir.
-->
<servlet>
<display-name>Miaa</display-name>
<servlet-name>Miaa</servlet-name>
<servlet-class>com.ejb.Miaa</servlet-class>
</servlet>
<!--
To use non XDoclet servlets, create a servlets.xml file that
contains the additional servlets (eg Struts) and place it in your
project's merge dir. Don't include servlet-mappings in this file,
include them in a file called servlet-mappings.xml and put that in
the same directory.
-->
<servlet-mapping>
<servlet-name>Miaa</servlet-name>
<url-pattern>/Miaa</url-pattern>
</servlet-mapping>
<!--
To specify mime mappings, create a file named mime-mappings.xml, put it in your project's mergedir.
Organize mime-mappings.xml following this DTD slice:
<!ELEMENT mime-mapping (extension, mime-type)>
-->
<!--
To specify error pages, create a file named error-pages.xml, put it in your project's mergedir.
Organize error-pages.xml following this DTD slice:
<!ELEMENT error-page ((error-code | exception-type), location)>
-->
<!--
To add taglibs by xml, create a file called taglibs.xml and place it
in your merge dir.
-->
<!--
To set up security settings for your web app, create a file named web-security.xml, put it in your project's mergedir.
Organize web-security.xml following this DTD slice:
<!ELEMENT security-constraint (display-name?, web-resource-collection+, auth-constraint?, user-data-constraint?)>
<!ELEMENT web-resource-collection (web-resource-name, description?, url-pattern*, http-method*)>
<!ELEMENT web-resource-name (#PCDATA)>
<!ELEMENT url-pattern (#PCDATA)>
<!ELEMENT http-method (#PCDATA)>
<!ELEMENT user-data-constraint (description?, transport-guarantee)>
<!ELEMENT transport-guarantee (#PCDATA)>
<!ELEMENT login-config (auth-method?, realm-name?, form-login-config?)>
<!ELEMENT auth-method (#PCDATA)>
<!ELEMENT realm-name (#PCDATA)>
<!ELEMENT form-login-config (form-login-page, form-error-page)>
<!ELEMENT form-login-page (#PCDATA)>
<!ELEMENT form-error-page (#PCDATA)>
-->
</web-app>
JBOSS-WEB.XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
<jboss-web>
<context-root>test_web</context-root>
<!--
For additional resouce-env-ref tags add a merge file called jbossweb-resource-env-ref.xml
-->
<!--
For additional resouce-ref tags add a merge file called jbossweb-resource-ref.xml
-->
<!--
For additional ejb-ref tags add a merge file called jbossweb-ejb-ref.xml
-->
<!--
For additional ejb-local-ref tags add a merge file called jbossweb-ejb-local-ref.xml
-->
</jboss-web>
l'eccezzione generata è la seguente:
ERROR [LogInterceptor] EJBException in method: public abstract com.ejb.Hello com.ejb.HelloHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException :
javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract com.ejb.Hello com.ejb.HelloHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException
at org.jboss.ejb.StatelessSessionContainer$ContainerI nterceptor.invokeHome(StatelessSessionContainer.ja va:175)
at org.jboss.resource.connectionmanager.CachedConnect ionInterceptor.invokeHome(CachedConnectionIntercep tor.java:189)
at org.jboss.ejb.plugins.StatelessSessionInstanceInte rceptor.invokeHome(StatelessSessionInstanceInterce ptor.java:98)
at org.jboss.ejb.plugins.CallValidationInterceptor.in vokeHome(CallValidationInterceptor.java:56)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invoke Next(AbstractTxInterceptor.java:125)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTran sactions(TxInterceptorCMT.java:350)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome( TxInterceptorCMT.java:161)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHo me(SecurityInterceptor.java:145)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(Lo gInterceptor.java:132)
at org.jboss.ejb.plugins.ProxyFactoryFinderIntercepto r.invokeHome(ProxyFactoryFinderInterceptor.java:10 7)
at org.jboss.ejb.SessionContainer.internalInvokeHome( SessionContainer.java:637)
at org.jboss.ejb.Container.invoke(Container.java:981)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invok e(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation .java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.j ava:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(Ab stractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanSe rverImpl.java:659)
at org.jboss.invocation.local.LocalInvoker$MBeanServe rAction.invoke(LocalInvoker.java:169)
at org.jboss.invocation.local.LocalInvoker.invoke(Loc alInvoker.java:118)
at org.jboss.invocation.InvokerInterceptor.invokeLoca l(InvokerInterceptor.java:209)
at org.jboss.invocation.InvokerInterceptor.invoke(Inv okerInterceptor.java:195)
at org.jboss.proxy.TransactionInterceptor.invoke(Tran sactionInterceptor.java:61)
at org.jboss.proxy.SecurityInterceptor.invoke(Securit yInterceptor.java:70)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInt erceptor.java:184)
at org.jboss.proxy.ClientContainer.invoke(ClientConta iner.java:100)
at $Proxy139.create(Unknown Source)
at com.ejb.Miaa.doGet(Miaa.java:58)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.service.session.ClusteredSess ionValve.invoke(ClusteredSessionValve.java:87)
at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionV alve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:446)
at java.lang.Thread.run(Unknown Source)
16:21:39,890 ERROR [STDERR] java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract com.ejb.Hello com.ejb.HelloHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException
16:21:39,890 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.handleExcepti on(LogInterceptor.java:365)
16:21:39,890 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(Lo gInterceptor.java:136)
16:21:39,890 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderIntercepto r.invokeHome(ProxyFactoryFinderInterceptor.java:10 7)
16:21:39,890 ERROR [STDERR] ... 43 more
--------------------------------------------------------------------------------------
La servlet funziona solo se cancello le interfaccie dall'EAR.
Qualcuno sa dirmi come posso fare? è una settimana che ci stò sbattendo la testa ma risultati "0".
Vi ringrazio in aticipo!!!![]()

rg.jnp.interfaces");
Rispondi quotando