Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > J2EE on MacOSX

J2EE on MacOSX
Thread Tools
Mac Enthusiast
Join Date: Dec 2002
Location: Amsterdam, Netherlands
Status: Offline
Reply With Quote
Apr 5, 2003, 08:12 AM
 
I want to setup a J2EE environment on my TiBook, but am a little bit stumped (?) on how to do it...

I know you'll need Tomcat and Apache, but am not really sure what the role of JBoss is in this picture.

What is the difference with JBoss and Tomcat?

Is there any extensive tutorial how to setup an environment like this and link it all together?

I know the one on developer.apple.com, but that is a little bit outdated I think.

I'm using Eclipse as a Java IDE and probably will stay using that.

Anyway: Some tips from da pro's plz
I'm Appleless and unhappy: tiBook is dead and iPod stolen
     
Dedicated MacNNer
Join Date: Oct 2000
Location: Washington, DC
Status: Offline
Reply With Quote
Apr 5, 2003, 07:22 PM
 
J2EE isn't really any one specific program. Its more of a concept of various packages under the javax tree.

Servlets, JSP, JDBC and EJBs are usually the most commonly used J2EE components and you can install whatever packages/applications you need to use.

Tomcat would get you Servlets/JSP, but if you also wanted EJB, then you'd have to use JBoss instead of Tomcat.
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Apr 5, 2003, 10:29 PM
 
As posted above J2EE is a collection ("mess") of technologies. Anyway, MacOSX is a decent platform for J2EE development. It baffles me that Apple doesn't push this... This is were the money is for Java development. Be as it may, anything that is built on 100% java runs justs fine.

Without going throught the whole J2EE mumbo-jumbo let me just say that the key technologies are JSP, Servlets and EJBs. The first two require a web container such as Tomcat and the latter requires an EJB container such as JBOSS. You don't need Apache, unless you want higher performance for static html.

Below are some of my experiences with various packages on MacOSX:

TOMCAT + JBOSS
The problem with those two, is integration: tomcat and JBOSS are two different packages with overlapping functionality and although you can download an integrated version of JBOSS & Tomcat, the whole deal is kind of fuzzy and at least a couple of months ago the documentation was not all that it should be.

TOMCAT + OPENEJB
This is one is very well-integrated but OpenEJB implements EJB 1.1 and not the latest 2.1 specs -which I need. Still, this is really good combination. Apple uses OpenEJB for integrating EJBs into WebObjects.


JRUN4
By far, my best experience and what I currently use with wonderful results. It works REALLY WELL and both the web and ejb containers are very well integrated and up to date with the latest specs. The downside is that it's worth about $800. The upside is that you can download a developer version for free -with time limitations and perhaps some other constraints that render it unsuited for production. In any event, it's definitely adequate for development work. I can't say anything that's remotely negative about it.

DATABASES
Get a hold of a good database i.e., Oracle or Postgres and if the system is simple enough (zero transactions) then MySQL is yet another option.

Finally, get ready... Learning J2EE is a real challenge! There's a lot to learn and to experiment with. Learning it on MacOSX eases the pain greatly.
Get yourself a good book and start with just JSPs and Servlets. For this, a standalone version of Tomcat is all you need. Once you graduate from those technologies and want to mess with EJBs then get JBOSS or JRUN4.

Good luck

PS: I run on a 17" iMac 800MHZ, 256RAM and haven't found an IDE that I like. So I use BBedit and ANT and I'm perfectly content.
(Last edited by DaGuy; Apr 5, 2003 at 11:03 PM. )
     
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Apr 6, 2003, 03:53 AM
 
Hi am am reading Java Server Pages, from O'Reilly, and it is really good, one of the best J2EE books to start with also as up to date as you can get compared to other books.

My question is what is the real difference between a Servlets and JavaBeans, since both are just types of class files with rules on how they are coded, what is the difference, between them, are they interchangeable or are they truly different and why.

I am interested from the prospective of the Model View Controller paradigm. Why is a bean a bean and a servlet and servlet?

What have I missed?
     
Ilja  (op)
Mac Enthusiast
Join Date: Dec 2002
Location: Amsterdam, Netherlands
Status: Offline
Reply With Quote
Apr 6, 2003, 07:18 AM
 
Thanks for the good advice! I'm fairly experienced with java programming, just never had set up any j2ee environment. I am not really a unix-geek and it seems that for configuring jboss, tomcat (setting all the classpaths and stuff like that) you need some experience for that. But you've been very helpfull..

And btw 'DaGuy', have you tried eclipse? I think it's really powerfull. Once you get to know it, I think you can't get any better for free. It also has plugins for j2ee, tomcat, struts etc...
I'm Appleless and unhappy: tiBook is dead and iPod stolen
     
Ilja  (op)
Mac Enthusiast
Join Date: Dec 2002
Location: Amsterdam, Netherlands
Status: Offline
Reply With Quote
Apr 6, 2003, 08:15 AM
 
the main thing that bugs me is setting all those classpaths (for jdk, tomcat, jboss, ant, postgresql etc...)

setenv... doesn't work system-wide, doesn't persist... Isn't there a unix commando which sets classpaths and environment variables permanent and system-wide, without using a .tcsh file or something?
I'm Appleless and unhappy: tiBook is dead and iPod stolen
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Apr 6, 2003, 10:02 AM
 
Originally posted by depolitic:
Hi am am reading Java Server Pages, from O'Reilly, and it is really good, one of the best J2EE books to start with also as up to date as you can get compared to other books.

My question is what is the real difference between a Servlets and JavaBeans, since both are just types of class files with rules on how they are coded, what is the difference, between them, are they interchangeable or are they truly different and why.

I am interested from the prospective of the Model View Controller paradigm. Why is a bean a bean and a servlet and servlet?

What have I missed?
A Servlet is Java server side technology that needs to run in a well-defined environment called a container. This is what Tomcat provides, amongst other things. Servlets are typically used for routing and any work that requires a request/response dialog. Any utility type work i.e., validation, get/set data that does not need request/response is handled by a bean.

A bean from a J2EE perspective is just a regular Java class that generally impements the serializable interface and has setter/getter methods and in some cases some simple logic for validation and database access. In principle such an object does not need to be associated with a container. Don't confuse this notion of beans with JavaBeans which have nothing to do with J2EE. Those are meant to be visual components that parallel ActiveX components in Windows.

There are two other key J2EE technologies. JSPs are really disguised servlets that are embedded with HTML just like PHP and CGI.
Given that JSPs are just a friendly face on Servlets, they need to run in a web container i.e., Tomcat. The other big technology is Enterprise Java Beans (EJBs).

In a J2EE sense, EJBs are meant to handle deep business logic and completely abstract the database. They come in four flavors:

Stateless Session Beans: meant to carry out a service and not hold state i.e., credit card, validation, get a stock quote etc. There life is tied to a single request.

Statefull Session Beans: these can hold state and there life is tied to the user session. They are meant to handle business logc.

Entity Beans: These are real heavyweights and are meant to handle transactions and database entity abstraction. They model nouns i.e., bank account, customer order etc. They need to be associated with a database and either implement a container managed or bean managed persistence model.

The best beginner's book on JSP/Servlet is "Visual JSP". It just has step by step code examples meant to get you going quickly. The next one is the first "Java Server Pages" by Geary -he wrote two books a basic one and an advanced one.

For EJBs, I recommend "Mastering Enterprise Beans" by Roman and others and for a deeper no nonsense approach I suggest the O'Rielly "Enterprise JavaBeans" y Monson-Haefel.

J2EE is huge, I haven't mentioned JDBC, JNDI, JMS, JMX etc. Like I mentioned in my prior post. Stick to JSPs and Servlets that should get you going. For that, all you need is Tomcat.
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Apr 6, 2003, 10:08 AM
 
Originally posted by Ilja:
Thanks for the good advice! I'm fairly experienced with java programming, just never had set up any j2ee environment. I am not really a unix-geek and it seems that for configuring jboss, tomcat (setting all the classpaths and stuff like that) you need some experience for that. But you've been very helpfull..

And btw 'DaGuy', have you tried eclipse? I think it's really powerfull. Once you get to know it, I think you can't get any better for free. It also has plugins for j2ee, tomcat, struts etc...
I tried Eclipse once and it certainly looked nice and it seemed plenty capable. I'll visit it again and see what happens. After you get used to a simple text editor with just syntax coloring and line numbering (BBedit) and an extremely powerful tool like ANT then most IDEs seem real bloated and lead to nonportable habits -from and IDE to and another IDE sense. But I'll go try out Eclipse again, I keep hearing good things about it.
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Apr 6, 2003, 10:20 AM
 
Originally posted by Ilja:
the main thing that bugs me is setting all those classpaths (for jdk, tomcat, jboss, ant, postgresql etc...)

setenv... doesn't work system-wide, doesn't persist... Isn't there a unix commando which sets classpaths and environment variables permanent and system-wide, without using a .tcsh file or something?
setenv is not system wide. It just belongs to terminal that executes it. What you need to do is (assuming that you are using the default tcsh shell) is either put the the sentenvs in the .login or .tcshrc files. The .login is "User" wide and the .tcshrc is read when you launch a terminal session. I placed all my setenvs and set paths in my ~/.tcshrc file (you need to create one if it doesn't already exist). Some folks prefer the ~/.login file. So far I haven't had any problems with my setup.

Here's a snipplet:

# ------------------------------------ ANT ---------------------------------------
set path = ($path /usr/local/jakarta-ant-1.5.1/bin)
setenv ANT_HOME /usr/local/jakarta-ant-1.5
setenv CLASSPATH ${CLASSPATH}:/usr/local/jakarta-ant-1.5.1/lib/ant.jar


# ---------------------------------- JBOSS -------------------------------------
setenv JBOSS_HOME /usr/local/jboss-3.0.4
     
Ilja  (op)
Mac Enthusiast
Join Date: Dec 2002
Location: Amsterdam, Netherlands
Status: Offline
Reply With Quote
Apr 6, 2003, 11:10 AM
 
yeah, I did that allready, but then some other problems arise: these paths only apply if you open a terminal right? can't you make a script like that that's executed when you startup your computer?

Anyway: for now I installed the following:

- Apache (allready installed with mac osx)
- Tomcat
- JBoss
- Postgresql

Problems:

- how to configure postgresql and jboss as a system startup service?
- how to integrate all those services alltogether? I have found documentation around mod_jk etc, but all those things involve heavy commandline/file operations. Aren't there any userfriendly ways of doing it?
- any recommended gui-clients for the above packages?
I'm Appleless and unhappy: tiBook is dead and iPod stolen
     
Ilja  (op)
Mac Enthusiast
Join Date: Dec 2002
Location: Amsterdam, Netherlands
Status: Offline
Reply With Quote
Apr 6, 2003, 12:03 PM
 
When starting JBoss I get numerous warnings and errors... Info is left out by substituting it with (...)

Code:
18:52:09,831 ERROR [WebService] Starting failed java.net.BindException: Address already in use (...) 18:52:09,900 WARN [ServiceController] Problem starting service jboss:service=Webserver java.net.BindException: Address already in use (...) 18:52:10,267 ERROR [NamingService] Could not start on port 1099 java.net.BindException: Address already in use (...) 18:52:10,779 ERROR [JRMPInvoker] Failed java.rmi.server.ExportException: Port already in use: 4444; nested exception is: (...) 18:52:11,935 INFO [STDOUT] Server.run/init: java.net.BindException: Address already in use 18:52:11,937 ERROR [STDERR] java.net.BindException: Address already in use 18:52:11,938 ERROR [STDERR] at java.net.PlainSocketImpl.socketBind(Native Method) 18:52:11,940 ERROR [STDERR] at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:331) 18:52:11,941 ERROR [STDERR] at java.net.ServerSocket.bind(ServerSocket.java:309) 18:52:11,943 ERROR [STDERR] at java.net.ServerSocket.<init>(ServerSocket.java:183) 18:52:11,944 ERROR [STDERR] at java.net.ServerSocket.<init>(ServerSocket.java:95) 18:52:11,945 ERROR [STDERR] at org.hsqldb.Embedded_Server.run(Embedded_Server.java:145) 18:52:11,946 ERROR [STDERR] at org.hsqldb.Embedded_Server.main(Embedded_Server.java:92) 18:52:11,948 ERROR [STDERR] at org.jboss.jdbc.HypersonicDatabase$2.run(HypersonicDatabase.java:186) (...) 18:52:13,966 ERROR [OILServerILService] Starting failed java.net.BindException: Address already in use (...) 18:52:13,983 WARN [ServiceController] Problem starting service jboss.mq:service=InvocationLayer,type=OIL java.net.BindException: Address already in use (...) 18:52:14,000 ERROR [UILServerILService] Starting failed java.net.BindException: Address already in use (...) 18:52:14,017 WARN [ServiceController] Problem starting service jboss.mq:service=InvocationLayer,type=UIL java.net.BindException: Address already in use (...) 18:52:14,843 ERROR [MainDeployer] could not create deployment: file:/Library/JBoss/jboss-3.0.6/server/default/deploy/tomcat41-service.xml org.jboss.deployment.DeploymentException: instantiating org.jboss.web.catalina.EmbeddedCatalinaService41 failed: java.lang.NoClassDefFoundError: org/apache/catalina/Context; (...) 18:52:14,866 ERROR [URLDeploymentScanner] Failed to deploy: org.jboss.deployment.scanner.URLDeploymentScanner$DeployedURL@726415fe{ url=file:/Library/JBoss/jboss-3.0.6/server/default/deploy/tomcat41-service.xml, deployedLastModified=0 } org.jboss.deployment.DeploymentException: instantiating org.jboss.web.catalina.EmbeddedCatalinaService41 failed: java.lang.NoClassDefFoundError: org/apache/catalina/Context; - nested throwable: (RuntimeErrorException: instantiating (...) 18:52:17,111 WARN [ServiceController] Problem starting service jboss.j2ee:jndiName=ejb/mgmt/MEJB,service=EJB java.rmi.ServerException: Could not bind home; nested exception is: javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: object not exported] (...) 18:52:17,936 WARN [ServiceController] Problem starting service jboss.j2ee:jndiName=ejb/jmx/ejb/Adaptor,service=EJB java.rmi.ServerException: Could not bind home; nested exception is: javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: object not exported] (...) 18:52:18,060 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()' Cause: Incomplete Deployment listing: (...)
I'm Appleless and unhappy: tiBook is dead and iPod stolen
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Apr 6, 2003, 12:53 PM
 
Hey Ilja, are you sure you don't want to take things one step at a time?

You are really chewing on a lot of things simultaneosly. You will not be able to avoid using the command line. That's were all the fun is. It's painful at the beginning but well worth the time.

Below are some further comments.

DATABASE:
Instead of Postgres I would start out with MySQL.

http://www.apple.com/downloads/macos...letemysql.html

not that Postgres is bad or anything like that I just rembeer having an easier time with MySQL.

The package above does allow you to configure MySQL as a startup service. There are many books on the market for both MySQL and Postgres so you may want to pick one up. The web tutorials that I found were kinda hokey and not very serious.

CONTAINER(S)
If you are not dealing with EJBs then you don't need JBOSS. The JBOSS + Tomcat package is not that straightforward. My suggestion is to at first forget about JBOSS and just install Tomcat from:

http://apache.mirrorcentral.com/dist...at-4/binaries/

I suggest the package:

tomcat-4.1.24.tar.gz

This will get you JSPs and Servlets. Most J2EE books will use a standalone Tomcat for JSP/Servlet examples. You don't even need the database to start the learning process.

The JBOSS errors that you are getting appear to be related to JBOSS wanting to use ports that are already in use. Perhaps by the same version of Tomcat that comes with it. That dual combination is not a good beginning experience. You may also want to forget about Apache and mod_Jk etc. Tomcat can serve you webpages just as Apache can.

As far as your classpath. Have you tried the .login? And login in and out of the system. Can you give me a step-by-step example on how you are intending to use the CLASSPATH variable i.e., launching apps, javac etc. Perhaps we can work this out.

later

(Last edited by DaGuy; Apr 6, 2003 at 01:15 PM. )
     
Ilja  (op)
Mac Enthusiast
Join Date: Dec 2002
Location: Amsterdam, Netherlands
Status: Offline
Reply With Quote
Apr 6, 2003, 01:30 PM
 
I know mysql (have installed it allready) and have enough experience with it, but prefere postgres due to the better tsql-support.

But until know I have apache, tomcat and postgres succesfully running (mod_jk is setup as well), am only looking for a startup script for postgres.

Anyway: I want to try out EJB's so guess I need JBoss and hope one of you can solve this startup problem with it
I'm Appleless and unhappy: tiBook is dead and iPod stolen
     
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Apr 6, 2003, 08:05 PM
 
Thanks DaGuy for your explanation

All these component make up J2EE so t perform specialised task with in J2EE.

It seems however that for most simple non enterprise projects. A Simple combination of JSP and Servlets can do most if not all tasks.

Can it be said that all these J2EE technologies are only useful for large and complex sister where scaleability, and long term maintainability is a major concern?

If I am just building a simple but solid member system, or a guest book, JSP and Servlet will perform admirably.

Sun is claiming that J2EE is to complex, and will be simplifying the technology in coming release of J2EE. I hope it gets simpler.
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Apr 6, 2003, 08:50 PM
 
Below is the java classpath script I use. I use Bourne shell (bash), but it should work with ksh or zsh as well (csh or tcsh users will need to translate).

In my .bash_profile, I source this script with " . ~/bin/setup_java_environment.sh"

Code:
#!/bin/sh # BEGIN JAVA CLASSPATH SETUP JAVA_BASE="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK" export JAVA_HOME="$JAVA_BASE/Home" CLASSPATH="." # TOMCAT if [ "$CATALINA_HOME" = "" ]; then CATALINA_HOME="/Library/WebServer/jakarta-tomcat-4.1.18" CH=$CATALINA_HOME export CATALINA_HOME fi OS_JARS="$JAVA_BASE/Classes" TOMCAT_JARS="$CH/common/lib/servlet.jar \ $CH/common/lib/velocity.jar \ $CH/common/lib/velocity-dep.jar \ $CH/common/lib/mail.jar" MY_JARS="$HOME/Library/Java $HOME/Library/Java/Extensions" javasourcelist="$OS_JARS $MY_JARS $TOMCAT_JARS" for javasource in $javasourcelist do if [ -d $javasource ]; then #it is a directory for jarfile in `cd ${javasource} && ls | grep jar` do if [ "$CLASSPATH" = "" ]; then CLASSPATH="${javasource}/${jarfile}" else CLASSPATH="${CLASSPATH}:${javasource}/${jarfile}" fi done elif [ -f $javasource ]; then # it is a file if [ "$CLASSPATH" = "" ]; then CLASSPATH="${javasource}" else CLASSPATH="${CLASSPATH}:${javasource}" fi fi done export CLASSPATH
As you can see, it's easy to add in more stuff as you need it by adding files or folders of jars to javasourcelist. HTH.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Apr 7, 2003, 01:00 AM
 
Originally posted by depolitic:
Thanks DaGuy for your explanation

All these component make up J2EE so t perform specialised task with in J2EE.

It seems however that for most simple non enterprise projects. A Simple combination of JSP and Servlets can do most if not all tasks.

Can it be said that all these J2EE technologies are only useful for large and complex sister where scaleability, and long term maintainability is a major concern?

If I am just building a simple but solid member system, or a guest book, JSP and Servlet will perform admirably.

Sun is claiming that J2EE is to complex, and will be simplifying the technology in coming release of J2EE. I hope it gets simpler.
Glad I could help. I agree with your assessment. JSP and Servlet pack a big punch. You should be fine with just those two.

Good luck!

     
Forum Regular
Join Date: Jan 2003
Location: Jersey City, NJ
Status: Offline
Reply With Quote
Apr 16, 2003, 09:21 PM
 
Originally posted by DaGuy:
I tried Eclipse once and it certainly looked nice and it seemed plenty capable. I'll visit it again and see what happens. After you get used to a simple text editor with just syntax coloring and line numbering (BBedit) and an extremely powerful tool like ANT then most IDEs seem real bloated and lead to nonportable habits -from and IDE to and another IDE sense. But I'll go try out Eclipse again, I keep hearing good things about it.
One of the features of Eclipse that I like most is code-refactor. It would be hard to have this done in a text editor.
PB.17.1Ghz - iPod.10G
     
Mac Elite
Join Date: Nov 2001
Status: Offline
Reply With Quote
Apr 17, 2003, 03:42 PM
 
Originally posted by javabeans:
One of the features of Eclipse that I like most is code-refactor. It would be hard to have this done in a text editor.
Yep. Intellij does a better job of that, fwiw. Only 5 more days (or so they say... looks like they've pushed back the date) until version 3 will run on OS X (I use it on XP and it's great):

http://www.intellij.com/idea/download.jsp
     
Ilja  (op)
Mac Enthusiast
Join Date: Dec 2002
Location: Amsterdam, Netherlands
Status: Offline
Reply With Quote
Apr 17, 2003, 04:03 PM
 
Originally posted by CatOne:
Yep. Intellij does a better job of that, fwiw. Only 5 more days (or so they say... looks like they've pushed back the date) until version 3 will run on OS X (I use it on XP and it's great):

http://www.intellij.com/idea/download.jsp
but it isn't free which I like of Eclipse

afaik Eclipse has most of what IDEA has and more, since it is pluggable
I'm Appleless and unhappy: tiBook is dead and iPod stolen
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:21 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2