Showing posts with label JBoss. Show all posts
Showing posts with label JBoss. Show all posts

How to configure JAAS for JBoss

  1. In jboss.xml, add <security-domain>java:/jaas/jboss-secure</security-domain>
  2. In JBoss install directorty, C:\jboss-4.2.1.GA\server\default\conf, add users.properties and roles.properties
  3. In users.properties, add user=pass
  4. In roles.properties, add user=role
  5. Deploy ejb, restart jboss
  6. In your ejb client, your initialContext should look like this
  7. properties.put(Context.INITIAL_CONTEXT_FACTORY , "org.jboss.security.jndi.JndiLoginInitialContextFactory");
    properties.put("java.naming.provider.url", "jnp://localhost:1099");
    properties.put(Context.SECURITY_PRINCIPAL, "user");
    properties.put(Context.SECURITY_CREDENTIALS, "pass");

    Context ic = new InitialContext(properties);
Or alternatively,
Application Server side:
NO CHANGES
EJB side:
  1. In jboss.xml add domain
  2. Add users.properties, roles.properties to ejb jar above META-INF
This is probably the simplest tutorial on JAAS (that actually works!)

Exception in thread "main" javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.ejb3.JBossProxy (no secu

Exception in thread "main" javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.ejb3.JBossProxy (no security manager: RMI class loader disabled)]

Cause:
Client library missing

Solution:
Add jbossall-client.jar to classpath

NoInitialContextException when calling an EJB from a java client

Exception in thread "main" 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:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at helloworldclient.Main.main(Main.java:34)

Cause
:
The initial context is not set.

Solution:
Set the initial context via jndi.properties or programatically:
properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.provider.url","jnp://localhost:1099");
Context ic = new InitialContext(properties );

No ClassLoaders found exception when trying to start JBoss

org.jboss.deployment.DeploymentException: No ClassLoaders found for: org.jboss.management.j2ee.LocalJBossServerDomain
Cause:
You get this error when after extracting JBoss, you try to start it

Solution:
This happens if you try to extract JBoss archive using windows archiver. It doesn't properly extract the library files. Use a different archiver and ditch Windows.

JBoss Application Server Start Failed. HTTP Connector port 8080 is already in use

JBoss Application Server Start Failed. HTTP Connector port 8080 is already in use
Cause:
When you try to start JBoss Application Server. In my case, within NetBeans. As the error indicates, this happens when the port JBoss tries to listen on is in use.

Solution:
Change the default port to a different port. In this case, 7070
  1. Change port number to an unused port
  2. Edit C:\jboss-4.0.5.GA\server\default\deploy\jbossweb-tomcat55.sar\server.xml
  3. Change connector port 8080 to 7070

How to set the initial context in Axis?

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:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at axiscds.test.Test.testMain(Test.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:421)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:912)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:766)
Cause:
Axis cannot find the context

Solution:
Set initial context.

Example:
Properties props = new Properties();
props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.provider.url", "127.0.0.1:1099");
Context ctx = new InitialContext(props);