Can't connect to jboss server - Operation failed with status WAITING - java

Got this exception while trying to connect to local jboss server (wildfly-8.2.0.Final)
javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Operation failed with status WAITING]
at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at com.sample.CalculatorIntegrationTestCase.obtainProxyReferences(CalculatorIntegrationTestCase.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
Caused by: java.lang.RuntimeException: Operation failed with status WAITING
at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:89)
at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
... 18 more
JNDI properties are following:
#BeforeClass
public static void obtainProxyReferences() throws Throwable {
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "remote://localhost:4447");
properties.put("jboss.naming.client.ejb.context", true);
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
properties.put(Context.SECURITY_PRINCIPAL, "testuser");
properties.put(Context.SECURITY_CREDENTIALS, "!Test1");
namingContext = new InitialContext(properties);
bean = (MeBeanImpl) namingContext.lookup(JNDI_NAME);
}
Telnet also says that it can't connect to server with the port 4447. I opened this port in the firewall but it didn't help.

By default WildFly uses 8080 as the remoting port. The EJB client API uses the http port, with the http-upgrade functionality, for communicating with the server for remote invocation.
Eg:
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL,"http-remoting://localhost:8080");
jndiProps.put("jboss.naming.client.ejb.context", true);
jndiProps.put(Context.SECURITY_PRINCIPAL, "testuser");
jndiProps.put(Context.SECURITY_CREDENTIALS, "!Test1");
// create a context passing these properties
Context ctx = new InitialContext(jndiProps);
// lookup
ctx.lookup(JNDI_NAME);
See: Remote EJB invocations via JNDI - EJB client API or remote-naming project

instead of using "remote://localhost:4447" use "http-remoting://localhost:8080"
properties.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
When you configure jndi properties in code, lookup name should not contain ejb:
JNDI_NAME = "ear-name/ejb-name/beanClass!beanInterface.fullpath");

If you're using maven, don't forget to add this dependency:
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>8.0.0.Final</version>
<type>pom</type>
</dependency>
For JMS, you'll need these as well:
<dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-jms-client</artifactId>
<version>2.2.13.Final</version>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-core-client</artifactId>
<version>2.2.13.Final</version>
</dependency>
This should be the only dependency you need.

Related

org.apache.hadoop.security.AccessControlException: Client cannot authenticate via:[TOKEN, KERBEROS] Issue

I'm using the java client to Access HDFS secure with Kerberos authentication.
I Tried typing klist on sever, it shows an already existing valid ticket.
The exception I received was Client cannot authenticate via:[TOKEN, KERBEROS] .
Help would be greatly appreciated.
This is an error log.
Java 8, cdh 5.12.1, Hadoop 2.6
Exception in thread "main" java.io.IOException: Failed on local exception: java.io.IOException: org.apache.hadoop.security.AccessControlException: Client cannot authenticate via:[TOKEN, KERBEROS]; Host Details : local host is:
at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:772)
at org.apache.hadoop.ipc.Client.call(Client.java:1508)
at org.apache.hadoop.ipc.Client.call(Client.java:1441)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:230)
at com.sun.proxy.$Proxy10.getListing(Unknown Source)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getListing(ClientNamenodeProtocolTranslatorPB.java:588)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:258)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:104)
at com.sun.proxy.$Proxy11.getListing(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient.listPaths(DFSClient.java:2145)
at org.apache.hadoop.hdfs.DFSClient.listPaths(DFSClient.java:2128)
at org.apache.hadoop.hdfs.DistributedFileSystem.listStatusInternal(DistributedFileSystem.java:743)
at org.apache.hadoop.hdfs.DistributedFileSystem.access$600(DistributedFileSystem.java:113)
at org.apache.hadoop.hdfs.DistributedFileSystem$16.doCall(DistributedFileSystem.java:808)
at org.apache.hadoop.hdfs.DistributedFileSystem$16.doCall(DistributedFileSystem.java:804)
at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
at org.apache.hadoop.hdfs.DistributedFileSystem.listStatus(DistributedFileSystem.java:804)
at hive.Hadoop_TEST.delete(Hadoop_TEST.java:54)
at hive.NableHive.main(NableHive.java:47)
Caused by: java.io.IOException: org.apache.hadoop.security.AccessControlException: Client cannot authenticate via:[TOKEN, KERBEROS]
at org.apache.hadoop.ipc.Client$Connection$1.run(Client.java:718)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1920)
at org.apache.hadoop.ipc.Client$Connection.handleSaslConnectionFailure(Client.java:681)
at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:769)
at org.apache.hadoop.ipc.Client$Connection.access$3000(Client.java:396)
at org.apache.hadoop.ipc.Client.getConnection(Client.java:1557)
at org.apache.hadoop.ipc.Client.call(Client.java:1480)
... 21 more
Caused by: org.apache.hadoop.security.AccessControlException: Client cannot authenticate via:[TOKEN, KERBEROS]
at org.apache.hadoop.security.SaslRpcClient.selectSaslClient(SaslRpcClient.java:172)
at org.apache.hadoop.security.SaslRpcClient.saslConnect(SaslRpcClient.java:396)
at org.apache.hadoop.ipc.Client$Connection.setupSaslConnection(Client.java:594)
at org.apache.hadoop.ipc.Client$Connection.access$2000(Client.java:396)
at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:761)
at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:757)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1920)
at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:756)
... 24 more
This is the java code
final String CONF_CORE_SITE = "/etc/hadoop/conf/core-site.xml";
final String CONF_HDFS_SITE = "/etc/hadoop/conf/hdfs-site.xml";
Configuration configuration = new Configuration();
configuration.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
configuration.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
configuration.set("hadoop.rpc.protection", "privacy");
File hadoopCoreConfig = new File(CONF_CORE_SITE);
File hadoopHdfsConfig = new File(CONF_HDFS_SITE);
if (! hadoopCoreConfig.exists() || ! hadoopHdfsConfig.exists()) {
throw new FileNotFoundException("Files core-site.xml or hdfs-site.xml are not found. Check /etc/hadoop/conf/ path.");
}
configuration.addResource(new Path(hadoopCoreConfig.toURI()));
configuration.addResource(new Path(hadoopHdfsConfig.toURI()));
//Use existing security context created by $ kinit
UserGroupInformation.setConfiguration(configuration);
UserGroupInformation.loginUserFromKeytab("dwh_udp#abc.com", "/home/dwh_udp/dwh_udp.keytab");
UserGroupInformation.loginUserFromSubject(null);
URI uri = URI.create("hdfs://****");
FileSystem fs = FileSystem.get(uri,configuration,"User");
FileStatus[] fsStatus = fs.listStatus(new Path("/"));
for(int i = 0; i <= fsStatus.length; i++){
System.out.println(fsStatus[i].getPath().toString());
}
Maven dependency
<properties>
<hadoop.version>2.6.0</hadoop.version>
<hadoop.release>cdh5.12.1</hadoop.release>
</properties>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>${hadoop.version}-mr1-${hadoop.release}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>${hadoop.version}-${hadoop.release}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}-${hadoop.release}</version>
</dependency>
</dependencies>

NoInitialContextFound Exception while running testcases using junit/spring-test to test a spring WS webservice

I have a Soap Web Service developed using Spring WS. I want to create Junit test cases that test the service before it moves to other environments ( from dev to sit to uat to prod).
I am trying to use Spring test's MockWebServiceClient like this
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(locations = { "classpath:WEB-INF/spring-ws-servlet.xml" })
public class AccountSearchEndpointTests {
#Autowired
private ApplicationContext applicationContext;
private MockWebServiceClient mockClient;
#Before
public void createClient() {
mockClient = MockWebServiceClient.createClient(applicationContext);
}
#Test
public void testWsEndPointTest() throws Exception {
StringSource requestPayload = new StringSource(
""); //omitted actual request
StringSource responsePayload = new StringSource(""); //omitted actual response
mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(responsePayload));
}
However the error i get is
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bean' defined in class path resource [WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
... 24 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at com.bean.initialize(bean.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 37 more
This is the bean in spring-ws-servlet
<bean id="bean" init-method="initialize" destroy-method="terminate"
class="com.bean" />
and in the initialize of bean this happens
ctx = new InitialContext();
ds = (DataSource) ctx.lookup(DS_NAME);
I understand that the webservice should be running in a container like tomcat, but then i want to know how can i mock it/ configure something in spring test for it. Essentially i want to know how can i go about testing the webservice using junit!
This is essentially a duplicate of https://stackoverflow.com/a/5947016/388980.
So check out the solutions discussed there.
In summary, you should not be performing JDNI look-ups directly within your code. Instead, you should externalize the JDNI lookup in your Spring configuration and then only have Spring inject the DataSource into your components.
You can then use an embedded database (e.g., H2, HSQL, Derby -- Spring supports all three of those) while testing and inject the DataSource for the embedded database into your components.
As an alternative, you could move the data access code to a dedicated Repository or DAO implementation and inject a mock for that into your Web Service endpoints -- for example, using Mockito.
If you're not familiar with bean definition profiles in Spring, you should read the corresponding sections of the Spring Reference Manual. The Testing chapter demonstrates how to use profiles prod for production and dev in your tests.

Jboss EAP 7.0.0 - java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory

I am migrating a service from Jboss 5.1 to Jboss EAP 7.0.0.
It is successfully build in jdk 1.8 using maven 3.9.9 and successfully deployed in jboss EAP 7.0.0.
During deployment it is showing java.lang.ClassNotFoundException. This service contains only local ejb no remote ejbs.
EJb lookup class -
String contextFactory = SysConfigUtil.getJndiFactory();
String ejbLocalJndi = SysConfigUtil.getTimerEjbLocalJndi();
Properties environment = new Properties();
environment.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
Context ctx;
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
environment.put("jboss.naming.client.ejb.context", new Boolean(true));
ctx = new InitialContext(environment);
logger.info("************ before lookup");
ejb = (ISystemConfigurationTimerLocal) ctx.lookup(ejbLocalJndi);
logger.info("************ after lookup");
Stack Trace -
javax.naming.NamingException: WFLYNAM0027: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader f
or Module "deployment.SystemConfiguration.ear.system-configuration-lifecycle.sar:main" from Service Module Loader [Root exception is java.lang.ClassNotFoundException: org.jb
oss.naming.remote.client.InitialContextFactory from [Module "deployment.SystemConfiguration.ear.system-configuration-lifecycle.sar:main" from Service Module Loader]]
org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:118)
org.jboss.as.naming.InitialContext.init(InitialContext.java:99)
javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
org.jboss.as.naming.InitialContext.<init>(InitialContext.java:89)
org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:43)
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
javax.naming.InitialContext.init(InitialContext.java:244)
javax.naming.InitialContext.<init>(InitialContext.java:216)
com.abcd.services.core.systemconfiguration.conn.impl.SystemConfigurationTimerEjbExecutor.getSystemConfigurationTimerEJB(SystemConfigurationTimerEjbExecutor.java:96)
com.abcd.services.core.systemconfiguration.conn.impl.SystemConfigurationTimerEjbExecutor.startScheduler(SystemConfigurationTimerEjbExecutor.java:56)
com.abcd.services.core.systemconfiguration.conn.impl.SystemConfigurationAppLifeCycle.start(SystemConfigurationAppLifeCycle.java:65)
org.jboss.as.service.AbstractService.invokeLifecycleMethod(AbstractService.java:76)
org.jboss.as.service.StartStopService$1.run(StartStopService.java:61)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory from [Module "deployment.SystemConfiguration.ear.system-configuration-lifec
ycle.sar:main" from Service Module Loader]
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:348)
org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:113)
You have never needed to provide environment properties to new InitialContext() when looking up local objects in any version of JBossAS or WildFly.
Context ctx = new InitialContext();
ejb = (ISystemConfigurationTimerLocal) ctx.lookup(ejbLocalJndi);
should be all that you need.
FWIW, the property configuration that you provided is for remote standalone clients, and is incorrect even for server -> server calls.

Eclipse: "Failed to connect to any server" when trying to create Factory over Wildfly

I've added a connection factory at the standalone-full file of Wildfly:
<jms-connection-factories>
<connection-factory name="K19Factory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="K19Factory"/>
<entry name="java:jboss/exported/jms/K19Factory"/>
</entries>
</connection-factory>
...
</jms-connection-factories>
And so a code on Eclipse to use it. But I'm having problems at the moment of the creation of the factory:
ConnectionFactory factory = (ConnectionFactory)ic.lookup("jms/K19Factory");
When trying to run this line, I'm getting the following error:
Exception in thread "main" javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:87)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:129)
at javax.naming.InitialContext.lookup(Unknown Source)
at br.com.k19.emissores.EnviaNovoPedidoJBoss.main(EnviaNovoPedidoJBoss.java:30)
What is the problem?
Properties prop=new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
prop.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
prop.put("jboss.naming.client.ejb.context", true);
Context ctx = new InitialContext(prop);
Faced the exact error log when trying to connect JBoss from my code. Issue was fixed once I removed all other jars in build path with jboss-client.jar.

Error when trying to access my application in JBoss AS 7.1

I recently migrated my application from JBoss AS 4.2.1 to JBoss AS 7.1, but I am not being able to access the application vua http request since I am getting the below error:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Unable to instantiate Action, payment.PaymentBean, defined for 'prepayment' in namespace '/payment'javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.TPGWeb.war:main" from Service Module Loader - action - vfs:/content/TPGWeb.war/WEB-INF/classes/struts.xml:26:64
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
root cause
Unable to instantiate Action, payment.PaymentBean, defined for 'prepayment' in namespace '/payment'javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.TPGWeb.war:main" from Service Module Loader - action - vfs:/content/TPGWeb.war/WEB-INF/classes/struts.xml:26:64
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:289)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:360)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:78)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:70)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:66)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:497)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
root cause
java.lang.RuntimeException: javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.TPGWeb.war:main" from Service Module Loader
utils.ResourceCenter.lookupGatewaySecurityBean(ResourceCenter.java:76)
payment.PaymentBean.<init>(PaymentBean.java:39)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:532)
java.lang.Class.newInstance0(Class.java:372)
java.lang.Class.newInstance(Class.java:325)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:121)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:152)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:141)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:111)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:270)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:360)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:78)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:70)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:66)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:497)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
root cause
javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.TPGWeb.war:main" from Service Module Loader
org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681)
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
javax.naming.InitialContext.init(InitialContext.java:240)
javax.naming.InitialContext.<init>(InitialContext.java:192)
utils.ResourceCenter.lookupGatewaySecurityBean(ResourceCenter.java:66)
payment.PaymentBean.<init>(PaymentBean.java:39)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:532)
java.lang.Class.newInstance0(Class.java:372)
java.lang.Class.newInstance(Class.java:325)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:121)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:152)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:141)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:111)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:270)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:360)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:78)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:70)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:66)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:497)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
note The full stack trace of the root cause is available in the JBoss Web/7.0.13.Final logs.
JBoss Web/7.0.13.Final
Add "Dependencies: org.jboss.remote-naming" to META-INF/manifest.mf of your .WAR file. This will load org.jboss.remote-naming module and eliminate "Failed instantiate InitialContextFactory" exception. Details here: https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7
use jboss-ejb-client.properties file and place it to WEB-INF folder vs content like this:
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=your host
remote.connection.default.port=your port
remote.connection.default.username=you user
remote.connection.default.password=you password
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
and lookup this way:
Properties jndiProps = new Properties();
jndiProps.puy(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL, JBOSS_USER);
jndiProps.put(Context.SECURITY_CREDENTIALS, JBOSS_PWD);
jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProps.put(Context.PROVIDER_URL, "remote://yourhost:yourport");
InitialContext initialContext = new InitialContext(jndiProps);
YourRemote remote=(YourRemote)initialContext.lookup("java:/app-name/ejb-jar-name/YourBean!package.YourRemote");
For details see:
https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
Good luck!
From post above... "Add "Dependencies: org.jboss.remote-naming" to META-INF/manifest.mf of your .WAR file."
Thanks so much for the above help. It got me a step closer to migrating to JBoss EAP 6.
An alternative to above, if you have a War file that has to be deployed on non-JBoss servers, is to add the following to the jboss-deployment-structure.xml file.
That has the benefit of separating out the JBoss specific elements to their own JBoss specific files.
<sub-deployment name="yourWebApp.war">
<dependencies>
<module name="org.jboss.remote-naming" />
</dependencies>
</sub-deployment>
regards,
Owen

Categories