Hi there, from the trace it seems like you have a jpa 1.x provider on the classpath. James use jpa 2.x, so you need to remove the 1.x one..
Hope it helps, Norman 2011/1/28 Luc Saulière <[email protected]>: > Of course, I give you some details if you are interested. > > The stand alone app needs only 6 beans : > mailboxManager which needs authenticator and sessionMapperFactory which > needs entityManagerFactory which needs datasource and vendorAdapter. > which are loaded with ApplicationContext constructor...(and I get them by > context.getbean method) > > My web app is a BaseDS app, which loads beans with a dispatcherServlet.xml > file, and then injects them with annotation (like @Resource or @Autowired). > As I load the authenticator bean, the builder throw an exception asking for > a localusersrepository bean and then another bean... > I then make my own simple authenticator which does not need a usersRepos > (this Auth is always answering yes:). But I don't understand why in my > standalone app I don't need this... > > Second issue, and much bigger, once my authenticator, datasource, > vendorAdapter instanced, the entityManagerFactory throw me some persistence > issues... > First I am told that the xml schema of META-INF/persistence.xml (that I've > imported in my web-app project) is not correct. And I got this first stack > trace, which means, I think, "you have to use version 1.0 of persistence" > after that I change the version to 1.0 in persistence.xml and I got a second > trace about a ValidationMode method. > The first trace : > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'entityManagerFactory' defined in ServletContext resource > [/WEB-INF/dispatcherServlet-servlet.xml]: Invocation of init method failed; > nested exception is java.lang.IllegalArgumentException: Invalid XML in > persistence unit from URL > [file:/C:/WSRFLX/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/kiengiRecup-server/WEB-INF/classes/META-INF/persistence.xml] > > I skip the trace which are not useful I think... and then, the XML traces... > > Caused by: java.lang.IllegalArgumentException: Invalid XML in persistence > unit from URL > [file:/C:/WSRFLX/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/kiengiRecup-server/WEB-INF/classes/META-INF/persistence.xml] > at > org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.readPersistenceUnitInfos(PersistenceUnitReader.java:150) > at > org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.readPersistenceUnitInfos(DefaultPersistenceUnitManager.java:303) > at > org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:275) > at > org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:260) > at > org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:192) > at > org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:288) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398) > ... 32 more > Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.1: Value '2.0' > of attribute 'version' of element 'persistence' is not valid with respect to > the corresponding attribute use. Attribute 'version' has a fixed value of > '1.0'. > at > com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) > at > com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) > at > com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) > at > com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:417) > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3181) > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processOneAttribute(XMLSchemaValidator.java:2801) > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2713) > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2065) > at > com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705) > at > com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400) > at > com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626) > at > com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3103) > at > com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922) > at > com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) > at > com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140) > at > com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) > at > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) > at > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) > at > com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) > at > com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235) > at > com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284) > at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124) > at > org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.validateResource(PersistenceUnitReader.java:186) > at > org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.readPersistenceUnitInfos(PersistenceUnitReader.java:137) > ... 39 more > > The second trace : > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'entityManagerFactory' defined in ServletContext resource > [/WEB-INF/dispatcherServlet-servlet.xml]: Invocation of init method failed; > nested exception is java.lang.AbstractMethodError: > org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode; > > I skip the trace which are not useful I think... and then, the persistence > traces... > > Caused by: java.lang.AbstractMethodError: > org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode; > at > org.apache.openjpa.persistence.PersistenceUnitInfoImpl.toOpenJPAProperties(PersistenceUnitInfoImpl.java:457) > at > org.apache.openjpa.persistence.PersistenceProductDerivation.load(PersistenceProductDerivation.java:314) > at > org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:161) > at > org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:65) > at > org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225) > at > org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:288) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398) > ... 32 more > 28 janv. 2011 12:30:24 org.apache.catalina.core.StandardContext > loadOnStartup > GRAVE: La servlet a généré une exception "load()" > java.lang.AbstractMethodError: > org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode; > at > org.apache.openjpa.persistence.PersistenceUnitInfoImpl.toOpenJPAProperties(PersistenceUnitInfoImpl.java:457) > at > org.apache.openjpa.persistence.PersistenceProductDerivation.load(PersistenceProductDerivation.java:314) > at > org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:161) > at > org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:65) > at > org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225) > at > org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:288) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) > at > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) > at > org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) > at > org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) > at > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) > at > org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:540) > at > org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842) > at > org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416) > at > org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) > at > org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) > at > org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) > at > org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) > at > org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) > at javax.servlet.GenericServlet.init(GenericServlet.java:212) > at > org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) > at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) > at > org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4387) > at org.apache.catalina.core.StandardContext.start(StandardContext.java:4700) > at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) > at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) > at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) > at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) > at org.apache.catalina.core.StandardService.start(StandardService.java:525) > at org.apache.catalina.core.StandardServer.start(StandardServer.java:701) > at org.apache.catalina.startup.Catalina.start(Catalina.java:585) > 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:597) > at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) > > Thx. > > 2011/1/28 Norman Maurer <[email protected]> > >> Could you give use some more details ? Like the stacktrace etc. >> >> Bye, >> Norman >> >> >> 2011/1/28 Luc Saulière <[email protected]>: >> > Hi James Dev Team, >> > Another question on this topic, in facts another step in my James based >> app >> > devlopment. >> > The mail storage in James DB (via jdbc mysql connector) works fine in >> stand >> > alone with only 6 beans (7 with the PlaceHolderConfigurer). >> > My issue takes place in a JavaEE/Spring app, when I tried to load my >> reduced >> > James spring context, the build behaviour is not the same as in stand >> alone >> > and it ask me much more beans for, actually trigger a class constructor >> > exception. >> > Anyone has a clue about James based webapp dev? >> > >> > Thx, >> > Luc. >> > >> > 2011/1/24 Eric Charles <[email protected]> >> > >> >> Hi Luc, >> >> >> >> Try to add in log4j.properties >> >> log4j.logger.com.kiengi.recup=INFO, CONS, FILE >> >> >> >> Tks, >> >> >> >> Eric >> >> >> >> >> >> >> >> On 24/01/2011 17:05, Luc Saulière wrote: >> >> >> >>> Hello, >> >>> >> >>> Now I load my java app, as a James side module, I would like to log >> some >> >>> informations for debug and information, like James : >> >>> >> >>> INFO 16:42:31,246 | >> >>> org.apache.james.container.spring.JamesServerApplicationContext | >> >>> Refreshing >> >>> >> org.apache.james.container.spring.JamesServerApplicationContext@27e59128: >> >>> startup date [Mon Jan 24 16:42:31 CET 2011]; root of context hierarchy >> >>> >> >>> INFO 16:42:31,859 | >> >>> org.apache.james.container.spring.JamesServerApplicationContext | >> Closing >> >>> >> org.apache.james.container.spring.JamesServerApplicationContext@27e59128: >> >>> startup date [Mon Jan 24 16:42:31 CET 2011]; root of context hierarchy >> >>> >> >>> I tried to make a log : >> >>> >> >>> Log log = LogFactory.getLog(Main.class.getName()); >> >>> >> >>> >> >>> But I got : >> >>> >> >>> log4j:WARN No appenders could be found for logger >> >>> (com.kiengi.recup.POP.Main). >> >>> >> >>> log4j:WARN Please initialize the log4j system properly. >> >>> >> >>> So the only solution I have is : >> >>> >> >>> System.out.println("String to write to the console..."); >> >>> >> >>> Which is a little bit archaic... >> >>> >> >>> So do you have any clue about how to log properly to the Java (or >> Eclipse) >> >>> console? >> >>> >> >>> Thx >> >>> Luc. >> >>> >> >>> 2011/1/21 Norman Maurer<[email protected]> >> >>> >> >>> So you want to store a MimeMessage instance in the Mailbox ? >> >>>> >> >>>> You could use the MimeMessageInputStream class for this: >> >>>> >> >>>> >> >>>> >> >>>> >> http://svn.apache.org/viewvc/james/server/trunk/core/src/main/java/org/apache/james/core/MimeMessageInputStream.java?view=markup >> >>>> >> >>>> Bye, >> >>>> Norman >> >>>> >> >>>> >> >>>> 2011/1/21 Luc Saulière<[email protected]>: >> >>>> >> >>>>> It worked, that was a weird eclipse behaviour... >> >>>>> You are very helpful, may I bother you one more time? maybe the >> last... >> >>>>> maybe not :) >> >>>>> >> >>>>> Now I can easily store my messages in the db, ok, but the source of >> my >> >>>>> messages is an inputStream. >> >>>>> I don't know how to make an Inputstream from a mail message (as >> >>>>> >> >>>> javax.Mail, >> >>>> >> >>>>> MimeMessage or Message...) cause each try I made gave me a "bad >> header >> >>>>> message...". >> >>>>> I see in James code the MessageResultImpl class which looks like a >> >>>>> >> >>>> Message >> >>>> >> >>>>> def but with Content type instead of MimeMessage... >> >>>>> I will try to parse every ppty of the message and make a new >> >>>>> >> >>>> MessageResult >> >>>> >> >>>>> and find a way to extract the damned InputStream I need... >> >>>>> >> >>>>> Thx >> >>>>> >> >>>>> >> >>>>> >> >>>>> 2011/1/21 Norman Maurer<[email protected]> >> >>>>> >> >>>>> Maybe some nice classpath problem with eclipse or something like >> >>>>>> that.. maybe just rename your beans config to something else and use >> >>>>>> it in the Main class. Just to be sure it not use the wrong one.. >> >>>>>> >> >>>>>> Bye, >> >>>>>> Norman >> >>>>>> >> >>>>>> >> >>>>>> 2011/1/21 Luc Saulière<[email protected]>: >> >>>>>> >> >>>>>>> Thx, it works perfectly with only only 7 beans. >> >>>>>>> Just one weird thing, in my J3M2 project which worked perfectly >> >>>>>>> >> >>>>>> yesterday, I >> >>>>>> >> >>>>>>> have now a XmlBeanDefinitionStoreException, which specify the >> >>>>>>> spring-beans.xml line number 1770!!?! >> >>>>>>> weird, isn't it? >> >>>>>>> >> >>>>>>> 2011/1/20 Norman Maurer<[email protected]> >> >>>>>>> >> >>>>>>> Hi there, >> >>>>>>>> >> >>>>>>>> exactly. In fact you will prolly only need to instance the needed >> >>>>>>>> MailboxManager/SubscriptionManager/Authenticator implementation >> you >> >>>>>>>> want to use in your code or just wire these implementations via >> >>>>>>>> spring. Everything else should not be needed. >> >>>>>>>> >> >>>>>>>> Bye, >> >>>>>>>> Norman >> >>>>>>>> >> >>>>>>>> >> >>>>>>>> 2011/1/20 Luc Saulière<[email protected]>: >> >>>>>>>> >> >>>>>>>>> Ok it works, I didnt know how to inject beans in my main class... >> >>>>>>>>> It loads all the james app before sending one mail to the bdd, >> but >> >>>>>>>>> >> >>>>>>>> it >> >>>> >> >>>>> works >> >>>>>>>> >> >>>>>>>>> :) In fact I hacked all the spring-bean.xml (from J3M2) without >> >>>>>>>>> >> >>>>>>>> deleting >> >>>>>> >> >>>>>>> any >> >>>>>>>> >> >>>>>>>>> bean... I just have to select those I need. >> >>>>>>>>> >> >>>>>>>>> Thanks for your help, >> >>>>>>>>> Luc >> >>>>>>>>> >> >>>>>>>>> 2011/1/20 Eric Charles<[email protected]> >> >>>>>>>>> >> >>>>>>>>> Hi, >> >>>>>>>>>> >> >>>>>>>>>> Yes, direct injection does not work in main class because it is >> >>>>>>>>>> >> >>>>>>>>> not >> >>>> >> >>>>> fetched >> >>>>>>>> >> >>>>>>>>> from spring context. >> >>>>>>>>>> >> >>>>>>>>>> 1. you can create a bean and move the @Resource within, define >> the >> >>>>>>>>>> >> >>>>>>>>> bean >> >>>>>> >> >>>>>>> in >> >>>>>>>> >> >>>>>>>>> spring xml context, spring should inject the mailboxmanager in >> >>>>>>>>>> >> >>>>>>>>> your >> >>>> >> >>>>> bean. >> >>>>>>>> >> >>>>>>>>> You can get your bean with context.getBean("mybean") in main >> >>>>>>>>>> >> >>>>>>>>> class. >> >>>> >> >>>>> 2. or simply call from the main class >> >>>>>>>>>> >> >>>>>>>>> context.getBean("mailboxmanager"), >> >>>>>> >> >>>>>>> it >> >>>>>>>> >> >>>>>>>>> should give you the mailboxmanager,... but it seems you had an >> >>>>>>>>>> >> >>>>>>>>> exception >> >>>>>> >> >>>>>>> (if >> >>>>>>>> >> >>>>>>>>> such, could you provide the stack trace ?). >> >>>>>>>>>> >> >>>>>>>>>> Tks, >> >>>>>>>>>> >> >>>>>>>>>> Eric >> >>>>>>>>>> >> >>>>>>>>>> >> >>>>>>>>>> >> >>>>>>>>>> On 20/01/2011 15:42, Luc Saulière wrote: >> >>>>>>>>>> >> >>>>>>>>>> Hello Eric, >> >>>>>>>>>>> That was quite the code I tested yesterday, but I got still the >> >>>>>>>>>>> >> >>>>>>>>>> same >> >>>> >> >>>>> exception, because the MailboxManager is not initialized (null >> >>>>>>>>>>> >> >>>>>>>>>> pointer >> >>>>>> >> >>>>>>> exception). >> >>>>>>>>>>> I tried the @Resource annotation, I got 'null pointer' and I >> >>>>>>>>>>> >> >>>>>>>>>> tried >> >>>> >> >>>>> the >> >>>>>> >> >>>>>>> BeanFactory way but I got a 'bean creation exception'... >> >>>>>>>>>>> I think the first method is the good one, but I'm still looking >> >>>>>>>>>>> >> >>>>>>>>>> after >> >>>>>> >> >>>>>>> the >> >>>>>>>> >> >>>>>>>>> magic method to instantiate my MailboxManager. >> >>>>>>>>>>> >> >>>>>>>>>>> Thx, >> >>>>>>>>>>> Luc. >> >>>>>>>>>>> >> >>>>>>>>>>> >> >>>>>>>>>>> 2011/1/20 Eric Charles<[email protected]> >> >>>>>>>>>>> >> >>>>>>>>>>> Hi, >> >>>>>>>>>>> >> >>>>>>>>>>>> Probably you did not instantiate spring context. >> >>>>>>>>>>>> >> >>>>>>>>>>>> As first shot, you could copy Main to YourMain >> >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>> >> https://svn.apache.org/repos/asf/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/Main.java >> >>>> >> >>>>> and hack it with for example with code sample in [1]. >> >>>>>>>>>>>> >> >>>>>>>>>>>> You can also hack the spring context xml files if you don't >> want >> >>>>>>>>>>>> >> >>>>>>>>>>> to >> >>>> >> >>>>> load >> >>>>>>>> >> >>>>>>>>> all the beans, but you will still need a few of them to access >> >>>>>>>>>>>> >> >>>>>>>>>>> the >> >>>> >> >>>>> mailbox. >> >>>>>>>>>>>> >> >>>>>>>>>>>> Obviously, we could discuss the following: >> >>>>>>>>>>>> 1. Add some code simple samples for basic operations on >> mailbox. >> >>>>>>>>>>>> 2. Have a spring context for mailbox that could be used as a >> >>>>>>>>>>>> >> >>>>>>>>>>> stand-alone >> >>>>>>>> >> >>>>>>>>> (and also be imported in server). >> >>>>>>>>>>>> >> >>>>>>>>>>>> Tks, >> >>>>>>>>>>>> >> >>>>>>>>>>>> Eric >> >>>>>>>>>>>> >> >>>>>>>>>>>> [1] code sample (non compiling). >> >>>>>>>>>>>> >> >>>>>>>>>>>> public class YourMain { >> >>>>>>>>>>>> >> >>>>>>>>>>>> private static Log log = >> >>>>>>>>>>>> >> >>>>>>>>>>> LogFactory.getLog(Main.class.getName()); >> >>>>>> >> >>>>>>> @Ressource(name="mailboxmanager") >> >>>>>>>>>>>> private static MailboxManager; >> >>>>>>>>>>>> >> >>>>>>>>>>>> public static void main(String[] args) throws IOException { >> >>>>>>>>>>>> >> >>>>>>>>>>>> final JamesServerApplicationContext context = new >> >>>>>>>>>>>> JamesServerApplicationContext(new String[] { >> >>>>>>>>>>>> "context/james-server-context.xml" }); >> >>>>>>>>>>>> context.registerShutdownHook(); >> >>>>>>>>>>>> >> >>>>>>>>>>>> // Bad code practice - Refactor it!!! >> >>>>>>>>>>>> >> >>>>>>>>>>>> MailboxPath mailboxPath = >> MailboxPath.inbox("userName"); >> >>>>>>>>>>>> >> >>>>>>>>>>>> MailboxSession mailboxSession = >> >>>>>>>>>>>> mailboxManager.createSystemSession(userName30, log) >> >>>>>>>>>>>> mailboxManager.startProcessingRequest(mailboxSession); >> >>>>>>>>>>>> try { >> >>>>>>>>>>>> mailboxManager.createMailbox(mailboxPath, >> >>>>>>>>>>>> >> >>>>>>>>>>> mailboxSession); >> >>>>>>>> >> >>>>>>>>> } >> >>>>>>>>>>>> catch (MailboxExistsException e) { >> >>>>>>>>>>>> // Do nothing, the mailbox already exists. >> >>>>>>>>>>>> } >> >>>>>>>>>>>> >> >>>>>>>>>>>> mailboxManager.endProcessingRequest(mailboxSession); >> >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>>>>>>>>>> MessageManager messageManager = >> >>>>>>>>>>>> mailboxManager.getMailbox("mailboxPath", mailboxSession); >> >>>>>>>>>>>> >> >>>>>>>>>>>> // instanciate an input stream that contains your email >> >>>>>>>>>>>> >> >>>>>>>>>>> content >> >>>>>> >> >>>>>>> (body, header,...) >> >>>>>>>>>>>> >> >>>>>>>>>>>> messageManager.appendMessage(your-input-stream, >> >>>>>>>>>>>> new Date(), >> >>>>>>>>>>>> mailboxSession, >> >>>>>>>>>>>> isRecent, >> >>>>>>>>>>>> flags); >> >>>>>>>>>>>> >> >>>>>>>>>>>> mailboxManager.endProcessingRequest(mailboxSession); >> >>>> >> >>>>> } >> >>>>>>>>>>>> >> >>>>>>>>>>>> } >> >>>>>>>>>>>> >> >>>>>>>>>>>> } >> >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>>>>>>>>>> On 19/01/2011 20:07, Luc Saulière wrote: >> >>>>>>>>>>>> >> >>>>>>>>>>>> Thx for answering so quickly, I tried this in a new package >> >>>>>>>>>>>> >> >>>>>>>>>>> inside >> >>>> >> >>>>> james-server-container-spring project... >> >>>>>>>>>>>>> I have a public static void main(String[] args) containing my >> >>>>>>>>>>>>> >> >>>>>>>>>>>> private >> >>>>>> >> >>>>>>> staticMailboxManager mailboxManager which >> >>>>>>>>>>>>> >> >>>>>>>>>>>>> is injected with the annotation >> >>>>>>>>>>>>> >> >>>>>>>>>>>> @Resource(name="mailboxmanager") >> >>>> >> >>>>> from >> >>>>>> >> >>>>>>> the >> >>>>>>>>>>>>> spring-bean.xml. >> >>>>>>>>>>>>> But it does not succeed in initializing the variable and I >> get >> >>>>>>>>>>>>> >> >>>>>>>>>>>> a >> >>>> >> >>>>> NullPointerException as soon as I use it... >> >>>>>>>>>>>>> How can I initialize my beans without running the entire >> James >> >>>>>>>>>>>>> >> >>>>>>>>>>>> app? >> >>>>>> >> >>>>>>> Tks. >> >>>>>>>>>>>>> >> >>>>>>>>>>>>> >> >>>>>>>>>>>>> 2011/1/19 Eric Charles<[email protected]> >> >>>>>>>>>>>>> >> >>>>>>>>>>>>> Hi Luc, >> >>>>>>>>>>>>> >> >>>>>>>>>>>>> Yes, code has changed in trunk since M2 (we don't use >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>> MailServer >> >>>> >> >>>>> anymore). >> >>>>>>>>>>>>>> In M2, or in trunk, the way to store mail is the same. >> >>>>>>>>>>>>>> If you are deploying the your code/class in the james spring >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>> container, >> >>>>>>>> >> >>>>>>>>> you >> >>>>>>>>>>>>>> need to inject the mailboxmanager (with >> >>>>>>>>>>>>>> @Resources(name="mailboxmanager") >> >>>>>>>>>>>>>> and have a block of code such as: >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> MailboxPath mailboxPath = MailboxPath.inbox(userName30); >> >>>>>>>>>>>>>> MailboxSession mailboxSession = >> >>>>>>>>>>>>>> mailboxManager.createSystemSession(userName30, log) >> >>>>>>>>>>>>>> MessageManager messageManager = >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>> mailboxManager.getMailbox(mailboxPath, >> >>>>>>>> >> >>>>>>>>> mailboxSession); >> >>>>>>>>>>>>>> messageManager.appendMessage(your-input-stream, >> >>>>>>>>>>>>>> new Date(), >> >>>>>>>>>>>>>> mailboxSession, >> >>>>>>>>>>>>>> isRecent, >> >>>>>>>>>>>>>> flags); >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> mailboxManager.endProcessingRequest(mailboxSession); >> >>>>>> >> >>>>>>> } >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> I just realize I can't find a simple test case to in trunk >> to >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>> show >> >>>>>> >> >>>>>>> this >> >>>>>>>> >> >>>>>>>>> (or >> >>>>>>>>>>>>>> maybe I didn't look good). >> >>>>>>>>>>>>>> If we don't have this, maybe you could open a jira so we can >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>> further >> >>>>>> >> >>>>>>> provide test samples. >> >>>>>>>>>>>>>> (this comes from the fact that all our tests were made from >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>> an >> >>>> >> >>>>> "imap >> >>>>>>>> >> >>>>>>>>> perspective", we moved the imap test to another project, but >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>> we >> >>>> >> >>>>> probably >> >>>>>>>>>>>>>> should further enrich the pure mailbox test cases/samples). >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> Tks, >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> Eric >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> On 19/01/2011 18:04, Luc Sauličre wrote: >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> Hello, >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> I'm developing with Math on the same mail app. We didn't >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> succeed >> >>>> >> >>>>> in >> >>>>>> >> >>>>>>> storing >> >>>>>>>>>>>>>>> mail as james3 does. In fact the SieveMailet class does not >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> have >> >>>> >> >>>>> a >> >>>>>> >> >>>>>>> setUsersRepo method, I think you're dealing with a newer >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> version >> >>>> >> >>>>> of >> >>>>>> >> >>>>>>> James3... >> >>>>>>>>>>>>>>> We are developing with the M2 one and SieveMailet have a >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> setMailserver >> >>>>>>>> >> >>>>>>>>> method instead. >> >>>>>>>>>>>>>>> So, is there any way to store a mail (from another IMAP >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> connection >> >>>>>> >> >>>>>>> for >> >>>>>>>> >> >>>>>>>>> instance) in the James3 mySQL db, as James3 does (i.e. >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> filling >> >>>> >> >>>>> correctly >> >>>>>>>>>>>>>>> all >> >>>>>>>>>>>>>>> the appropriate tables...)? >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> Thx for helping. >> >>>>>>>>>>>>>>> Luc. >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> 2011/1/17 Eric Charles<[email protected]> >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> Hi, >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> The mails store magic occurs in LocalDelivery where the >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> MailboxManager >> >>>>>>>>>>>>>>>> is >> >>>>>>>>>>>>>>>> injected. >> >>>>>>>>>>>>>>>> (more precise, LocalDelivery uses the SieveMailet >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> initialized >> >>>> >> >>>>> with >> >>>>>> >> >>>>>>> the >> >>>>>>>>>>>>>>>> MailboxManager) >> >>>>>>>>>>>>>>>> sieveMailet.setUsersRepository(usersRepository); >> >>>>>>>>>>>>>>>> sieveMailet.setMailboxManager(mailboxManager); >> >>>>>>>>>>>>>>>> sieveMailet.init(m); >> >>>>>>>>>>>>>>>> sieveMailet.setQuiet(true); >> >>>>>>>>>>>>>>>> ... >> >>>>>>>>>>>>>>>> if (mail.getState() != Mail.GHOST) { >> >>>>>>>>>>>>>>>> sieveMailet.service(mail); >> >>>>>>>>>>>>>>>> } >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> You only need to know that *MailRepository is not for >> users' >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> mail >> >>>>>> >> >>>>>>> storage >> >>>>>>>>>>>>>>>> http://james.apache.org/server/3/feature-persistence.html >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> Both topics (mailet usage for delivery + separate mail >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> stores) >> >>>> >> >>>>> are >> >>>>>> >> >>>>>>> subject >> >>>>>>>>>>>>>>>> to discussion will certainly change. >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> Tks, >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> Eric >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> On 17/01/2011 11:43, math math wrote: >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> Hello everybody, >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> I am developping a web mail project using james 3M2. I'm >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> trying >> >>>>>> >> >>>>>>> to >> >>>>>>>> >> >>>>>>>>> store >> >>>>>>>>>>>>>>>>> mails in a "james3" way with an external application >> using >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> MySql >> >>>>>> >> >>>>>>> DB. >> >>>>>>>> >> >>>>>>>>> I've >> >>>>>>>>>>>>>>>>> tried to store mails using mysq database repositories for >> a >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> few >> >>>>>> >> >>>>>>> days >> >>>>>>>> >> >>>>>>>>> now >> >>>>>>>>>>>>>>>>> but >> >>>>>>>>>>>>>>>>> i didn't succeed to do so... I 've traced the store >> method >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> of >> >>>> >> >>>>> JDBCMailRepository class and also the ToRepository one. But >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> still >> >>>>>> >> >>>>>>> don't >> >>>>>>>>>>>>>>>>> know >> >>>>>>>>>>>>>>>>> how James 3 is storing mails in the DB. >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> I would be very glad if someone could help me in this >> task. >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> Thanks, >> >>>>>>>>>>>>>>>>> Mat >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>>> >> --------------------------------------------------------------------- >> >>>> >> >>>>> To unsubscribe, e-mail: >> >>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> [email protected] >> >>>>>> >> >>>>>>> For additional commands, e-mail: >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>> [email protected] >> >>>>>> >> >>>>>>> >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> >>>>>>>>>>>>>>>> >> --------------------------------------------------------------------- >> >>>> >> >>>>> To unsubscribe, e-mail: >> >>>>>>>>>>>>>>> >> >>>>>>>>>>>>>> [email protected] >> >>>> >> >>>>> For additional commands, e-mail: >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>> [email protected] >> >>>>>> >> >>>>>>> >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> >>>>>>>>>>>>>> >> --------------------------------------------------------------------- >> >>>> >> >>>>> To unsubscribe, e-mail: [email protected] >> >>>>>>>>>>>> For additional commands, e-mail: >> >>>>>>>>>>>> >> >>>>>>>>>>> [email protected] >> >>>> >> >>>>> >> >>>>>>>>>>>> >> >>>>>>>>>>>> >> >>>>>>>>>> >> --------------------------------------------------------------------- >> >>>> >> >>>>> To unsubscribe, e-mail: [email protected] >> >>>>>>>>>> For additional commands, e-mail: >> [email protected] >> >>>>>>>>>> >> >>>>>>>>>> >> >>>>>>>>>> >> --------------------------------------------------------------------- >> >>>>>>>> To unsubscribe, e-mail: [email protected] >> >>>>>>>> For additional commands, e-mail: [email protected] >> >>>>>>>> >> >>>>>>>> >> >>>>>>>> >> --------------------------------------------------------------------- >> >>>>>> To unsubscribe, e-mail: [email protected] >> >>>>>> For additional commands, e-mail: [email protected] >> >>>>>> >> >>>>>> >> >>>>>> >> --------------------------------------------------------------------- >> >>>> To unsubscribe, e-mail: [email protected] >> >>>> For additional commands, e-mail: [email protected] >> >>>> >> >>>> >> >>>> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [email protected] >> >> For additional commands, e-mail: [email protected] >> >> >> >> >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
