File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes James embedding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "James embedding" Watch "James embedding" New topic
Author

James embedding

Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Hi, I find some James embedding example on this url, Embeddable James, but I don't really get how to relate, the refined MAIN class of author (the args argument) and the servlet code 9inside what args variable has been used).? This is the code of lunchJAMES servlet:


and this is working version of Main with functions that were added or modified :

Is this way of embedding achievable ( I also find some quite obscure means of James embedding in association with Spring) ?>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
This seems to use separate classloaders for James; is that necessary in your case? I'd just drop all the libraries into WEB-INF/lib, and use a context listener to start a background thread that calls the standard main method.
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
No of course, it's not necessary but was the only example of embedding James. So, you suggest to copy each libraries from james source (there is few lib. folders containing many libraries. Do I need some particular like phoenix-loader.jar), and in the web.xml ( I'm gonna try to add it into .war apps. to place something like this :


and in the class MyContextListener, to do somthing like this :


Is that what you think?
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
No, it was just ridiculous thought. I try it really I do not get it...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
That is pretty much exactly what I was thinking of.
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
yeah? But nothing's happens.. I cannot send messages between users (probably because James hasn't started).I wrote this testing listener:


and this mapping ;

When I type address http://www.localhost.com:8080/James_Test/, the Welcome.jsp page would open, and nothing ( I believe that myListener class should be invoked on servletcontext startup, and create instance of Main class. Probably I need to invoke some method of James (like I start it from command line typing run.bat). If so, what is that method?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
But nothing's happens

I wouldn't expect anything visible to happen, since James has no GUI.
I cannot send messages between users

What happened when you tried?
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Well, nothing. I even monitor number of processes when I start server, and no more is added (unlike when I start James by command prompt). However, when I open outlook I get follow error :


It mean, that James hasn't started, i think, because, when I start it by run.bat, I can perform sending/receiving of messages between users.
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
One more thing. In my application lib-folder, I store only phoenix-xxx.jar, jar files and mx4j-tools.jar. If I include all from JAMES_HOME/lib, and JAMES_HOME/tools, and JAMES_HOME/bin/lib, I continuously receive an exception and failed deployment of application...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
I even monitor number of processes when I start server, and no more is added (unlike when I start James by command prompt).

The number of processes wouldn't change, because it runs inside the JVM (which is just one process).

The connection to the server has failed. Account: '127.0.0.1', Server: '127.0.0.1', Protocol: POP3, Port: 110, Secure(SSL): No, Socket Error: 10061, Error Number: 0x800CCC0E

Not sure what that's trying to tell us, but it sure doesn't look good. But "Account: '127.0.0.1'" looks particularly strange, as if the code were using "127.0.0.1" for the username.

In my application lib-folder, I store only phoenix-xxx.jar, jar files and mx4j-tools.jar. If I include all from JAMES_HOME/lib, and JAMES_HOME/tools, and JAMES_HOME/bin/lib, I continuously receive an exception and failed deployment of application...

I'd expect all jar files to be needed; if there are exceptions I'd start by tracking those down. It's possible that there are version conflicts with other jar files your code -or the servlet engine- uses.

You could also make this a separate web app, independent of the one that runs your other application code.
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
well, 127.0.0.1, was name of account nothing special. I have change it. I've delete applications from Tomcat's deployment directory, so this is the only. There is something wrong about some arguments, and excalibur.jar I have nowhere on my classpath. I just have configured PHOENIX_HOME environment variable. This is the stack trace ;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: James embedding