cancel
Showing results for 
Search instead for 
Did you mean: 

AuthenticationUtils.startSession expception

chicco0386
Champ on-the-rise
Champ on-the-rise
Hi all,
I've this piece of code that authentica the user admin via WS:

try {

            boolean isLogged = RepositoryUtils.isLoggedIn();

            if (!isLogged) {
                if (log.isDebugEnabled()) {
                    log.debug("process, procedo con l'autenticazione");
                }
                AuthenticationUtils.startSession("admin", "admin");
            }

            …Execute some operation…

        } finally {
            // End session
            AuthenticationUtils.endSession();
        }

When I call this code for the first time alla works perfectly, but when I execute it for the second and other time I've this exception:
2010-09-15 10:27:28,326 DEBUG [it.mytria.soa.esb.alfresco.action.InsertContentAction] process, procedo con l'autenticazione
2010-09-15 10:27:28,326 INFO  [STDOUT] [WARN ] DiscoverResources - -getNextResources: Ignoring Exception <java.io.IOException: Invalid use of destroyed classloader, UCL destroyed at:>
2010-09-15 10:27:28,326 ERROR [STDERR] java.io.IOException: Invalid use of destroyed classloader, UCL destroyed at:
2010-09-15 10:27:28,326 ERROR [STDERR]     at org.jboss.mx.loading.RepositoryClassLoader.findResources(RepositoryClassLoader.java:588)
2010-09-15 10:27:28,326 ERROR [STDERR]     at java.lang.ClassLoader.getResources(ClassLoader.java:1016)
2010-09-15 10:27:28,342 ERROR [STDERR]     at org.apache.commons.discovery.jdk.JDK12Hooks.getResources(JDK12Hooks.java:150)
2010-09-15 10:27:28,342 ERROR [STDERR]     at org.apache.commons.discovery.resource.DiscoverResources$1.getNextResources(DiscoverResources.java:153)
2010-09-15 10:27:28,342 ERROR [STDERR]     at org.apache.commons.discovery.resource.DiscoverResources$1.getNextResource(DiscoverResources.java:129)
2010-09-15 10:27:28,342 ERROR [STDERR]     at org.apache.commons.discovery.resource.DiscoverResources$1.hasNext(DiscoverResources.java:116)
2010-09-15 10:27:28,342 ERROR [STDERR]     at org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.getNextClassNames(DiscoverNamesInFile.java:186)
2010-09-15 10:27:28,342 ERROR [STDERR]     at org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.getNextClassName(DiscoverNamesInFile.java:170)
2010-09-15 10:27:28,342 ERROR [STDERR]     at org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.hasNext(DiscoverNamesInFile.java:157)
2010-09-15 10:27:28,342 ERROR [STDERR]     at org.apache.commons.discovery.resource.names.NameDiscoverers$1.getNextIterator(NameDiscoverers.java:143)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.apache.commons.discovery.resource.names.NameDiscoverers$1.hasNext(NameDiscoverers.java:126)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.apache.commons.discovery.resource.classes.ResourceClassDiscoverImpl$1.getNextResource(ResourceClassDiscoverImpl.java:159)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.apache.commons.discovery.resource.classes.ResourceClassDiscoverImpl$1.hasNext(ResourceClassDiscoverImpl.java:147)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(EngineConfigurationFactoryFinder.java:120)
2010-09-15 10:27:28,373 ERROR [STDERR]     at java.security.AccessController.doPrivileged(Native Method)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:113)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:160)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.apache.axis.client.Service.getEngineConfiguration(Service.java:813)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.apache.axis.client.Service.getAxisClient(Service.java:104)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.apache.axis.client.Service.<init>(Service.java:113)
2010-09-15 10:27:28,373 ERROR [STDERR]     at org.alfresco.webservice.authentication.AuthenticationServiceLocator.<init>(AuthenticationServiceLocator.java:16)
2010-09-15 10:27:28,388 ERROR [STDERR]     at org.alfresco.webservice.util.WebServiceFactory.getAuthenticationService(WebServiceFactory.java:153)
2010-09-15 10:27:28,388 ERROR [STDERR]     at org.alfresco.webservice.util.AuthenticationUtils.startSession(AuthenticationUtils.java:73)
2010-09-15 10:27:28,388 ERROR [STDERR]     at it.mytria.soa.esb.alfresco.action.InsertContentAction.process(InsertContentAction.java:47)
2010-09-15 10:27:28,388 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2010-09-15 10:27:28,388 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2010-09-15 10:27:28,388 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2010-09-15 10:27:28,388 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:597)
2010-09-15 10:27:28,388 ERROR [STDERR]     at org.jboss.soa.esb.listeners.message.ActionProcessorMethodInfo.processMethods(ActionProcessorMethodInfo.java:102)
2010-09-15 10:27:28,388 ERROR [STDERR]     at org.jboss.soa.esb.listeners.message.OverriddenActionLifecycleProcessor.process(OverriddenActionLifecycleProcessor.java:74)
2010-09-15 10:27:28,388 ERROR [STDERR]     at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:520)
2010-09-15 10:27:28,388 ERROR [STDERR]     at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:392)
2010-09-15 10:27:28,388 ERROR [STDERR]     at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:538)
2010-09-15 10:27:28,388 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
2010-09-15 10:27:28,388 ERROR [STDERR]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
2010-09-15 10:27:28,404 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:619)
2010-09-15 10:27:28,404 ERROR [STDERR] Caused by: java.lang.Exception
2010-09-15 10:27:28,404 ERROR [STDERR]     at org.jboss.mx.loading.RepositoryClassLoader.unregister(RepositoryClassLoader.java:265)
2010-09-15 10:27:28,404 ERROR [STDERR]     at org.jboss.mx.loading.UnifiedClassLoader.unregister(UnifiedClassLoader.java:196)
2010-09-15 10:27:28,404 ERROR [STDERR]     at org.jboss.deployment.DeploymentInfo.cleanup(DeploymentInfo.java:402)
2010-09-15 10:27:28,404 ERROR [STDERR]     at org.jboss.deployment.MainDeployer.destroy(MainDeployer.java:731)
2010-09-15 10:27:28,404 ERROR [STDERR]     at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:639)
2010-09-15 10:27:28,404 ERROR [STDERR]     at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:632)
2010-09-15 10:27:28,404 ERROR [STDERR]     at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:615)
2010-09-15 10:27:28,404 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2010-09-15 10:27:28,404 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2010-09-15 10:27:28,420 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2010-09-15 10:27:28,420 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:597)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
2010-09-15 10:27:28,420 ERROR [STDERR]     at $Proxy9.undeploy(Unknown Source)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.deployment.scanner.URLDeploymentScanner.undeploy(URLDeploymentScanner.java:450)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:604)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
2010-09-15 10:27:28,420 ERROR [STDERR]     at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
2010-09-15 10:27:28,435 ERROR [STDERR]     at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)

Can you help me?
Thank you
7 REPLIES 7

chicco0386
Champ on-the-rise
Champ on-the-rise
Anyone can help me?

jeyaa
Champ in-the-making
Champ in-the-making
Did ur problem get solved?. Do you have any idea of accessing the remote alfresco server. ie., http://10.10.10.10:8080/alfresco. How could I access from your above code?

jcustovic
Champ in-the-making
Champ in-the-making
RepositoryUtils is not a class from alfresco lib.
You can access alfresco web services using these command:

// Set url to alfresco web services
WebServiceFactory.setEndpointAddress("http://10.10.10.10:8080/alfresco/api");
// Start session
AuthenticationUtils.startSession(alfrescoUsername, alfrescoPassword);
System.out.println("Ticket: " + AuthenticationUtils.getTicket());
try {
… code to access alfresco web services …
} finally {
   // End session
   AuthenticationUtils.endSession();
}

jeyaa
Champ in-the-making
Champ in-the-making
Thanks Jan,
It's working fine. Could you please help me to get these details in web providing the links to refer. 
Thanks once again.

chicco0386
Champ on-the-rise
Champ on-the-rise
RepositoryUtils is not a class from alfresco lib.
You can access alfresco web services using these command:

// Set url to alfresco web services
WebServiceFactory.setEndpointAddress("http://10.10.10.10:8080/alfresco/api");
// Start session
AuthenticationUtils.startSession(alfrescoUsername, alfrescoPassword);
System.out.println("Ticket: " + AuthenticationUtils.getTicket());
try {
… code to access alfresco web services …
} finally {
   // End session
   AuthenticationUtils.endSession();
}

RepositoryUtils is a class that I've write to help me, if you want these are the methods for loggin:

public class RepositoryUtils {

   private static Log log = LogFactory.getLog(RepositoryUtils.class);

   public static void login() throws AuthenticationFault {
      boolean isLogged = RepositoryUtils.isLoggedIn();

      if (!isLogged) {
         log.info("process, procedo con l'autenticazione");
         String username = ConfigManager.getInstance().getConfigValue("alfresco.username");
         String password = ConfigManager.getInstance().getConfigValue("alfresco.password");
         AuthenticationUtils.startSession(username, password);
      }
   }

   public static boolean isLoggedIn() {
      boolean logged = false;
      AuthenticationDetails authenticationDetails = AuthenticationUtils.getAuthenticationDetails();
      if (authenticationDetails != null) {
         String userName = authenticationDetails.getUserName();
         logged = true;
         log.info("isLoggedIn, sono autenticato con user [" + userName + "]");
      } else {
         log.info("isLoggedIn, NON sono autenticato");
      }
      return logged;

   }
}


I hope that can help you.

jcustovic
Champ in-the-making
Champ in-the-making
Thanks Jan,
It's working fine. Could you please help me to get these details in web providing the links to refer. 
Thanks once again.

http://wiki.alfresco.com/wiki/Web_Service_Samples_for_Java and code http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/sdk/samples/WebServic...

jeyaa
Champ in-the-making
Champ in-the-making
Thanks a lot. This really helps me. Smiley Very Happy
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.