创建一个独立的client:
缺少依赖项:
thufir@dur:~/NetBeansProjects/ejbClient$
thufir@dur:~/NetBeansProjects/ejbClient$ gradle runShadow
> Task :runShadow
Nov 06, 2017 11:16:38 AM net.bounceme.dur.ejb.client.App run
INFO: running..
Nov 06, 2017 11:16:38 AM net.bounceme.dur.ejb.client.App run
INFO: {org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, Context.SECURITY_CREDENTIALS=pass123, org.omg.CORBA.ORBInitialHost=localhost, Context.SECURITY_PRINCIPAL=user1, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
Nov 06, 2017 11:16:38 AM net.bounceme.dur.ejb.client.App lookup
INFO: looking up jndi
Nov 06, 2017 11:16:38 AM net.bounceme.dur.ejb.client.App lookup
SEVERE: null
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.InitialContext.<init>(InitialContext.java:192)
at net.bounceme.dur.ejb.client.App.lookup(App.java:30)
at net.bounceme.dur.ejb.client.App.run(App.java:19)
at net.bounceme.dur.ejb.client.App.main(App.java:23)
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:72)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:61)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:672)
... 6 more
BUILD SUCCESSFUL in 1s
6 actionable tasks: 1 executed, 5 up-to-date
thufir@dur:~/NetBeansProjects/ejbClient$
添加错误的(?)依赖项:
thufir@dur:~/NetBeansProjects/ejbClient$
thufir@dur:~/NetBeansProjects/ejbClient$ gradle clean build
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.glassfish.external:asm-all:3.3.
Searched in the following locations:
https://repo1.maven.org/maven2/org/glassfish/external/asm-all/3.3/asm-all-3.3.pom
https://repo1.maven.org/maven2/org/glassfish/external/asm-all/3.3/asm-all-3.3.jar
Required by:
project : > org.glassfish.main.appclient:gf-client:4.1 > org.glassfish.main.appclient:gf-client-module:4.1 > org.glassfish.main.ejb:ejb-full-container:4.1 > org.glassfish.main.ejb:ejb-container:4.1
project : > org.glassfish.main.appclient:gf-client:4.1 > org.glassfish.main.appclient:gf-client-module:4.1 > org.glassfish.main.deployment:dol:4.1 > org.glassfish.main.deployment:deployment-common:4.1
project : > org.glassfish.main.appclient:gf-client:4.1 > org.glassfish.main.appclient:gf-client-module:4.1 > org.glassfish.main.security:webservices.security:4.1 > org.glassfish.main.core:kernel:4.1 > org.glassfish.main.flashlight:flashlight-framework:4.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
2 actionable tasks: 1 executed, 1 up-to-date
thufir@dur:~/NetBeansProjects/ejbClient$
build.gradle文件:
plugins {
id 'com.gradle.build-scan' version '1.8'
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '2.0.1'
}
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
//publishAlways()
}
configurations {
provided
}
shadowJar {
baseName = 'ejbClient'
classifier = null
version = null
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
mainClassName = 'net.bounceme.dur.ejb.client.App'
repositories {
// jcenter()
mavenCentral()
}
configurations {
provided
}
dependencies {
provided 'javax:javaee-api:7.0'
compile group: 'org.glassfish', name: 'javax.json', version: '1.0.4'
// compile group: 'org.glassfish.main.appclient', name: 'gf-client', version: '4.1'
// compile group: 'org.glassfish.hk2.external', name: 'asm-all-repackaged', version: '2.1.88'
}
实例化javax.name.Context
个对象的依赖项是什么?而且,这些依赖性如何在gradle中得到解决?
最后,尝试获取javax.naming
:
thufir@dur:~/NetBeansProjects/ejbClient$
thufir@dur:~/NetBeansProjects/ejbClient$ gradle clean runShadow
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.glassfish:javax.naming:1.0.4.
Searched in the following locations:
https://repo1.maven.org/maven2/org/glassfish/javax.naming/1.0.4/javax.naming-1.0.4.pom
https://repo1.maven.org/maven2/org/glassfish/javax.naming/1.0.4/javax.naming-1.0.4.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
2 actionable tasks: 2 executed
thufir@dur:~/NetBeansProjects/ejbClient$
gradle依赖项:
dependencies {
provided 'javax:javaee-api:7.0'
compile group: 'org.glassfish', name: 'javax.naming', version: '1.0.4'
}
答案 0 :(得分:0)
sorta有点工作:
thufir@dur:~$
thufir@dur:~$ appclient -client NetBeansProjects/ejbClient/build/libs/ejbClient.jar
Nov 06, 2017 12:10:08 PM net.bounceme.dur.ejb.client.App run
INFO: running..
Nov 06, 2017 12:10:08 PM net.bounceme.dur.ejb.client.App run
INFO: {java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
Nov 06, 2017 12:10:08 PM net.bounceme.dur.ejb.client.App lookup
INFO: looking up jndi
thufir@dur:~$
thufir@dur:~$ alias appclient
alias appclient='/home/thufir/GlassFish_Server/glassfish/bin/appclient '
thufir@dur:~$
MEH。