You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Tom Dietz <to...@glis.net> on 2002/12/08 19:58:02 UTC

Debug startup of James

I am knew to James, and not a Java expert, but have been using Java for
a few years now so I can pretty much find my way around.

 

I am currently using IntelliJ IDEA 3.0 to debug James and I have gotten
that working in that I can set a breakpoint on say, an SMTPServer
connection and step through all the code there, but I don't have any
runtime (debug) to anything in Phoenix, Avalon, and all the other
projects James uses.


Is there someone out there that is using IDEA (or any GUI debugger) that
can give me a brief explanation of how I can debug everything.   I have
had IDEA for about a month now, so I am very new to that, but is there a
main project file that can contain all the other projects.   

 

The main reason for this (among other important ones) is I still don't
understand how phoenix loads James.   I have look at the run.bat (I am
Windows) and see that it passes in a special loader class, but what
happens then?  Is everything dynamically loaded based upon XML file
configurations?

 

The last reason why I would like to debug (at least the startup) is I am
trying to add a very basic mailet (as described in this arcticle:

http://www.javaworld.com/javaworld/jw-10-2001/jw-1026-jamesmail_p.html

 

And can't james to start in the debugger when my mailet is included in
the config.xml (it starts fine without it).


I traced it down to this error in phoenix's log:



1039373134293 [ERROR  ] (Phoenix.kernel.james.lifecycle): Block named
"spoolmanager" failed to pass through the Initialization stage. (Reason:
java.lang.NoClassDefFoundError: org/apache/mailet/GenericMailet).

 

I have made sure mailet.jar is in (and high) in the classpath, but still
get this error.

 

I hope this all makes sense.


Thanks!


Re: Debug startup of James

Posted by Darrell DeBoer <da...@apache.org>.
On Tue, 10 Dec 2002 02:22, Tom wrote:
> Why are things such as SAR and BAR files?   I know they are just Java
> Archive files, but it makes working with Avalon/Phoenix/James, etc. a
> pain with an IDE because they only (AFAIK with IDEA) only recognize .JAR
> files.

Hi Tom,

There's no need to rename any files when using IDEA (v3.0). Just do this:
1) Options->IDE Settings
2) Click on FileTypes
3) Add "sar" as a registered extension for the "Archive Files" file type.

This way, you can see the sar files in your project view. In IDEA 2.0 I don't 
think it's possible, but I don't think you could see jar files, either.

You shouldn't need to add the sar file to your classpath. Instead, you need to 
add the individual jar files separately (see Danny's email for debugging in 
eclipse).

>
> After figuring this out, I ended up just making copies of the BAR, SAR
> files and giving them JAR extensions (so the IDEA compiler wouldn't
> complain).

The compiler has no need to know about the sar file. I've got no idea why IDEA 
would need to see it, and thus complain.

I never compile from my ide, but use Ant instead. Add build.xml to the list of 
build files in the Ant tab, and execute the "main" target. This will compile 
everything, and bundle it into a distribution ready to roll.

>From there, the easiest way to build your custom mailet is to just add it into 
the org.apache.james.transport.mailets package. (NOTE: this is NOT a proper 
solution, but will get you up and running quickly). 

Here's a quick step-through that might help.
1) Check out James from cvs
2) Create a james project in IDEA - you *don't* need to set the compiler 
output path.
3) Add src/java to the sourcepath.
4) Add all of the jar files in lib and in phoenix-bin/lib to your classpath.
5) Add build.xml to your ant files
6) Execute the "main" target of build.xml
7) You now have a working ant distribution in "dist". Try it out and see if it 
works. Add a user. Configure your mail client to use localhost:25 for SMTP. 
Send an email to "user@localhost". Add a POP3 account to your email client 
using localhost:110. Make sure you can fetch the mail you sent.

8) OK, now you've got a working copy of james. Time to add your mailet.
9) Add a new package to src/java. Let's call it "mymailets".
10) Add a new class: "mymailets/SimpleMailet" - make this class extend 
org.apache.mailet.GenericMailet.
11) important: Modify "build.xml" - "sar" target to look like this
    <target name="sar" depends="prepare,compile">
	... stuff ...
        <jar jarfile=....>
            <include name="org/apache/james/**"/>
            <include name="org/apache/mailet/**"/>
            <include name="mymailets/**"/> <!-- This is the new line -->
        </jar>
        <!-- Make sar file-->
This will make sure that your new classes are included with the build.
12) Run the "main" target again - test James. Nothing should have changed.
13) Modify dist/james-2.1-cvs/apps/james/SAR-INF/config.xml (spoolmanager 
element) to use your mailet. You'll need to do this:
      <!-- Set the Java packages from which to load mailets and matchers -->
      <mailetpackages>
         <mailetpackage>org.apache.james.transport.mailets</mailetpackage>
	 <!-- This is the new line -->
         <mailetpackage>mymailets</mailetpackage>
      </mailetpackages>
And this:
<processor name="transport">
	<mailet match="RecipientIs=user123@somewhere.com" mailet="SimpleMailet"/>
	...

14) Restart james - you should see your mailet in action. 

Note: I suggest a very simple mailet for starters. Try modifying the subject 
line or something similar. This will give you the positive feedback to move 
forward.

I hope this helps. Please keep asking questions, but please be specific about 
what you're doing and why. I use IDEA, too, so maybe I'll play around with 
debugging the Phoenix source. But try this simple example, and I think you'll 
start to understand a bit more.

Also, you might want to read:
http://jakarta.apache.org/site/idedevelopers.html
It's got some useful tips.

Hope this helps,
ciao
Daz


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Debug startup of James

Posted by Kenny Smith <ke...@journalscape.com>.
Hey Tom,

The thing is though, a .sar file is NOT a .jar or a .war. Your .war file 
is assumed to have a WEB-INF directory with specific information in it. 
A sar file doesn't have that structure, so it's not that they just gave 
it a different name, it is a different thing. They tried to follow the 
convention of the filename.?ar pattern. We've got jar, war, ear... sar 
makes perfect sense.

I understand it causes problems for you when debugging... does IDEA 
support ant? Perhaps you can add the commands to update your sar and bar 
files before you debug.

Kenny Smith
JournalScape.com

Tom wrote:

> ----Original Message-----
> From: Noel J. Bergman [mailto:noel@devtech.com]
> Sent: Monday, December 09, 2002 11:43 AM
> To: James Users List
> Subject: RE: Debug startup of James
>
> Tom,
>
>
> >Why are things such as SAR and BAR files?   I know they are just Java
> >Archive files, but it makes working with Avalon/Phoenix/James, etc. a
> >pain with an IDE because they only (AFAIK with IDEA) only recognize
>
> .JAR
>
> >files.
>
>
> The SAR file is the Avalon project's idea of how to package
> applications,
> just as the Servlet folks defined a WAR file.  And there should only be
> a
> SAR file with James v2.1.  And I don't recommend working with any other
> version.
>
> I don't want to turn this into a philosophical discussion, but I was
> just questioning why someone chose to create a custom extension.  While
> it makes sense for the application in question, it creates all sorts of
> compatibility "blips" in the market.  For example, my problem of having
> to create duplicate SAR files (one named SAR and one named JAR) just so
> my particular IDE (IDEA in this case) can compile everything.
>
> Granted, there are always ways around it, and the WAR extension, if I am
> not mistaken is a SUN/Java standard, which makes it a little bit higher
> in the "acceptance chain" (in my book) for applications to support it
> (heck, it's part of a standard).
>
> I guess I was just frustrated when I came along the SAR, and BAR stuff.
> It just slowed me down in development, and created a sloppier
> environment for me (having to remember if the SAR or BAR was updated at
> some point, to copy them over to supported extensions).  I guess I could
> use links, but...
>
> Thanks,
>
>
>
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Debug startup of James

Posted by "Noel J. Bergman" <no...@devtech.com>.
> I don't want to turn this into a philosophical discussion, but I was
> just questioning why someone chose to create a custom extension.

You'd have to ask the Avalon folks (avalon-user@apache.org).  We are
consumers of the technology.

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Debug startup of James

Posted by Tom <li...@rcn.com>.
----Original Message-----
From: Noel J. Bergman [mailto:noel@devtech.com] 
Sent: Monday, December 09, 2002 11:43 AM
To: James Users List
Subject: RE: Debug startup of James

Tom,

> Why are things such as SAR and BAR files?   I know they are just Java
> Archive files, but it makes working with Avalon/Phoenix/James, etc. a
> pain with an IDE because they only (AFAIK with IDEA) only recognize
.JAR
> files.

The SAR file is the Avalon project's idea of how to package
applications,
just as the Servlet folks defined a WAR file.  And there should only be
a
SAR file with James v2.1.  And I don't recommend working with any other
version.

I don't want to turn this into a philosophical discussion, but I was
just questioning why someone chose to create a custom extension.  While
it makes sense for the application in question, it creates all sorts of
compatibility "blips" in the market.  For example, my problem of having
to create duplicate SAR files (one named SAR and one named JAR) just so
my particular IDE (IDEA in this case) can compile everything.

Granted, there are always ways around it, and the WAR extension, if I am
not mistaken is a SUN/Java standard, which makes it a little bit higher
in the "acceptance chain" (in my book) for applications to support it
(heck, it's part of a standard).

I guess I was just frustrated when I came along the SAR, and BAR stuff.
It just slowed me down in development, and created a sloppier
environment for me (having to remember if the SAR or BAR was updated at
some point, to copy them over to supported extensions).  I guess I could
use links, but...

Thanks,




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Debug startup of James

Posted by "Noel J. Bergman" <no...@devtech.com>.
Tom,

> Why are things such as SAR and BAR files?   I know they are just Java
> Archive files, but it makes working with Avalon/Phoenix/James, etc. a
> pain with an IDE because they only (AFAIK with IDEA) only recognize .JAR
> files.

The SAR file is the Avalon project's idea of how to package applications,
just as the Servlet folks defined a WAR file.  And there should only be a
SAR file with James v2.1.  And I don't recommend working with any other
version.

> Basically all I am doing is trying to write a matcher/mailet that
> detects if an email comes to say, user123@mycompany.com I want to
> act on it and have my Java mailet code take the complete email
> message and do something with (put it my own proprietary database).

The matcher exists (RecipientIs), and the mailet is pretty straightforward
to author.  Alternatively, you might use the existing support within James
to store e-mail in the database, and then have a custom view.  Depends upon
your needs.

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Debug startup of James

Posted by Danny Angus <da...@apache.org>.
it is possible to debug james in eclipse here's a rough guide...

1/ checkout and build James from cvs (I haven't tried it any other way)

2/ the main class is org.apache.avalon.phoenix.launcher.Main

3/ you have to add all the following jars to the cp

-- every jar in 
jakarta-james/lib
jakarta-james/bin
jakarta-james/bin/lib
and jakarta-james/build/lib

this will get every jar required.

you might add the classes dir from /build instead of the build/lib/jars


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Debug startup of James

Posted by Tom <li...@rcn.com>.
Why are things such as SAR and BAR files?   I know they are just Java
Archive files, but it makes working with Avalon/Phoenix/James, etc. a
pain with an IDE because they only (AFAIK with IDEA) only recognize .JAR
files.  

After figuring this out, I ended up just making copies of the BAR, SAR
files and giving them JAR extensions (so the IDEA compiler wouldn't
complain).

Is there something I am missing here?  Is remote debugging the only way
to "cleanly" (and I use that term EXTREMELY loosely here) to compile and
debug a James project.  This means, not having to rename or copy
existing files that are shipped with James?

Tom
-----Original Message-----
From: Darrell DeBoer [mailto:darrell@apache.org] 
Sent: Sunday, December 08, 2002 7:01 PM
To: James Users List
Subject: Re: Debug startup of James

On Mon, 9 Dec 2002 08:08, Tom wrote:
> Darrell DeBoer <da...@apache.org> wrote:
> Basically all I am doing is trying to write a matcher/mailet that
> detects if an email comes to say, user123@mycompany.com I want to act
on
> it and have my Java mailet code take the complete email message and do
> something with (put it my own proprietary database).
>
> As my previous messages hints at, I still can't get James to run with
a
> sample someone posted yesterday.
>
> http://www.javaworld.com/javaworld/jw-10-2001/jw-1026-jamesmail_p.html
>
> I followed this example as best I could, but ended up with the errors
I
> mentioned in my previous message.

Hi Tom,

Following the exact instructions in this article may *not* work with the

latest version of James, because the deployment structure is different. 
Phoenix no longer expands the entire SAR file at the time of first
running 
(like it used to), Now, Phoenix reads jar files directly from within the
SAR 
file, so you need to make sure that your jar file (with your mailet) is 
bundled in the James.sar file.

>From my last message:
>> As far as I'm aware, the only way to get your Mailet to run is to
bundle it
>> up into the James.sar file. You should be able to add your
MyMailet.jar to
>> the lib directory of James.sar, or just add the class files directly
to
>> James.jar. (I haven't tried the former, but it should work).
>>
>> Have a look at the "sar" target of build.xml to get an idea of how to
>> bundle everything into a sar file.
>>
>> I know this is a less than perfect solution, and probably something
we'll
>> want to address in James3.

>
> One more question regarding Phoenix do you any IDE for debugging (like
> JBuilder or IDEA)?  What do I exactly run when I want to debug James,
> but with Phoenix?  Is it a Phoenix project then?

I've debugged Phoenix in IDEA using remote debugging. To make this work
you 
need to do 2 things:
1) uncomment the lines in phoenix.sh (or phoenix.bat) that enable remote

debugging: ie
	rem uncomment to get enable remote debugging
	rem set DEBUG=-Xdebug 
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y

2) Set up your ide to remote debug, using the specified config. I'm sure
you 
can find details on how to set up remote debugging with your IDE on
google.

3) Oh, and you'll need to hope that Phoenix was compiled with debugging
info 
included. I haven't tried the jars that are in the latest version of
James. 
If they don't include debugging info, you'll need to build Phoenix 
yourself....

-- 
ciao,
Daz

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Debug startup of James

Posted by Darrell DeBoer <da...@apache.org>.
On Mon, 9 Dec 2002 08:08, Tom wrote:
> Darrell DeBoer <da...@apache.org> wrote:
> Basically all I am doing is trying to write a matcher/mailet that
> detects if an email comes to say, user123@mycompany.com I want to act on
> it and have my Java mailet code take the complete email message and do
> something with (put it my own proprietary database).
>
> As my previous messages hints at, I still can't get James to run with a
> sample someone posted yesterday.
>
> http://www.javaworld.com/javaworld/jw-10-2001/jw-1026-jamesmail_p.html
>
> I followed this example as best I could, but ended up with the errors I
> mentioned in my previous message.

Hi Tom,

Following the exact instructions in this article may *not* work with the 
latest version of James, because the deployment structure is different. 
Phoenix no longer expands the entire SAR file at the time of first running 
(like it used to), Now, Phoenix reads jar files directly from within the SAR 
file, so you need to make sure that your jar file (with your mailet) is 
bundled in the James.sar file.

>From my last message:
>> As far as I'm aware, the only way to get your Mailet to run is to bundle it
>> up into the James.sar file. You should be able to add your MyMailet.jar to
>> the lib directory of James.sar, or just add the class files directly to
>> James.jar. (I haven't tried the former, but it should work).
>>
>> Have a look at the "sar" target of build.xml to get an idea of how to
>> bundle everything into a sar file.
>>
>> I know this is a less than perfect solution, and probably something we'll
>> want to address in James3.

>
> One more question regarding Phoenix do you any IDE for debugging (like
> JBuilder or IDEA)?  What do I exactly run when I want to debug James,
> but with Phoenix?  Is it a Phoenix project then?

I've debugged Phoenix in IDEA using remote debugging. To make this work you 
need to do 2 things:
1) uncomment the lines in phoenix.sh (or phoenix.bat) that enable remote 
debugging: ie
	rem uncomment to get enable remote debugging
	rem set DEBUG=-Xdebug 
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y

2) Set up your ide to remote debug, using the specified config. I'm sure you 
can find details on how to set up remote debugging with your IDE on google.

3) Oh, and you'll need to hope that Phoenix was compiled with debugging info 
included. I haven't tried the jars that are in the latest version of James. 
If they don't include debugging info, you'll need to build Phoenix 
yourself....

-- 
ciao,
Daz

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Debug startup of James

Posted by Tom <li...@rcn.com>.
Darrell DeBoer <da...@apache.org> wrote:
>What exactly are you doing? Phoenix used to ignore the user-defined
>classpath - probably still does. Have you tried putting mailet.jar in
the 
>same location as mymailet.jar? 

First off thanks for the help so far, I think I understand it a little
better, but Phoenix still confuses me (but we can let that go...)

Basically all I am doing is trying to write a matcher/mailet that
detects if an email comes to say, user123@mycompany.com I want to act on
it and have my Java mailet code take the complete email message and do
something with (put it my own proprietary database).

As my previous messages hints at, I still can't get James to run with a
sample someone posted yesterday.

http://www.javaworld.com/javaworld/jw-10-2001/jw-1026-jamesmail_p.html

I followed this example as best I could, but ended up with the errors I
mentioned in my previous message.

One more question regarding Phoenix do you any IDE for debugging (like
JBuilder or IDEA)?  What do I exactly run when I want to debug James,
but with Phoenix?  Is it a Phoenix project then?  

Thanks,

Tom



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Debug startup of James

Posted by Darrell DeBoer <da...@apache.org>.
Hi Tom,

On Mon, 9 Dec 2002 04:58, Tom Dietz wrote:
> Is there someone out there that is using IDEA (or any GUI debugger) that
> can give me a brief explanation of how I can debug everything.   I have
> had IDEA for about a month now, so I am very new to that, but is there a
> main project file that can contain all the other projects.

If you want to debug the phoenix source code, you'll need to download the 
phoenix source. I *think* this is the right place to get the source version 
which matches the Phoenix version in James.

http://jakarta.apache.org/builds/jakarta-avalon-phoenix/release/v4.0.1/

I'm not sure if the Avalon-Framework source is included. If not, you'll 
probably also want to get:
http://jakarta.apache.org/builds/jakarta-avalon/release/framework/latest/

In both cases, you'll want the file marked ".src.zip".

>
> The main reason for this (among other important ones) is I still don't
> understand how phoenix loads James.   I have look at the run.bat (I am
> Windows) and see that it passes in a special loader class, but what
> happens then?  Is everything dynamically loaded based upon XML file
> configurations?

Once you have the Phoenix source, you should be able to debug the entire 
startup process.

> The last reason why I would like to debug (at least the startup) is I am
> trying to add a very basic mailet (as described in this arcticle:
>
> http://www.javaworld.com/javaworld/jw-10-2001/jw-1026-jamesmail_p.html
>
> And can't james to start in the debugger when my mailet is included in
> the config.xml (it starts fine without it).
>
> I traced it down to this error in phoenix's log:
>
> 1039373134293 [ERROR  ] (Phoenix.kernel.james.lifecycle): Block named
> "spoolmanager" failed to pass through the Initialization stage. (Reason:
> java.lang.NoClassDefFoundError: org/apache/mailet/GenericMailet).

If I'm not mistaken, it looks like you're putting your Mailet class files (or 
jar) into the lib or ext directory of the Phoenix install. What's happening 
is that Phoenix can find your mailet fine, but Mailet.jar is not visible in 
the same classloader as your Mailet is loaded. (Mailet.jar is loaded by a 
James-specific classloader, which is a child of the Phoenix classloader, 
where your Mailet is loaded). When loading your Mailet, Phoenix is looking 
for GenericMailet.class, and can't find it, so throws this exception. 

It could also be more complex than this - I haven't looked at Phoenix for 
ages, and I think the classloader stuff has had some significant changes.

As far as I'm aware, the only way to get your Mailet to run is to bundle it up 
into the James.sar file. You should be able to add your MyMailet.jar to the 
lib directory of James.sar, or just add the class files directly to 
James.jar. (I haven't tried the former, but it should work). 

Have a look at the "sar" target of build.xml to get an idea of how to bundle 
everything into a sar file.

I know this is a less than perfect solution, and probably something we'll want 
to address in James3.

> I have made sure mailet.jar is in (and high) in the classpath, but still
> get this error.

What exactly are you doing? Phoenix used to ignore the user-defined classpath 
- probably still does. Have you tried putting mailet.jar in the same location 
as mymailet.jar? 

> I hope this all makes sense.

Absolutely. I hope this all helps.

-- 
ciao,
Daz

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>