2013-10-21 6 views
0

저는 EJB가 처음입니다. 예외가 발생했습니다. EJB

이 내가 만든이 첫 번째

package Ejb01; 

import java.util.Iterator; 
import java.util.Vector; 
import javax.annotation.PostConstruct; 
import javax.ejb.Singleton; 
import javax.ejb.Startup; 



@Singleton 
@Startup 
public class Ejb01 implements Ejb01Remote,Ejb01Local { 

Vector geheugen; 

@PostConstruct 
void inhetbegin() { 
    geheugen = new Vector(); 
    Contact c = new Contact(); 
    geheugen.add(c); 
} 

public void voegtoe(String number, String naam) { 
    Contact c = new Contact(naam, number); 
    geheugen.add(c); 
} 

@Override 
public Vector geefGeheugen() { 
    return geheugen; 
} 

@Override 
public String giveName(String number) { 
    String result = "NOT FOUND"; 
    for (Iterator it = geheugen.iterator(); it.hasNext();) { 
     Contact i = (Contact) it.next(); 
     if(i.getNumber().equals(number)) 
     { 
      result=i.getName(); 
     } 
    } 
     return result; 

    } 
} 
하지만 내가 다른 일을 할 때 :

package Ejb02; 

import Ejb01.Ejb01Local; 
import Ejb01.Ejb01Remote; 
import java.util.Vector; 
import java.util.logging.Level; 
import java.util.logging.Logger; 
import javax.annotation.PostConstruct; 
import javax.ejb.EJB; 
import javax.ejb.Remove; 
import javax.ejb.Stateful; 
import javax.naming.Context; 
import javax.naming.InitialContext; 
import javax.naming.NamingException; 


@Stateful 
public class Ejb02 implements Ejb02Remote{ 

@Remove  
public void gedaan(){} 
@EJB 
private Ejb01Local boontje; 


@Override 
public String geefNaam() { 
String result="Not found."; 

     //Context c= new InitialContext(); 
     // Ejb01Remote boontje=(Ejb01Remote)    
    c.lookup("java:global/EJBModule1/Ejb01!Ejb01.Ejb01Remote"); 
     result= boontje.giveName("0470/355.625"); 

    return result; 

}

}

내가 (글래스 피쉬 서버 로그)를 얻을 :

ant -f /Users/eoghainverdonckt/Documents/netBeansProjects/EJB02 -DforceRedeploy=true -Ddirectory.deployment.supported=true -Dnb.wait.for.caches=true run 
init: 
EJBModule1.init: 
EJBModule1.deps-jar: 
EJBModule1.compile: 
EJBModule1.library-inclusion-in-archive: 
EJBModule1.dist: 
deps-jar: 
compile: 
library-inclusion-in-archive: 
dist-directory-deploy: 
pre-run-deploy: 
In-place deployment at /Users/eoghainverdonckt/Documents/netBeansProjects/EJB02/build/classes 
Initializing... 
deploy?DEFAULT=/Users/eoghainverdonckt/Documents/netBeansProjects/EJB02/build/classes&name=EJB02&libraries=/Users/eoghainverdonckt/Documents/netBeansProjects/EJBModule1/dist/EJBModule1.jar&force=true failed on GlassFish Server 3.1.2 
Error occurred during deployment: Exception while deploying the app [EJB02] : Invalid ejb jar [EJB02]: it contains zero ejb. 
Note: 
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean. 
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar. 
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.. Please see server.log for more details. 
/Users/eoghainverdonckt/Documents/netBeansProjects/EJB02/nbproject/build-impl.xml:920: The module has not been deployed. 
See the server log for details. 
BUILD FAILED (total time: 0 seconds) 

그리고 지금 나는 왜 그런가 ?? 어떻게 해결할 수 있습니까?

+0

구현에 @LocalBean을 추가하십시오. – constantlearner

+0

빠른 응답을 보내 주셔서 감사합니다. 시도했습니다 @ LocalBean @ Stateful 공용 클래스 Ejb02 implements Ejb02Remote {여전히 같은 오류? 어쩌면 나는 그것을 잘못된 장소에 넣었을 까? –

+0

클래스 이름을 Ejb02Bean 및 Ejb01Bean으로 지정하십시오. – constantlearner

답변

1

인터페이스 클래스에 @Remote를 넣는 것을 잊었습니다. 그냥 알아 냈습니다.

관련 문제