Tutorial on J2EE using JBOSS-4.x, Eclipse-3.x, Lomboz-3.x an
jbosszone May 17, 2005 10:27 AMDear Vishal,
Cleared up to Chapter 3 (Stateless Session Bean) with following setup (a summary of info in various threads/ref.).
Your kind comments and/or advice would be appreciated.
Ref. : Your original thread : http://www.jboss.org/index.html?module=bb&op=viewtopic&t=36910
=== Environment:
- Windows XP SP2
- J2SDK 1.4.2_08
- Eclipse 3.0.2
- JBoss 4.0.2
- Lomboz 3.0.1 + emf-sdo-runtime-2.0.0
- PostgreSQL 8.0.3 (= DefaultDS)
Note : For download and installation of Eclipse, JBoss and Lomboz, see related docs/references for details.
: Axis 1.2 to be installed later
= Step 1: Download and install PostgreSQL (follow the Installer's instructions.)
- The directory is "C:/PostgreSQL".
- Add a user name ?postgres? with an own password "******".
= Step 2: Make a database in PostgreSQL
- Activate "pgAdmin III" for GUI session.
- Create a new database named "MyStoreDbPgSQL" for the tutorial.
- Make the tables and the data from myStoreSchema.script and myStoreSchema.data (see Chapter 1 of the tutorial).
e.g. copy and paste SQL codes in *.script and *.data files above.(add ";" to each end of SQL codes)
= Step 3: Add a directory as a new server option
- Copy the complete directory of ?all? under "C:/JBoss-4.0.2/server" and name it "postgres".
/JBoss-4.0.2/server |- /all |- /default |- /minimal |- /postgres- Keep the directories "all", "default" & "minimal" un-touched.
- Delete all sub-directories and files under /server/postgres/log and /temp if any.
= Step 4: Install JDBC drivers for PostgreSQL
- Delete hsqldb.jar and hsqldb-plugin.jar in /server/postgres/lib.
- Copy following three *.jar files in C:/PostgreSQL/8.0/jdbc to /server/postgres/lib.
postgresql-8.0-311.jdbc2.jar
postgresql-8.0-311.jdbc2ee.jar
postgresql-8.0-311.jdbc3.jar
- Due to troubles in their names, modify them as follows;
postgresql-8.0.311.jdbc2.jar
postgresql-8.0.311.jdbc2ee.jar
postgresql-8.0.311.jdbc3.jar
= Step 5: Prepare a Server Definition File for Lomboz to start up JBoss in Eclipse
- Make a copy of "jboss32x.server" in "C:/eclipse/plugins/com.objectlearn.jdt.j2ee_3.0.1/servers" as "jboss402postgres.server".
- Add ".bak" to all other "*.server" files in the same directory except for "jboss402postgres.server".
- Modify "jboss402postgres.server" file.
- A preliminary shape is as follows. (also see other samples in other threads/ref.)
<serverDefinition name="JBOSS 4.0.2 PgSQL" ejbModules="true" webModules="true" earModules="true"> <property id="serverRootDirectory" label="Application Server Directory:" type="directory" default="C:/jboss-4.0.2" /> <property id="serverAddress" label="Address:" type="string" default="127.0.0.1" /> <property id="serverPort" label="Port:" type="string" default="8080" /> <property id="serverConfig" label="Server Configuration (minimal/default/all/postgres):" type="string" default="postgres" /> <property id="classPathVariableName" label="Classpath Variable Name:" type="string" default="JBOSS402" /> <property id="classPath" label="Classpath Variable:" type="directory" default="C:/jboss-4.0.2" /> <serverHome>${serverRootDirectory}</serverHome> <webModulesDeployDirectory>${serverRootDirectory}/server/${serverConfig}/deploy</webModulesDeployDirectory> <ejbModulesDeployDirectory>${serverRootDirectory}/server/${serverConfig}/deploy</ejbModulesDeployDirectory> <earModulesDeployDirectory>${serverRootDirectory}/server/${serverConfig}/deploy</earModulesDeployDirectory> <jndiInitialContextFactory>org.jnp.interfaces.NamingContextFactory</jndiInitialContextFactory> <jndiProviderUrl>jnp://${serverAddress}:1099</jndiProviderUrl> <startClass>org.jboss.Main</startClass> <startWorkingDirectory>${serverRootDirectory}/bin</startWorkingDirectory> <startVmParameters>-Dprogram.name=run.bat -Djava.endorsed.dirs=${serverRootDirectory}/bin/../lib/endorsed -Xms128m -Xmx512m</startVmParameters> <startProgramArguments>-c ${serverConfig}</startProgramArguments> <stopClass>org.jboss.Shutdown</stopClass> <stopWorkingDirectory>${serverRootDirectory}/bin</stopWorkingDirectory> <stopVmParameters>-cp ${classPathVariableName}/bin/shutdown.jar -Djboss.boot.loader.name=shutdown.bat</stopVmParameters> <stopProgramArguments>-S</stopProgramArguments> <serverClassPath> <jar type="variable">JDK_TOOLS</jar> <jar type="variable">${classPathVariableName}/bin/run.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/postgresql-8.0.311.jdbc3.jar</jar> </serverClassPath> <clientClassPath> <jar type="variable">${classPathVariableName}/client/jboss-j2ee.jar</jar> <jar type="variable">${classPathVariableName}/client/jnp-client.jar</jar> <jar type="variable">${classPathVariableName}/client/jboss-client.jar</jar> <jar type="variable">${classPathVariableName}/client/jboss-common-client.jar</jar> <jar type="variable">${classPathVariableName}/client/jbosssx-client.jar</jar> <jar type="variable">${classPathVariableName}/client/log4j.jar</jar> <jar type="variable">${classPathVariableName}/client/jnet.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jnpserver.jar</jar> <jar type="variable">${classPathVariableName}/client/jboss-jaas.jar</jar> </clientClassPath> <projectClassPath> <jar type="variable">JDK_TOOLS</jar> <jar type="variable">${classPathVariableName}/bin/run.jar</jar> <jar type="variable">${classPathVariableName}/bin/shutdown.jar</jar> <jar type="variable">${classPathVariableName}/client/jboss-j2ee.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/javax.servlet.jar</jar> <jar type="variable">${classPathVariableName}/lib/jboss-system.jar</jar> <jar type="variable">${classPathVariableName}/lib/concurrent.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jboss.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jnpserver.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jpl-pattern.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jpl-util.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jboss-transaction.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/bcel.jar</jar> <jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/postgresql-8.0.311.jdbc3.jar</jar> </projectClassPath> <adminTool> <web><deploy /><undeploy /> </web> <ejb><deploy /><undeploy /> </ejb> <ear><deploy /><undeploy /> <webModule><deploy /><undeploy /> </webModule> <ejbModule><deploy /><undeploy /> </ejbModule> </ear> </adminTool> <adminToolPath> </adminToolPath> </serverDefinition>= Step 6: Prepare the Service Description File
- Delete "/server/postgres/deploy/hsqldb-ds.xml".
- Copy "postgres-ds.xml" in "/jboss-4.0.2/docs/examples/jca" to "/server/postgres/deploy"
- In "postgres-ds.xml", the contents of <local-tx-datasource> are as follows;
<jndi-name>DefaultDS</jndi-name> <connection-url>jdbc:postgresql://localhost/MyStoreDbPgSQL</connection-url> <driver-class>org.postgresql.Driver</driver-class> <user-name>postgres</user-name> <password>******</password> <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> <metadata> <type-mapping>PostgreSQL 8.0</type-mapping> </metadata>
= Step 7: Modify following three files for the postgres configuration to be fully J2EE 1.4 compliant.
Ref. : "What?s New in JBoss AS 4.0" (section 2.1) http://docs.jboss.org/jbossas/whatsnew40/pdf/whatsnew40.pdf
1. /server/postgres/conf/jboss-service.xml --> set the NamingService (JNDI) CallByValue to "true"
2. /server/postgres/deploy/ear-deployer.xml --> set the Isolated and CallByValue attributes to "true"
3. /server/postgres/deploy/jbossweb-tomcat55.sar/META-INF/jboss-service.xml --> confirm the Java2ClassLoadingCompliance and UseJBossWebLoader attributes to "false"
= Step 8: Modify the JBoss Login Config File (/server/postgres/conf/login-config.xml)
- Activate "Security domain for JBossMQ when using file-state-service.xml" section.
- Make a copy of "Security domains for testing new jca framework" (HsqlDbRealm) section and name it "PostgresDbRealm".
- Comment out the HsqlDbRealm section which is for "Hypersonic SQL".
- The <application-policy> for PostgresDbRealm is as follows;
<!-- Security domains for testing new jca framework --> <application-policy name = "PostgresDbRealm"> <authentication> <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required"> <module-option name = "principal"></module-option> <module-option name = "userName">postgres</module-option> <module-option name = "password">******</module-option> <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option> </login-module> </authentication> </application-policy>
= Step 9: Modify "standardjaws.xml"
- In "/server/postgres/conf/standardjaws.xml", the top parts of are as follows;
<jaws> <datasource>java:/DefaultDS</datasource> <type-mapping>PostgreSQL</type-mapping> <debag>false</debug> <default-entity> :
= Step 10: Modify "standardjbosscmp-jdbc.xml"
- In "/server/postgres/conf/standardjbosscmp-jdbc.xml", the top parts are as follows;
<jbosscmp-jdbc> <defaults> <datasource>java:/DefaultDS</datasource> <datasource-mapping>PostgreSQL</datasource-mapping> <!-- optional since 4.0 <datasource-mapping>Hypersonic SQL</datasource-mapping> --> <create-table>true</create-table> :
= Step 11: Add ".bak" to disable "/jms" folder under "/server/postgres/deploy".
= Step 12: Arrange "/server/postgres/deploy-hasingleton/jms" folder instead of "/server/postgres/deploy/jms.bak" (Step 11)
- Delete hsqldb-jdbc2-service.xml and hsqldb-jdbc-state-service.xml. (Note : Addition of ".bak" for disabling is not effective.)
- Copy following three files in "C:/jboss-4.0.2/docs/examples/jms" to "/server/postgres/deploy-hasingleton/jms".
oil-service.xml
postgres-jdbc3-service.xml
rmi-il-service.xml
- Modify the jdbc3 Persistence Manager section of postgres-jdbc3-service.xml as follows; (i.e. : ...=DataSourceBinding, name=PostgresDS --> name=DefaultDS ...)
: | If you encouter problems with the configured BLOB_TYPE try a different | setting. Valid settings are OBJECT_BLOB, BINARYSTREAM_BLOB and BYTES_BLOB. --> <mbean code="org.jboss.mq.pm.jdbc3.PersistenceManager" name="jboss.mq:service=PersistenceManager"> <depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name=DefaultDS</depends> <attribute name="SqlProperties"> BLOB_TYPE=BYTES_BLOB :
*** Start Eclipse and build a new project as MyStorePgSQL.
= Step 13: Edit "xdoclet.xml" for PostgreSQL
- In "/MyStorePgSQL/MyStoreMgr/META-INF/xdoclet.xml", the JBoss part is as follows;
: <jboss version="4.0" : datasource="java:/DefaultDS" datasourcemapping="PostgreSQL" preferredrelationmapping="foreign-key" /> :
= Step 14: Start JBoss from the "Lomboz J2EE View" tag in Eclipse.
--------------------
Regards,
jbosszone