2017-11-07 4 views
0

waysを試してみるとEJBからappclientまでは成功しません。 JNDIルックアップ失敗のappclient-clientを使用してEJBをルックアップする方法は? (NamingException)

スタックトレース:

[email protected]:~/NetBeansProjects/ejbClient$ 
[email protected]:~/NetBeansProjects/ejbClient$ gradle clean shadowJar 
> Task :shadowJar 
The SimpleWorkResult type has been deprecated and is scheduled to be removed in Gradle 5.0. Please use WorkResults.didWork() instead. 


BUILD SUCCESSFUL in 0s 
4 actionable tasks: 4 executed 
[email protected]:~/NetBeansProjects/ejbClient$ 
[email protected]:~/NetBeansProjects/ejbClient$ appclient -client build/libs/ejbClient.jar Nov 06, 2017 5:13:34 PM net.bounceme.dur.ejb.client.App main 
SEVERE: null 
javax.naming.NamingException: Lookup failed for 'java:global/EJBModule1/FooBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacenet.bounceme.dur.ejb.NewSessionBeanRemote [Root exception is java.lang.ClassNotFoundException: net.bounceme.dur.ejb.NewSessionBeanRemote]] 
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491) 
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438) 
    at javax.naming.InitialContext.lookup(InitialContext.java:417) 
    at net.bounceme.dur.ejb.client.App.run(App.java:19) 
    at net.bounceme.dur.ejb.client.App.main(App.java:24) 
Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfacenet.bounceme.dur.ejb.NewSessionBeanRemote [Root exception is java.lang.ClassNotFoundException: net.bounceme.dur.ejb.NewSessionBeanRemote] 
    at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:433) 
    at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75) 
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321) 
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:527) 
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:487) 
    ... 4 more 
Caused by: java.lang.ClassNotFoundException: net.bounceme.dur.ejb.NewSessionBeanRemote 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at org.glassfish.appclient.client.acc.ACCClassLoader.findClass(ACCClassLoader.java:237) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:685) 
    at com.sun.ejb.EJBUtils.loadGeneratedRemoteBusinessClasses(EJBUtils.java:462) 
    at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:413) 
    ... 8 more 

[email protected]:~/NetBeansProjects/ejbClient$ 

クリーン、Netbeansのデフォルトantからビルドおよびデプロイします。

[email protected]:~/NetBeansProjects/EJBModule1$ 
[email protected]:~/NetBeansProjects/EJBModule1$ asadmin list-applications 
Nothing to list. 
No applications are deployed to this target server. 
Command list-applications executed successfully. 
[email protected]:~/NetBeansProjects/EJBModule1$ 
[email protected]:~/NetBeansProjects/EJBModule1$ ant -p 
Buildfile: /home/thufir/NetBeansProjects/EJBModule1/build.xml 
Builds, tests, and runs the project EJBModule1. 
Main targets: 

-profile-pre72   Profile a J2EE project in the IDE. 
clean     Clean build products. 
compile    Compile project. 
debug     Debug project in IDE. 
default    Build whole project. 
dist     Build distribution (JAR). 
dist-directory-deploy Build distribution (JAR) - if directory deployment is not supported. 
dist-ear    Build distribution (JAR) to be packaged into an EAR. 
javadoc    Build Javadoc. 
profile    Profile a J2EE project in the IDE. 
run     Deploy to server. 
test     Run unit tests. 
test-single   Run single unit test. 
test-single-method  Run single unit test. 
Default target: default 
[email protected]:~/NetBeansProjects/EJBModule1$ 
[email protected]:~/NetBeansProjects/EJBModule1$ ant clean run 
Buildfile: /home/thufir/NetBeansProjects/EJBModule1/build.xml 

-pre-init: 

-init-private: 

-init-userdir: 

-init-user: 

-init-project: 

-init-macrodef-property: 

-do-init: 

-post-init: 

-init-check: 

-init-ap-cmdline-properties: 

-init-macrodef-javac-with-processors: 

-init-macrodef-javac-without-processors: 

-init-macrodef-javac: 

-init-macrodef-test-impl: 

-init-macrodef-junit-init: 

-init-macrodef-junit-single: 

-init-test-properties: 

-init-macrodef-junit-batch: 

-init-macrodef-junit: 

-init-macrodef-junit-impl: 

-init-macrodef-testng: 

-init-macrodef-testng-impl: 

-init-macrodef-test: 

-init-macrodef-junit-debug: 

-init-macrodef-junit-debug-batch: 

-init-macrodef-junit-debug-impl: 

-init-macrodef-test-debug-junit: 

-init-macrodef-testng-debug: 

-init-macrodef-testng-debug-impl: 

-init-macrodef-test-debug-testng: 

-init-macrodef-test-debug: 

-init-macrodef-java: 

-init-debug-args: 

-init-macrodef-nbjpda: 

-init-macrodef-debug: 

-init-taskdefs: 

-init-ap-cmdline-supported: 

-init-ap-cmdline: 

init: 

undeploy-clean: 

deps-clean: 

-do-clean: 
    [delete] Deleting directory /home/thufir/NetBeansProjects/EJBModule1/build 
    [delete] Deleting directory /home/thufir/NetBeansProjects/EJBModule1/dist 

-post-clean: 

clean: 

-pre-init: 

-init-private: 

-init-userdir: 

-init-user: 

-init-project: 

-init-macrodef-property: 

-do-init: 

-post-init: 

-init-check: 

-init-ap-cmdline-properties: 

-init-macrodef-javac-with-processors: 

-init-macrodef-javac-without-processors: 

-init-macrodef-javac: 

-init-macrodef-test-impl: 

-init-macrodef-junit-init: 

-init-macrodef-junit-single: 

-init-test-properties: 

-init-macrodef-junit-batch: 

-init-macrodef-junit: 

-init-macrodef-junit-impl: 

-init-macrodef-testng: 

-init-macrodef-testng-impl: 

-init-macrodef-test: 

-init-macrodef-junit-debug: 

-init-macrodef-junit-debug-batch: 

-init-macrodef-junit-debug-impl: 

-init-macrodef-test-debug-junit: 

-init-macrodef-testng-debug: 

-init-macrodef-testng-debug-impl: 

-init-macrodef-test-debug-testng: 

-init-macrodef-test-debug: 

-init-macrodef-java: 

-init-debug-args: 

-init-macrodef-nbjpda: 

-init-macrodef-debug: 

-init-taskdefs: 

-init-ap-cmdline-supported: 

-init-ap-cmdline: 

init: 

-init-cos: 

-init-deploy: 

-deps-module-jar: 

-deps-ear-jar: 

deps-jar: 

-pre-pre-compile: 
    [mkdir] Created dir: /home/thufir/NetBeansProjects/EJBModule1/build/classes 

-pre-compile: 

-copy-meta-inf: 
    [copy] Copying 1 file to /home/thufir/NetBeansProjects/EJBModule1/build/classes/META-INF 

-do-compile: 
    [mkdir] Created dir: /home/thufir/NetBeansProjects/EJBModule1/build/empty 
    [mkdir] Created dir: /home/thufir/NetBeansProjects/EJBModule1/build/generated-sources/ap-source-output 
    [javac] Compiling 2 source files to /home/thufir/NetBeansProjects/EJBModule1/build/classes 

-post-compile: 

compile: 

-library-inclusion-in-archive-weblogic: 

-library-inclusion-in-archive-by-user: 

library-inclusion-in-archive: 

-pre-dist: 

-do-tmp-dist-without-manifest: 

-do-tmp-dist-with-manifest: 
    [mkdir] Created dir: /home/thufir/NetBeansProjects/EJBModule1/dist 
     [jar] Building jar: /home/thufir/NetBeansProjects/EJBModule1/dist/EJBModule1.jar 

-do-dist-directory-deploy: 

-post-dist: 

dist-directory-deploy: 

pre-run-deploy: 

-pre-nbmodule-run-deploy: 

-run-deploy-nb: 

-init-deploy-ant: 

-init-cl-deployment-env: 

-parse-glassfish-web: 

-parse-sun-web: 

-no-parse-sun-web: 

-add-resources: 

-deploy-ant: 

-deploy-without-pw: 
    [echo] Deploying dist/EJBModule1.jar 
     [get] Getting: http://localhost:4848/__asadmin/deploy?path=/home/thufir/NetBeansProjects/EJBModule1/dist/EJBModule1.jar&force=true&name=EJBModule1 
     [get] To: /tmp/gfv31064357726 
    [delete] Deleting: /tmp/gfv31064357726 

-deploy-with-pw: 

-run-deploy-am: 

-post-nbmodule-run-deploy: 

post-run-deploy: 

-do-update-breakpoints: 

run-deploy: 

run: 

BUILD SUCCESSFUL 
Total time: 1 second 
[email protected]:~/NetBeansProjects/EJBModule1$ 
[email protected]:~/NetBeansProjects/EJBModule1$ asadmin list-applications 
EJBModule1 <ejb> 
Command list-applications executed successfully. 
[email protected]:~/NetBeansProjects/EJBModule1$ 
[email protected]:~/NetBeansProjects/EJBModule1$ 
[email protected]:~/NetBeansProjects/EJBModule1$ 

GlassFishのログ:

[2017-11-06T16:40:44.695-0800] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(2)] [timeMillis: 1510015244695] [levelValue: 800] [[ 
    visiting unvisited references]] 

[2017-11-06T16:40:44.699-0800] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=43 _ThreadName=admin-listener(2)] [timeMillis: 1510015244699] [levelValue: 800] [[ 
    visiting unvisited references]] 

[2017-11-06T16:40:44.746-0800] [glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: _ThreadID=43 _ThreadName=admin-listener(2)] [timeMillis: 1510015244746] [levelValue: 800] [[ 
    Portable JNDI names for EJB FooBean: [java:global/EJBModule1/FooBean!net.bounceme.dur.ejb.NewSessionBeanRemote, java:global/EJBModule1/FooBean]]] 

[2017-11-06T16:40:44.746-0800] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid: _ThreadID=43 _ThreadName=admin-listener(2)] [timeMillis: 1510015244746] [levelValue: 800] [[ 
    Glassfish-specific (Non-portable) JNDI names for EJB FooBean: [ejb/FooBean, ejb/FooBean#net.bounceme.dur.ejb.NewSessionBeanRemote]]] 

[2017-11-06T16:40:44.797-0800] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=43 _ThreadName=admin-listener(2)] [timeMillis: 1510015244797] [levelValue: 900] [[ 
    WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]] 

[2017-11-06T16:40:44.800-0800] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=43 _ThreadName=admin-listener(2)] [timeMillis: 1510015244800] [levelValue: 900] [[ 
    WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]] 

[2017-11-06T16:40:44.803-0800] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=43 _ThreadName=admin-listener(2)] [timeMillis: 1510015244803] [levelValue: 900] [[ 
    WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]] 

[2017-11-06T16:40:45.010-0800] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=43 _ThreadName=admin-listener(2)] [timeMillis: 1510015245010] [levelValue: 800] [[ 
    EJBModule1 was successfully deployed in 321 milliseconds.]] 

^C 
[email protected]:~$ 
[email protected]:~$ tail -f GlassFish_Server/glassfish/domains/dur/logs/server.log 

は、ルックアップしないかということですEJB?クライアントコード:

package net.bounceme.dur.ejb.client; 

import java.util.Properties; 
import java.util.logging.Level; 
import java.util.logging.Logger; 
import javax.naming.Context; 
import javax.naming.InitialContext; 
import javax.naming.Name; 
import javax.naming.NamingException; 

public class App { 

    private static final Logger log = Logger.getLogger(App.class.getName()); 

    public void run() throws NamingException { 
     log.fine("looking up jndi"); 
     Context context = null; 
     context = new InitialContext(); 
     context.lookup("java:global/EJBModule1/FooBean"); 
    } 

    public static void main(String[] args) { 
     try { 
      new App().run(); 
     } catch (NamingException ex) { 
      Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); 
     } 
    } 

} 

答えて

0

コードは正常ですが、Beanインタフェースとパラメータ、およびクライアントクラスパスで返されたオブジェクトも必要です。

context.lookup("java:global/EJBModule1/FooBean"); 

は、この行を変更します

NewSessionBeanRemote bean = (NewSessionBeanRemote) context.lookup("java:global/EJBModule1/FooBean"); 

そして、クラスパスの問題を解決します。それが動作します。

関連する問題