As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Exception in thread "main" javax.jcr.RepositoryException: Only one active session per thread.
import java.io.IOException; import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MyRepository { private static final String PASSWORD = "admin"; private static final String LOGIN = "admin"; private Repository repository; MyRepository(){ ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml"); repository = (Repository) context.getBean("JCR.Repository"); } public Session getSession() throws IOException, RepositoryException { System.out.println("Login… Getting new session… "); return repository.login(new SimpleCredentials(LOGIN, PASSWORD.toCharArray())); } }
Session session = repository.getSession();
[java] net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A v alid SecureContext was not provided in the RequestContext [java] at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.cr edentialsNotFound(AbstractSecurityInterceptor.java:477) [java] at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.be foreInvocation(AbstractSecurityInterceptor.java:355) [java] at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecur ityInterceptor.invoke(MethodSecurityInterceptor.java:77) [java] at org.springframework.aop.framework.ReflectiveMethodInvocation. proceed(ReflectiveMethodInvocation.java:176) [java] at org.alfresco.repo.security.permissions.impl.ExceptionTranslat orMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49) [java] at org.springframework.aop.framework.ReflectiveMethodInvocation. proceed(ReflectiveMethodInvocation.java:176) [java] at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditCom ponentImpl.java:256) [java] at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditCompone ntImpl.java:191) [java] at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMe thodInterceptor.java:69) [java] at org.springframework.aop.framework.ReflectiveMethodInvocation. proceed(ReflectiveMethodInvocation.java:176) [java] at org.springframework.transaction.interceptor.TransactionInterc eptor.invoke(TransactionInterceptor.java:107) [java] MultiAccessTest stop…5 [java] at org.springframework.aop.framework.ReflectiveMethodInvocation. proceed(ReflectiveMethodInvocation.java:176) [java] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(J dkDynamicAopProxy.java:210) [java] at $Proxy21.getCurrentUserName(Unknown Source) [java] at org.alfresco.jcr.util.JCRProxyFactory$SessionConte xtInvocatio nHandler.invoke(JCRProxyFactory.java:124) [java] at $Proxy84.getRootNode(Unknown Source) [java] at pl.swmind.jcr.test.UploadTest.execute(Unknown Source) [java] at pl.swmind.jcr.test.SingleTest.start(Unknown Source) [java] at pl.swmind.jcr.test.MultiAccessTest.run(Unknown Source)