我遇到了Jboss-as-7.1.1的问题。当我部署它时,它正确部署,但是当我从客户端发送请求时,我收到此错误:
javax.naming.NamingException:JBAS011843:实例化InitialContextFactory失败
MyErrorlog: -
14:18:22,952 INFO [stdout] (http--127.0.0.1-8080-1) BusinessClass::sendResponse Starts...
14:18:22,953 INFO [stdout] (http--127.0.0.1-8080-1) Enter the Try Block Edited by vivek
14:18:22,962 ERROR [stderr] (http--127.0.0.1-8080-1) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.responsecomponent.ear.response.war:main" from Service Module Loader
14:18:22,978 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)
14:18:22,996 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:664)
14:18:22,998 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
14:18:23,007 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.naming.InitialContext.init(InitialContext.java:223)
14:18:23,008 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.naming.InitialContext.<init>(InitialContext.java:197)
14:18:23,010 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.jsp.response_jsp._jspService(response_jsp.java:132)
14:18:23,011 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
14:18:23,012 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
14:18:23,014 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
14:18:23,037 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
14:18:23,038 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
14:18:23,040 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
14:18:23,041 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
14:18:23,049 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
14:18:23,051 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
14:18:23,053 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
14:18:23,054 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
14:18:23,064 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
14:18:23,065 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
14:18:23,066 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
14:18:23,068 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
14:18:23,069 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
14:18:23,076 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
14:18:23,078 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
14:18:23,081 ERROR [stderr] (http--127.0.0.1-8080-1) at java.lang.Thread.run(Thread.java:662)
ServerLog中: -
JBoss Bootstrap Environment
JBOSS_HOME: /home/vivekray/Desktop/vivek/jboss-as-7.1.1.Final
JAVA: /home/vivekray/Softwares/jdk1.6.0_30/bin/java
JAVA_OPTS: -server -XX:+TieredCompilation -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml
=========================================================================
14:14:09,212 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA
14:14:09,978 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
14:14:10,233 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
14:14:13,122 INFO [org.xnio] XNIO Version 3.0.3.GA
14:14:13,148 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
14:14:13,224 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
14:14:13,264 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
14:14:13,553 INFO [org.jboss.as.clustering.infinispan] JBAS010280: Activating Infinispan subsystem.
14:14:13,557 INFO [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin Subsystem
14:14:13,619 INFO [org.jboss.as.naming] JBAS011800: Activating Naming Subsystem
14:14:13,660 INFO [org.jboss.as.osgi] JBAS011940: Activating OSGi Subsystem
14:14:13,707 INFO [org.jboss.as.security] JBAS013101: Activating Security Subsystem
14:14:13,765 INFO [org.jboss.as.webservices] JBAS015537: Activating WebServices Extension
14:14:13,809 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
14:14:14,204 INFO [org.jboss.as.mail.extension] (MSC service thread 1-4) JBAS015400: Bound mail session [java:jboss/mail/Default]
14:14:14,260 INFO [org.jboss.as.connector] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
14:14:14,514 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
14:14:14,773 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.2.GA
14:14:15,739 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-4) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
14:14:16,378 WARN [com.arjuna.ats.arjuna] (Transaction Expired Entry Monitor) ARJUNA012210: Unable to use InetAddress.getLocalHost() to resolve address.
14:14:16,636 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /127.0.0.1:9999
14:14:16,639 INFO [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on /127.0.0.1:4447
14:14:16,717 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory /home/vivekray/Desktop/vivek/jboss-as-7.1.1.Final/standalone/deployments
14:14:17,095 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
14:14:17,201 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "responsecomponent.ear"
14:14:24,491 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jaxb-api.jar in "/content/responsecomponent.ear/lib/jaxb-xjc-2.1.7.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,502 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jaxb-impl.jar in "/content/responsecomponent.ear/lib/jaxb-xjc-2.1.7.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,515 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jsr173_1.0_api.jar in "/content/responsecomponent.ear/lib/jaxb-xjc-2.1.7.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,524 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry activation.jar in "/content/responsecomponent.ear/lib/jaxb-xjc-2.1.7.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,539 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jaxb-api.jar in "/content/responsecomponent.ear/lib/jaxb-impl-2.1.7.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,548 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry activation.jar in "/content/responsecomponent.ear/lib/jaxb-impl-2.1.7.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,564 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jsr173_1.0_api.jar in "/content/responsecomponent.ear/lib/jaxb-impl-2.1.7.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,567 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jaxb1-impl.jar in "/content/responsecomponent.ear/lib/jaxb-impl-2.1.7.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,575 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry bcel.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,580 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jibx-run.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,583 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry xpp3.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,585 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry stax-api.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,589 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry wstx-asl.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,594 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry xercesImpl.jar in "/content/responsecomponent.ear/lib/xalan-2.7.0.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,596 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry xml-apis.jar in "/content/responsecomponent.ear/lib/xalan-2.7.0.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,599 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry serializer.jar in "/content/responsecomponent.ear/lib/xalan-2.7.0.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,602 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry activation.jar in "/content/responsecomponent.ear/lib/mail-1.4.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,613 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry xpp3.jar in "/content/responsecomponent.ear/lib/jibx-run-1.2.1.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,615 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry stax-api.jar in "/content/responsecomponent.ear/lib/jibx-run-1.2.1.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,617 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry wstx-asl.jar in "/content/responsecomponent.ear/lib/jibx-run-1.2.1.jar" does not point to a valid jar for a Class-Path reference.
14:14:24,630 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "response.war"
14:14:24,633 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "AsyncResponseComponentVer2.jar"
14:14:25,750 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named SPConnectorResponseComponent in deployment unit subdeployment "AsyncResponseComponentVer2.jar" of deployment "responsecomponent.ear" are as follows:
java:global/responsecomponent/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBRemote
java:app/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBRemote
java:module/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBRemote
java:jboss/exported/responsecomponent/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBRemote
java:global/responsecomponent/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBHome
java:app/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBHome
java:module/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBHome
java:jboss/exported/responsecomponent/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBHome
14:14:26,794 INFO [org.jboss.web] (MSC service thread 1-2) JBAS018210: Registering web context: /response
14:14:26,797 INFO [org.jboss.as] (MSC service thread 1-3) JBAS015951: Admin console listening on http://127.0.0.1:9990
14:14:26,807 INFO [org.jboss.as] (MSC service thread 1-3) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 18387ms - Started 222 of 303 services (80 services are passive or on-demand)
14:14:26,958 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "responsecomponent.ear"
MyCode: -
Context context=null;
System.out.println("BusinessClass::sendResponse Starts...");
HashMap ack_gateway=null;
try {
System.out.println("Enter the Try Block Edited by vivek");
//add by vivek
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put(Context.PROVIDER_URL, "remote://localhost:4447");
props.put(Context.SECURITY_PRINCIPAL, "testuser");
props.put(Context.SECURITY_CREDENTIALS, "testpassword");
context = new InitialContext(props);
System.out.println("\n\tGot initial Context: "+context);
System.out.println("Got Initial Context");
SPResponseEJBHome home = (SPResponseEJBHome) ortableRemoteObject.narrow(context.lookup ("SPConnectorResponseComponent"),SPResponseEJBHome.class);
System.out.println("BusinessClass::sendResponse Starts...");
System.out.println("Got Home object");
SPResponseEJBRemote remote = home.create();
System.out.println("Got Remote object");
任何人都有一些想法请帮帮我? 谢谢 的Vivek
答案 0 :(得分:2)
我花了一天时间学习JBoss 6的教程和电子书(以及论坛解决方案)。主要的“问题”是JBoss 7对JNDI设置和InitialContext有不同的方法。
最后,我找到了一个节省了我一天的教程,希望这对你也有帮助:
我如何解决
道具必须只有这个条目:
props.put(Context.URL_PKG_PREFIXES,“org.jboss.ejb.client.naming”);
使用此内容在客户端文件夹中缺少 jboss-ejb-client.properties :
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
构建路径中缺少 jboss-client-7.1.0.Final.jar (JBOSS_HOME / bin / client)。
祝你好运, 丹尼尔。
答案 1 :(得分:1)
首先,从服务器日志中我看到一些与类路径相关的警告,所以在我看来,以后会跳出一些错误。 也许你已经解决了这个问题,但是从客户端报告的错误几乎总是与用于编译该客户端的类路径有关, 例如,用以下代码编译它:
javac -cp <JBOSS_FOLDER>/bin/client/jboss_client.jar <your src directory>
问候
答案 2 :(得分:0)
您可以使用其他方式查找您的bean。
BeanRemoteInterface bean = doLookup();
doLockup() - 方法:
private static BeanRemoteInterface doLookup() {
Context context = null;
BeanRemoteInterface bean = null;
try {
// 1. Obtaining Context
context = ClientUtility.getInitialContext();
// 2. Generate JNDI Lookup name
String lookupName = getLookupName();
// 3. Lookup and cast
System.out.println("LookUpName: " + lookupName);
bean = (BeanRemoteInterface) context.lookup(lookupName);
} catch (NamingException e) {
e.printStackTrace();
}
return bean;
}
getLookupName() - 方法:
private static String getLookupName() {
/*
* The app name is the EAR name of the deployed EJB without .ear suffix.
* Since we haven't deployed the application as a .ear, the app name for
* us will be an empty string
*/
String appName = "";
/*
* The module name is the JAR name of the deployed EJB without the .jar
* suffix.
*/
String moduleName = "PackageName";
/*
* AS7 allows each deployment to have an (optional) distinct name. This
* can be an empty string if distinct name is not specified.
*/
String distinctName = "";
// The EJB bean implementation class name
// String beanName = HelloWorldImpl.class.getSimpleName();
String beanName = "NameOfYourBeanImplementation";
// Fully qualified remote interface name
final String interfaceName = BeanRemoteInterdface.class.getName();
// Create a look up string name
String name = "ejb:" + appName + "/" + moduleName + "/" + distinctName
+ "/" + beanName + "!" + interfaceName;
return name;
}
ClientUtility类
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ClientUtility {
private static final String PROVIDER_URL = "jnp://localhost:1099";
private static final String JNP_INTERFACES = "org.jboss.naming:org.jnp.interfaces";
private static final String INITIAL_CONTEXT_FACTORY="org.jnp.interfaces.NamingContextFactory";
private static Context initialContext;
public static Context getInitialContext() throws NamingException
{
if (initialContext == null) {
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
prop.put(Context.URL_PKG_PREFIXES, JNP_INTERFACES);
prop.put(Context.PROVIDER_URL, PROVIDER_URL);
initialContext = new InitialContext(prop);
}
return initialContext;
}
}