[ 
http://jira.codehaus.org/browse/MJBOSS-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=207207#action_207207
 ] 

Roland Wiesemann edited comment on MJBOSS-42 at 1/17/10 8:22 AM:
-----------------------------------------------------------------

I tried to solve this issue by joining more credentials at the JMX 
Initial-Context with:
{quote}
env.put(Context.SECURITY_CREDENTIALS   , getPassword());
env.put(Context.SECURITY_PRINCIPAL     , getUserName());
{quote}
in the method:
{noformat}
/**
 * Set up the context information for connecting the the jboss server.
 * 
 * @return
 * @throws MojoExecutionException
 */
protected InitialContext getInitialContext() throws MojoExecutionException {
        try {
                Properties env = new Properties();
                env.put(Context.SECURITY_CREDENTIALS   , getPassword());
                env.put(Context.SECURITY_PRINCIPAL     , getUserName());
                env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
                env.put(Context.PROVIDER_URL           , hostName+":"+ 
namingPort); 
                env.put(Context.URL_PKG_PREFIXES       , 
"org.jboss.naming:org.jnp.interfaces");
                return new InitialContext(env);
        } catch (NamingException e) {
                throw new MojoExecutionException(
                                "Unable to instantiate naming context: " + 
e.getMessage(),
                                e);
        }
}
{noformat}
But unfortunately, this had no effects.
An other trial has more success.
I add the statements:
{quote}
SecurityAssociation.setPrincipal(new SimplePrincipal(getUserName()));
SecurityAssociation.setCredential(getPassword());
{quote}
{noformat}
/**
 * Set up the context information for connecting the the jboss server.
 * 
 * @return
 * @throws MojoExecutionException
 */
protected InitialContext getInitialContext() throws MojoExecutionException {
        try {
                SecurityAssociation.setPrincipal(new 
SimplePrincipal(getUserName()));
                SecurityAssociation.setCredential(getPassword());
                
                Properties env = new Properties();
                env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
                env.put(Context.PROVIDER_URL           , hostName+":"+ 
namingPort);
                env.put(Context.URL_PKG_PREFIXES       , 
"org.jboss.naming:org.jnp.interfaces");
                return new InitialContext(env);
        } catch (NamingException e) {
                throw new MojoExecutionException(
                                "Unable to instantiate naming context: " + 
e.getMessage(),
                                e);
        }
}
{noformat}
But now, an additional dependency is necessary in the pom.xml:
{noformat}
<dependency>
  <groupId>org.jboss.security</groupId>
  <artifactId>jbosssx-client</artifactId>
  <version>4.2.2.GA</version>
</dependency>
{noformat}

I don't know, if this is the correct solution for this plugin?
It works for me with jboss application server 4.2.3.GA.


      was (Author: rwiesemann):
    I tried to solve this issue by joining more credentials at the JMX 
Initial-Context with:
{quote}
env.put(Context.SECURITY_CREDENTIALS   , getPassword());
env.put(Context.SECURITY_PRINCIPAL     , getUserName());
{quote}
in the method:
{noformat}
/**
 * Set up the context information for connecting the the jboss server.
 * 
 * @return
 * @throws MojoExecutionException
 */
protected InitialContext getInitialContext() throws MojoExecutionException {
        try {
                Properties env = new Properties();
                env.put(Context.SECURITY_CREDENTIALS   , getPassword());
                env.put(Context.SECURITY_PRINCIPAL     , getUserName());
                env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
                env.put(Context.PROVIDER_URL           , hostName+":"+ 
namingPort); 
                env.put(Context.URL_PKG_PREFIXES       , 
"org.jboss.naming:org.jnp.interfaces");
                return new InitialContext(env);
        } catch (NamingException e) {
                throw new MojoExecutionException(
                                "Unable to instantiate naming context: " + 
e.getMessage(),
                                e);
        }
}
{noformat}
But unfortunately, this had no effects.
An other trial has more success.
I add the statements:
{quote}
SecurityAssociation.setPrincipal(new SimplePrincipal(getUserName()));
SecurityAssociation.setCredential(getPassword());
{quote}
{noformat}
/**
 * Set up the context information for connecting the the jboss server.
 * 
 * @return
 * @throws MojoExecutionException
 */
protected InitialContext getInitialContext() throws MojoExecutionException {
        try {
                SecurityAssociation.setPrincipal(new 
SimplePrincipal(getUserName()));
                SecurityAssociation.setCredential(getPassword());
                
                Properties env = new Properties();
                env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
                env.put(Context.PROVIDER_URL           , hostName+":"+ 
namingPort);
                env.put(Context.URL_PKG_PREFIXES       , 
"org.jboss.naming:org.jnp.interfaces");
                return new InitialContext(env);
        } catch (NamingException e) {
                throw new MojoExecutionException(
                                "Unable to instantiate naming context: " + 
e.getMessage(),
                                e);
        }
}
{noformat}
But no, an additional dependency is necessary in the pom.xml:
{noformat}
<dependency>
  <groupId>org.jboss.security</groupId>
  <artifactId>jbosssx-client</artifactId>
  <version>4.2.2.GA</version>
</dependency>
{noformat}

I don't know, if this is the correct solution for this plugin?
It works for me with jboss application server 4.2.3.GA.

  
> start-and-wait don't work on a secured jmx-console
> --------------------------------------------------
>
>                 Key: MJBOSS-42
>                 URL: http://jira.codehaus.org/browse/MJBOSS-42
>             Project: Maven 2.x JBoss Plugin
>          Issue Type: Bug
>    Affects Versions: 1.4.0, 1.4.1
>         Environment: all
>            Reporter: Roland Wiesemann
>
> If the jboss application server is configured with authentication for the 
> jmx-console, the start-and-wait goal dosn't work.
> The server authentication-information is set in the maven settings.xml file 
> as:
>     <server>
>       <id>default</id>
>       <username>admin</username>
>       <password>nimda</password>
>     </server>
> The execution output is:
> {noformat}
>      [java] [INFO] 
> ------------------------------------------------------------------------
>      [java] [INFO] Building tms-testapp-client
>      [java] [INFO]    task-segment: [jboss:start-and-wait] (aggregator-style)
>      [java] [INFO] 
> ------------------------------------------------------------------------
>      [java] [INFO] [jboss:start-and-wait {execution: default-cli}]
>      [java] [INFO] Starting JBoss...
>      [java] [INFO] Waiting to retrieve JBoss JMX MBean connection... 
>      [java] [INFO] Waiting to retrieve JBoss JMX MBean connection... 
>      [java] [INFO] JBoss JMX MBean connection successful!
>      [java] [INFO] 
> ------------------------------------------------------------------------
>      [java] [ERROR] BUILD ERROR
>      [java] [INFO] 
> ------------------------------------------------------------------------
>      [java] [INFO] Unable to wait: Failed to authenticate principal=null, 
> securityDomain=jmx-console
>      [java] [INFO] 
> ------------------------------------------------------------------------
>      [java] [INFO] Trace
>      [java] org.apache.maven.lifecycle.LifecycleExecutionException: Unable to 
> wait: Failed to authenticate principal=null, securityDomain=jmx-console
>      [java]   at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
>      [java]   at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
>      [java]   at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
>      [java]   at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>      [java]   at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
>      [java]   at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>      [java]   at 
> org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>      [java]   at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>      [java]   at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>      [java]   at 
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>      [java]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>      [java]   at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>      [java]   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>      [java]   at java.lang.reflect.Method.invoke(Method.java:597)
>      [java]   at 
> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>      [java]   at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>      [java]   at 
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>      [java]   at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
>      [java] Caused by: org.apache.maven.plugin.MojoExecutionException: Unable 
> to wait: Failed to authenticate principal=null, securityDomain=jmx-console
>      [java]   at 
> org.codehaus.mojo.jboss.StartAndWaitMojo.execute(StartAndWaitMojo.java:154)
>      [java]   at 
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>      [java]   at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>      [java]   ... 17 more
>      [java] Caused by: java.lang.SecurityException: Failed to authenticate 
> principal=null, securityDomain=jmx-console
>      [java]   at 
> org.jboss.jmx.connector.invoker.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:97)
>      [java]   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
>      [java]   at 
> org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
>      [java]   at 
> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
>      [java]   at 
> org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:179)
>      [java]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>      [java]   at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>      [java]   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>      [java]   at java.lang.reflect.Method.invoke(Method.java:597)
>      [java]   at 
> org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
>      [java]   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
>      [java]   at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
>      [java]   at 
> org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
>      [java]   at 
> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
>      [java]   at 
> org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:818)
>      [java]   at 
> org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:419)
>      [java]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>      [java]   at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>      [java]   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>      [java]   at java.lang.reflect.Method.invoke(Method.java:597)
>      [java]   at 
> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
>      [java]   at sun.rmi.transport.Transport$1.run(Transport.java:159)
>      [java]   at java.security.AccessController.doPrivileged(Native Method)
>      [java]   at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
>      [java]   at 
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
>      [java]   at 
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
>      [java]   at 
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
>      [java]   at 
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>      [java]   at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>      [java]   at java.lang.Thread.run(Thread.java:619)
>      [java]   at 
> sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
>      [java]   at 
> sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
>      [java]   at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
>      [java]   at 
> org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
>      [java]   at 
> org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:133)
>      [java]   at 
> org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
>      [java]   at 
> org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
>      [java]   at 
> org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor.invoke(InvokerAdaptorClientInterceptor.java:66)
>      [java]   at 
> org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
>      [java]   at 
> org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
>      [java]   at 
> org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
>      [java]   at $Proxy0.getAttribute(Unknown Source)
>      [java]   at 
> org.codehaus.mojo.jboss.StartAndWaitMojo.isStarted(StartAndWaitMojo.java:174)
>      [java]   at 
> org.codehaus.mojo.jboss.StartAndWaitMojo.execute(StartAndWaitMojo.java:152)
>      [java]   ... 19 more
>      [java] [INFO] 
> ------------------------------------------------------------------------
>      [java] [INFO] Total time: 19 seconds
>      [java] [INFO] Finished at: Fri Jan 15 15:12:57 CET 2010
>      [java] [INFO] Final Memory: 4M/10M
>      [java] [INFO] 
> ------------------------------------------------------------------------
> {noformat}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to