aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes eclipse + postgreSQL + JBoss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "eclipse + postgreSQL + JBoss" Watch "eclipse + postgreSQL + JBoss" New topic
Author

eclipse + postgreSQL + JBoss

Pragati Ogal
Greenhorn

Joined: Apr 02, 2004
Posts: 2
Hi,
I am using lomboz, eclipse, JBoss 3.2.3 and postgreSQL 7.4.1 for my J2EE project. I have configured JBoss to use postgreSQL as the database. When I run JBoss from the command line, I can see the jmx-console and can run my CMP EJBs. But when I do "debug server" from within eclipse, I get the following errors.
For jmx-console, I get the error:
HTTP Error 500
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
.............

And in the server I see these exceptions:
22:39:29,334 INFO [EjbModule] Deploying AvailabilityCMP
22:39:29,444 INFO [EjbModule] Deploying ScreenNameFacade
22:39:29,504 INFO [EjbModule] Deploying AvailabilityFacade
22:39:30,275 ERROR [EntityContainer] Starting failed
org.jboss.deployment.DeploymentException: Error: can't find data source: java:/PostgresDS; - nested throwable: (javax.naming.NameNotFoundException: PostgresDS not bound)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.init(JDBCEntityBridge.java:143)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.in
..........

In the jboss323.server file, I have:

<serverDefinition
name="JBOSS 3.2.3"
ejbModules="true"
webModules="true"
earModules="true">
<property id="serverRootDirectory"
label="Application Server Directory:"
type="directory"
default="C:/jboss-3.2.3/" />
<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):"
type="string"
default="all" />
<property id="classPathVariableName"
label="Classpath Variable Name:"
type="string"
default="JBOSS323" />
<property id="classPath"
label="Classpath Variable:"
type="directory"
default="C:/jboss-3.2.3" />

and in the xdoclet.xml I have :
<jboss
version="3.2"
xmlencoding="UTF-8"
destdir="${ejb.dd.dir}"
validatexml="false"
datasource="java:/PostgresDS"
datasourcemapping="PostgreSQL"
preferredrelationmapping="foreign-key"
/>
Please help me. Please suggest what I need to do. I am struggling with this problem for a long time now.
Thanks,
Pragati
Ade Barkah
Ranch Hand

Joined: Mar 17, 2004
Posts: 65
For some reason the Postgresql datasource isn't getting deployed by the server. Were there any other Postgres related errors in the log on startup?
Make sure the basics are covered...
1) Check that you have a valid postgres-ds.xml file within the ./server/default/deploy directory:
postgres-ds.xml: (substitude own dbname, username & password)

2) Ensure that there is a copy of JBoss' JDBC library ('pg73jdbc3.jar' or newer) in ./server/default/lib.
3) Start the server manually and double check that the PostgresDS datasource gets deployed properly.
4) Make sure Eclipse is starting the instance at ./server/default and not some other instance.
hth,
-Ade Barkah


-Ade<br /><a href="http://www.barkah.org" target="_blank" rel="nofollow">www.barkah.org</a>
Amit Ghai
Ranch Hand

Joined: Mar 24, 2004
Posts: 35
Here is how to go about. hope this helps.

Procedure for configuring postgres database to the application in Jboss.
Same way can be used to configure other databases too.
Kindly note the changes are to take place in the JBOSS only.
A data source is a Java Naming and Directory Interface (JNDI) object used to obtain a connection from a connection pool to a database. The default data source configured with JBoss is the HypersonicDB data source. To use another database, you need to modify jaws.xml or standardjaws.xml.
standardjbosscmp-jdbc.xml is the standard deployment descriptor to configure the JBoss CMP container. It can be replaced with a custom configuration version, called jbosscmp-jdbc.xml. As before, this file goes in the META-INF directory of the EJB .jar file. And once again, JBoss defaults to a Hypersonic version, in this case HypersonicDB cmp. To use another database, we need to edit this file. For all the examples below I am taking amit as user and password is blank.
Postgres Configuration
PostGres is a very popular enterprise database used for its performance and reliability. To configure JBoss with PostGres, we first need to put PostGres 's driver classes in the CLASSPATH. Copy PostGres 's JDBC driver .jar file /jdbc/lib/ pg73jdbc3.jar to the server/default/lib directory.
To use PostGres 's data source, copy /docs/examples/jca/ postgres-ds.xml to the /server/default/deploy directory.
Next, we need to modify the postgres-ds.xml configuration file. The <driver-class/> and <connection-url/> settings for postgres are as follows:
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/LiferayPool</jndi-name>
<connection-url>jdbc ostgresql://192.168.10.35:5432/portal</connection-url>;
<driver-class>org.postgresql.Driver</driver-class>
<user-name>amit</user-name>
<password></password>
<min-pool-size>0</min-pool-size>
</local-tx-datasource>
</datasources>
Next, we modify the standardjaws.xml or jaws.xml configuration file. Set the <datasource> and <type-mapping> elements as follows:
<jaws>
<datasource>java:/PostgresDS</datasource>
<type-mapping>postgresql</type-mapping>

</jaws>
Next, we modify the standardjbosscmp-jdbc.xml or jbosscmp-jdbc.xml configuration file, setting the <datasource> and <datasource-mapping> elements to use Postgres:
<jbosscmp-jdbc>
<defaults>
<datasource>java:/PostgresDS</datasource>
<datasource-mapping>postgresql</datasource-mapping>

</defaults>
</jbosscmp-jdbc>
Finally, we need to modify login-config.xml to use Postgres. Add the following <application-policy> element to login-config.xml:
<application-policy name = "PostgresDbRealm">
<authentication>
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
flag = "required">
<module-option name = "principal">amit</module-option>
<module-option name = "userName">amit</module-option>
<module-option name = "password"></module-option>
<module-option name =´┐ŻmanagedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=PostgresDS</module-option>
</login-module>
</authentication>
</application-policy>
By modifying the postgres -ds.xml, standardjaws.xml, standardjbosscmp-jdbc.xml, and login-config.xml files, the JBoss server is configured to be used with a Postgres database.

JBoss Deployment Descriptors for EJBs
standardjaws.xml is the standard deployment descriptor for the mapping of Container Managed Persistence (CMP) entity EJBs. To use a custom configuration for mapping CMP entity EJBs, you use the jaws.xml file instead. In both cases, the file is copied to the META-INF directory of the EJB .jar file. Whichever file is used configures the following: Specify a data source and a type mapping for the data source.
Specify how tables are built/used.
Define finder methods to access the entity beans.
Define type mappings.


Reasonable people adapt themselves to the world. Unreasonable people attempt to adapt the world to themselves. All progress, therefore, depends on unreasonable people.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: eclipse + postgreSQL + JBoss