Template project
cristiv Oct 10, 2002 6:00 AMHi!
Attention!
I'm very beginner in jboss! (jboss3.0)
I'm tring to connect to postgres using the example "Template".
Now, step by step:
1)postgres driver is in: c:\jboss\server\default\lib\jdbc7.0-1.1.jar
2)postgres-service.xml in c:\jboss\server\default\deploy\postgres-service.xml
with this content:
<?xml version="1.0" encoding="UTF-8" ?>
-
-
- <!--
uncomment out this line if you are using the PostgresDbRealm above
UKontaktRealm
-->
- <depends optional-attribute-name="ManagedConnectionFactoryName">
- <!--
embedded mbean
-->
-
UKontakt
-
-
<config-property name="ConnectionURL" type="java.lang.String">jdbc:postgresql://192.168.1.135:5432/inv</config-property>
<config-property name="DriverClass" type="java.lang.String">org.postgresql.Driver</config-property>
<config-property name="UserName" type="java.lang.String">postgres</config-property>
<config-property name="Password" type="java.lang.String">ps</config-property>
- <!--
Below here are advanced properties
-->
- <!--
hack
-->
<depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper
- <!--
real attributes
-->
- <depends optional-attribute-name="ManagedConnectionPool">
- <!--
embedded mbean
-->
-
0
50
5000
15
- <!--
criteria indicates if Subject (from security domain) or app supplied
parameters (such as from getConnection(user, pw)) are used to distinguish
connections in the pool. Choices are
ByContainerAndApplication (use both),
ByContainer (use Subject),
ByApplication (use app supplied params only),
ByNothing (all connections are equivalent, usually if adapter supports
reauthentication)
-->
ByContainer
<depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
<depends optional-attribute-name="JaasSecurityManagerService">jboss.security:name=JaasSecurityManager
java:/TransactionManager
- <!--
make the rar deploy! hack till better deployment
-->
jboss.jca:service=RARDeployer
3)
If I'm looking with Agent View (http://localhost:8082/)
I have:
jboss.jca
· service=LocalTxCM,name=UKontaktDS
· service=LocalTxCM,name=hsqldbDS
· service=LocalTxDS, name=UKontaktDS
· service=LocalTxDS,name=hsqldbDS
· service=LocalTxPool,name=UKontaktDS
· service=LocalTxPool,name=hsqldbDS
· service=RARDeployer
· service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper
· service=RARDeployment,name=JMS Adapter
· service=RARDeployment,name=Minerva JDBC XATransaction ResourceAdapter
· service=XaTxCM,name=jmsra
· service=XaTxDS,name=jmsra
· service=XaTxPool,name=jmsra
In section:
JndiName ---> java.lang.String--->UKontakt
4)
On the server side (jboss) I have:
14:41:28,700 INFO [Server] JBoss (MX MicroKernel) [3.0.0 Date:200205311035]
Sta
rted in 0m:53s:490ms
14:41:48,750 INFO [MainDeployer] Starting deployment of package:
file:/C:/jboss
/server/default/deploy/postgres-service.xml
14:41:49,300 WARN [ServiceController] jboss.jca:service=LocalTxDS,
name=UKontak
tDS does not implement any Service methods
14:41:49,300 INFO [JBossManagedConnectionPool] Creating
14:41:49,300 INFO [JBossManagedConnectionPool] Created
14:41:49,300 INFO [LocalTxConnectionManager] Creating
14:41:49,360 INFO [LocalTxConnectionManager] Created
14:41:49,360 INFO [JBossManagedConnectionPool] Starting
14:41:49,360 INFO [JBossManagedConnectionPool] Started
14:41:49,360 INFO [LocalTxConnectionManager] Starting
14:41:50,070 INFO [UKontakt] Bound connection factory for resource adapter
'JBo
ss LocalTransaction JDBC Wrapper' to JNDI name 'java:/UKontakt'
14:41:50,130 INFO [LocalTxConnectionManager] Started
14:41:50,130 INFO [MainDeployer] Successfully completed deployment of
package:
file:/C:/jboss/server/default/deploy/postgres-service.xml
5)The source of client is:
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package test.client;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import test.interfaces.TestSession;
import test.interfaces.TestSessionHome;
public class TestClient {
public static void main(String[] args){
try {
InitialContext lContext = new InitialContext();
// TestSessionHome lHome = (TestSessionHome) lContext.lookup( "ejb/test/TestSession" );
TestSessionHome lHome = (TestSessionHome) lContext.lookup( "java:comp/env/jdbc/UKontaktDB" );
TestSession lSession = lHome.create();
// Get a new Id of the Test Entity
int lId = lSession.getNewEntityId();
System.out.println( "New Entity Id is: " + lId );
lSession.remove();
} catch( Exception e ){
e.printStackTrace();
}
}
}
6)The compilation is ok
Buildfile: build.xml
check-environment:
check-jboss:
wrong-jboss:
check-xdoclet:
wrong-xdoclet:
init:
[echo] build.compiler = ${build.compiler}
[echo] user.home = C:\WINDOWS
[echo] java.home = C:\JDK1.4\JRE
[echo] ant.home = c:\ant
[echo] jboss.home = C:/jboss
[echo] xdoclet.home = C:/xdoclet
[echo] java.class.path = c:\jdk1.4\lib\tools.jar;c:\ant\lib\XML-APIS.JAR;c:
\ant\lib\XERCES~1.JAR;c:\ant\lib\OPTIONAL.JAR;c:\ant\lib\ANT.JAR;
xdoclet-generate:
[ejbdoclet] Generating Javadoc
[ejbdoclet] Javadoc execution
[ejbdoclet] Loading source file C:\awork\template\src\main\ejb\test\session\Sequ
enceGeneratorBean.java...
[ejbdoclet] Loading source file C:\awork\template\src\main\ejb\test\session\Test
SessionBean.java...
[ejbdoclet] Loading source file C:\awork\template\src\main\ejb\test\message\Test
MessageDrivenBean.java...
[ejbdoclet] Loading source file C:\awork\template\src\main\ejb\test\entity\TestE
ntityBean.java...
[ejbdoclet] Constructing Javadoc information...
[ejbdoclet] Running
[ejbdoclet] Running
[ejbdoclet] Running
[ejbdoclet] Running
[ejbdoclet] Running
[ejbdoclet] Running
[ejbdoclet] Running
compile:
jar:
compile-web:
war:
deploy-server:
create-client:
[echo] JBoss Home on Unix: C:/jboss
[echo] Java Home on Unix: C:/JDK1.4/JRE
main:
BUILD SUCCESSFUL
Total time: 47 seconds
7) When I-m tring to run the application I have the error message:
javax.naming.NameNotFoundException: comp not bound
C:\JDK1.4\JRE\bin\java.exe -classpath ".;C:\jboss\client\JNP-CL~1.JAR;C:\jboss\c
lient\GNU-RE~1.JAR;C:\jboss\client\JNET.JAR;C:\jboss\client\JBOSS-~1.JAR;C:\jbos
s\client\CONCUR~1.JAR;C:\jboss\client\JBOSSM~1.JAR;C:\jboss\client\JBOSSS~1.JAR;
C:\jboss\client\JCERT.JAR;C:\jboss\client\JMX-EJ~1.JAR;C:\jboss\client\LOG4J.JAR
;C:\jboss\client\JMX-RM~1.JAR;C:\jboss\client\JACORB.JAR;C:\jboss\client\JBOSSM~
2.JAR;C:\jboss\client\JBOSS-~2.JAR;C:\jboss\client\JBOSS-~3.JAR;C:\jboss\client\
JAAS.JAR;C:\jboss\client\JMX-CO~1.JAR;C:\jboss\client\JBOSSH~1.JAR;C:\jboss\clie
nt\JBOSS-~4.JAR;C:\jboss\client\JBOSS-~5.JAR;C:\jboss\client\JSSE.JAR;C:\jboss\c
lient\JBOSS-~6.JAR;C:\jboss\client\JBOSS-~7.JAR;..\client\CLIENT~1.JAR" test.cli
ent.TestClient
javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:536)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:445)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:429)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at test.client.TestClient.main(TestClient.java:22)
8)
I thing that I have some trouble with jboss.xml
This is the content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
<enterprise-beans>
<message-driven>
<ejb-name>UserMessageEJB</ejb-name>
<destination-jndi-name>jms/UMQueue</destination-jndi-name>
<resource-ref>
<res-ref-name>mail/MailSession</res-ref-name>
<jndi-name>java:/Mail</jndi-name>
</resource-ref>
</message-driven>
<message-driven>
<ejb-name>MailRegEJB</ejb-name>
<destination-jndi-name>jms/Queue</destination-jndi-name>
<resource-ref>
<res-ref-name>jdbc/UKontaktDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/UKontakt</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>mail/MailSession</res-ref-name>
<jndi-name>java:/Mail</jndi-name>
</resource-ref>
</message-driven>
<ejb-name>LogInEJB</ejb-name>
<jndi-name>ejb/Login</jndi-name>
<resource-ref>
<res-ref-name>jdbc/UKontaktDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/UKontakt</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>mail/MailSession</res-ref-name>
<jndi-name>java:/Mail</jndi-name>
</resource-ref>
</enterprise-beans>
<resource-managers>
<!-- DB
<resource-manager res-class="javax.sql.DataSource">
<res-name>UKontaktDB</res-name>
<res-jndi-name>jdbc/UKontakt</res-jndi-name>
</resource-manager>
-->
<!-- Mail session
<resource-manager res-class="javax.mail.Session">
<res-name>mail/MailSession</res-name>
<res-jndi-name>java:/Mail</res-jndi-name>
<mail-configuration>
Stefan
<mail-from>stefan.kuehn@gmx.net</mail-from>
<mail-host>192.168.1.135</mail-host>
</mail-configuration>
</resource-manager>
-->
</resource-managers>
Where must be this file and if is right?
What am i doing wrong?
I attached entired project!