Tengo un problema intentando aplicar lo que publican en este link pero con mysql, ya que con derby funciona sin problemas:
http://www.dosideas.com/noticias/jav...java-ee-6.html
Revise el puerto de mysql, hice un test con el jar de mysql en el servidor creando un pool de forma normal(Osea a mano) y todo sin problemas, intente cambiar los tipos de alcance del datasource a nivel de app, modulo y global...pero nada.
SERVIDOR: Glassfish 3.x
Código:
Como lo veo, no ha podido crear nada y retorna error solo al intentar accesarlo...@DataSourceDefinition(name = "java:app/mysql/TESTDB", className = "com.mysql.jdbc.jdbc2.optional.MysqlDataSource", portNumber = 3306, serverName = "localhost", databaseName = "testDB", user = "root", password = "", properties = {"createDatabaseIfNotExist=true"} ) @WebServlet(name = "MySqlTestServlet", urlPatterns = {"/MySqlTestServlet"}) public class MySqlTestServlet extends HttpServlet { private ServletContext context; @Resource(lookup = "java:app/mysql/TESTDB") private DataSource ds; @EJB private String dbName; @Override public void init(ServletConfig config) throws ServletException { try { context = config.getServletContext(); Connection con = ds.getConnection(); DatabaseMetaData dbmd = con.getMetaData(); dbName = dbmd.getDatabaseProductName(); Statement stmt = con.createStatement(); try {
Un saludo.
Descripcion:
The server encountered an internal error () that prevented it from fulfilling this request.
Ex. ERROR:
javax.servlet.ServletException: PWC1392: Error instantiating servlet class DS.MySqlTestServlet
Causa Raiz:
com.sun.enterprise.container.common.spi.util.Injec tionException: Error creating managed object for class: class DS.MySqlTestServlet
Causa Raiz:
com.sun.enterprise.container.common.spi.util.Injec tionException: Exception attempting to inject Remote ejb-ref name=DS.MySqlTestServlet/dbName,Remote 3.x interface =java.lang.String,ejb-link=null,lookup=,mappedName=,jndi-name=java.lang.String,refType=Session into class DS.MySqlTestServlet: Lookup failed for 'java:comp/env/DS.MySqlTestServlet/dbName' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterpr ise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.pr esentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.na ming}
Causa Raiz:
javax.naming.NamingException: Lookup failed for 'java:comp/env/DS.MySqlTestServlet/dbName' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterpr ise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.pr esentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.na ming} [Root exception is javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=DS.MySqlTestServlet/dbName,Remote 3.x interface =java.lang.String,ejb-link=null,lookup=,mappedName=,jndi-name=java.lang.String,refType=Session' . Actual (possibly internal) Remote JNDI name used for lookup is 'java.lang.String#java.lang.String' [Root exception is javax.naming.NamingException: Lookup failed for 'java.lang.String#java.lang.String' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterpr ise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.pr esentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.na ming} [Root exception is javax.naming.NameNotFoundException: java.lang.String#java.lang.String not found]]]
Causa Raiz:
javax.naming.NameNotFoundException: java.lang.String#java.lang.String not found