DataSorce usando Eclipse + Lomboz + JBoss - HELP!

0 respostas
woquiton

Várias pessoas já tentaram me ajudar, mas tô zicado…
Quero fazer um DataSorce usando Eclipse + Lomboz + JBoss.

Seguinte… usando as ferramentas acima, criei um Project com Módulo EJB e um WEB, criei um pacote br.com.empresa.DAO, aqui eu queria criar um OracleDAOFactory.java, que retornasse uma Connection. Nesta classe, tento fazer o lookup da variável oracleDS. A idéia é chama esta classe, se a conexao nao for “null”, então mostra um OK no console.

:arrow: Configurei um arquivo oracle-ds.xml, coloquei em $JBOSS_HOME/server/default/deploy (Iniciou o servidor sem mostrar erro). Coloque o driver em $JBOSS_HOME/server/default/lib .
:arrow: Configurei até o $JBOSS_HOME/server/default/conf/standardjaws.xml , substitui default por oracle:

<datasource>java:/oracleDS</datasource>
<type-mapping>Oracle</type-mapping>
<debug>false</debug>

:arrow: A minha classe OracleDAOFactory está assim:

package br.com.empresa.DAO;

import java.sql.Connection;
import java.util.Properties;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.sql.DataSource;

public class OracleDAOFactory {

static DataSource ds;
static Connection con;

private static DataSource initDataSource() throws Exception { 
   InitialContext jndiCtx = new InitialContext(); 
   Context envCtx = (Context) jndiCtx.lookup("java:"); 
   String dataSourceName = (String) envCtx.lookup("oracleDS"); 
   return (DataSource) jndiCtx.lookup(dataSourceName); 
}

public static Connection createConnection(){

	try{
		/*
		//Já tentei assim
		Context ctx = new InitialContext();
		DataSource ds = (DataSource)ctx.lookup("java:/oracleDS");
		
		
		DataSource ds = initDataSource();  
		
		*/
		
		/*
		
		//Já tentei assim também: 
		 
		 /*
		Properties prop = System.getProperties();
		prop.put( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
		prop.put( "java.naming.provider.url","localhost:1099");
		prop.put( "java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

		Context context = new InitialContext(prop);
		DataSource ds = (DataSource)context.lookup("oracleDS");
		*/
		
		//E normal:
		
		Context ctx = new InitialContext(); 
		DataSource ds = (DataSource) ctx.lookup("oracleDS");
		//Já fiz lookup com java:/oracleDS java:oracleDS java:comp/env.. só oracleDS
		//de todo jeito 
		
		
		if (ds != null){
			con = ds.getConnection();
		}else{
			throw new Exception();
		}
			
	}catch(Exception e){
		e.printStackTrace();
	}

return con;

}

}

:arrow: O erro retornado é null:

javax.naming.NameNotFoundException: oracleDS not bound

:arrow: Na inicialização do servidor, ele nao fica not bound:

15:29:24,375 INFO [oracleDS] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=LocalTxCM,name=oracleDS to JNDI name ‘java:/oracleDS’
15:29:24,375 INFO [TxConnectionManager] Started

:arrow: No final ocorrem umas falhas:
MBeans waiting for other MBeans:
[ObjectName: jboss.web:service=WebServer
state: FAILED
I Depend On:
Depends On Me: jboss.mq:service=InvocationLayer,type=HTTP
LifecycleException: Protocol handler initialization failed: java.net.BindException: Address already in use: JVM_Bind:8080, ObjectName: jboss.mq:service=InvocationLayer,type=HTTP
state: CONFIGURED
I Depend On: jboss.mq:service=Invoker
jboss.web:service=WebServer

Depends On Me: , ObjectName: jboss.mq:service=InvocationLayer,type=OIL
state: FAILED
I Depend On: jboss.mq:service=Invoker

Depends On Me: java.net.BindException: Address already in use: JVM_Bind, ObjectName: jboss.mq:service=InvocationLayer,type=UIL
state: FAILED
I Depend On: jboss.mq:service=Invoker

Depends On Me: java.net.BindException: Address already in use: JVM_Bind, ObjectName: jboss.mq:service=InvocationLayer,type=OIL2
state: FAILED
I Depend On: jboss.mq:service=Invoker

Depends On Me: java.net.BindException: Address already in use: JVM_Bind, ObjectName: jboss.mq:service=InvocationLayer,type=UIL2
state: FAILED
I Depend On: jboss.mq:service=Invoker

Depends On Me: java.net.BindException: Address already in use: JVM_Bind]
15:29:28,843 INFO [URLDeploymentScanner] Started
15:29:28,921 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1/server/default/conf/jboss-service.xml
15:29:28,921 INFO [Server] JBoss (MX MicroKernel) [3.2.1 (build: CVSTag=JBoss_3_2_1 date=200305041533)] Started in 18s:140ms

:arrow: o oracle-ds.xml tá configurado assim:

<datasources>

<local-tx-datasource>

<jndi-name>oracleDS</jndi-name>

<connection-url>jdbc:oracle:thin:@172.16.12.1:1521:SDES</connection-url>

<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>

DES

<password>DES</password>

<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

</local-tx-datasource>

</datasources>

:arrow: Por fim: :roll: Alguém pode me ajudar ?? Alguém que já tenha usado, ou usa, entende da integração destas ferramentas, pois eu executo no próprio eclipse (Run as… Java Application)

Criado 11 de novembro de 2003
Respostas 0
Participantes 1