[ 
https://issues.apache.org/jira/browse/JAMES-3580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17342173#comment-17342173
 ] 

Cosimo Damiano Prete commented on JAMES-3580:
---------------------------------------------

More on this, it seems like that even the `usersrepository.xml` file (copied 
under `conf`) is ignored, since I've
{code:xml}
<usersrepository name="LocalUsers" class="foo.bar.LazyJPAUsersRepository">
    <algorithm>SHA-512</algorithm>
    <enableVirtualHosting>true</enableVirtualHosting>
</usersrepository>
{code}
and 
{code:java}
public class LazyJPAUsersRepository extends JPAUsersRepository {
    private static final Logger LOGGER = 
LoggerFactory.getLogger(LazyJPAUsersRepository.class);
    @Inject
    public LazyJPAUsersRepository(DomainList domainList) {
        super(domainList);
        LOGGER.info("Created!");
    }
    @Override
    public boolean contains(Username name) throws UsersRepositoryException {
        LOGGER.info("In contains(Username)");
        LOGGER.info("super.contains(Username): {}", super.contains(name));
        if(!super.contains(name)) {
            addUser(name, name.getLocalPart());
        }

        return true;
    }
    @Override
    public User getUserByName(Username name) throws UsersRepositoryException {
        User user = super.getUserByName(name);
        LOGGER.info("In getUserByName(Username)");
        LOGGER.info("super.getUserByName(Username): {}", user);
        if(user == null) {
            addUser(name, name.getLocalPart());
            user = getUserByName(name);
        }

        return user;
    }
}
{code}
and 
{code:java}
public class CreateUserIfMissingModule extends AbstractModule {
    @Override
    protected void configure() {
        final CreateUserIfMissingInterceptor interceptor = new 
CreateUserIfMissingInterceptor();
        requestInjection(interceptor); // Inject the repository
        bindInterceptor(subclassesOf(UsersRepository.class), 
returns(subclassesOf(Boolean.class)), interceptor);
    }

    @Provides
    @Singleton
    public LazyJPAUsersRepository provideLazyJpaUsersRepository(DomainList 
domainList) {
        return new LazyJPAUsersRepository(domainList);
    }
}
{code}

but no log is printed out; not even the one in the constructor (PS I've a 
logger defined in logback.xml with level INFO).
I tried copying the jar in both `james-server-jpa-guice.lib` (since it 
contributes to the classpath) and in `extensions-jars`, but I didn't succeed.

> Can't integrate PostgreSQL completely
> -------------------------------------
>
>                 Key: JAMES-3580
>                 URL: https://issues.apache.org/jira/browse/JAMES-3580
>             Project: James Server
>          Issue Type: Bug
>          Components: guice, jpa
>    Affects Versions: 3.6.0
>            Reporter: Cosimo Damiano Prete
>            Priority: Blocker
>
> Hi guys.
> I'm migrating from James 2 to 3.6.0 and I cannot find any way to make it work 
> completely with PostgreSQL.
> By following the documentation, I set the DB connection properties in the 
> james-database.properties file but, somehow, in the logs I always get: 
> 15:35:33.924 [INFO ] o.a.j.m.m.MemoryMailRepositoryStore - JamesMailStore 
> init... 
> org.apache.james.mailrepository.memory.MemoryMailRepositoryStore@33827b88
> As a result, I don't see any data in the database at all. Unfortunately the 
> documentation doesn't really help much more, so I don't know where else I 
> should have a look at.
> Moreover, in James 2 I had the possibility to specify my own datasource 
> implementation. Is it possible with James 3 as well and, if it's so, how?
> Finally, I would need to create the users on the fly if they don't exist. Is 
> there something already available? I was trying by using an extension which 
> defines a Guice module providing an interceptor: 
> {code:java}
> public class CreateUserIfMissingModule extends AbstractModule {
>     @Override
>     protected void configure() {
>         final CreateUserIfMissingInterceptor interceptor = new 
> CreateUserIfMissingInterceptor();
>         requestInjection(interceptor); // Inject the repository
>         bindInterceptor(subclassesOf(UsersRepository.class), 
> returns(subclassesOf(Boolean.class)), interceptor);
>     }
> } {code}
> but, also this one, is not picked up at all.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to