0

I am studying the tutorial javarevoltions JSF 2 + PrimeFaces 5 + 4 + Spring Hibernate 4.

Essse tutorial is based on weblogic server and Oracle database.

My problem is I want to use glassfish with MySQL instead.

There is a file called utilidades.java containing webologic properties.

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;

public class Utilities {
    public static Object getEJBRemote (nameEJB String, String iface) throws Exception {
    Context context;

    Properties props = new Properties ();
    props.put (Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    props.put (Context.PROVIDER_URL, "http: // localhost: 7001");
    try {
        context = new InitialContext (props);
        String lookup nameEJB + = "#" + iface;
        System.out.println ("Lookup" + lookup);
        return context.lookup (lookup);
    } Catch (Exception ex) {
        throw new Exception ("There is EJB: '" + nameEJB + "'.");
    }
    }
}

I've changed to:

props.put (Context.INITIAL_CONTEXT_FACTORY, "org.springframework.jndi.JndiObjectFactoryBean");
props.put (Context.PROVIDER_URL, "http: // localhost: 4848");

This I saw a tutorial on the Internet, using glassfish and mysql. I created the ping successfully datasource in glassfish.

When I do a debbug it appears:

ex = (javax.naming.NoInitialContextException) javax.naming.NoInitialContextException: Can not instantiate class: org.springframework.jndi.JndiObjectFactoryBean [Root exception is java.lang.ClassCastException: org.springframework.jndi.JndiObjectFactoryBean can not be cast to javax.naming .spi.InitialContextFactory]

What am I doing wrong?

Micho
  • 3,929
  • 13
  • 37
  • 40

1 Answers1

0

Your problem is that weblogic.jndi.WLInitialContextFactory is not an InitialContextFactory. I think the value you want for Glassfish is com.sun.enterprise.naming.SerialInitContextFactory:

 Properties props = new Properties ();
    props.put (Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
    props.put (Context.PROVIDER_URL, "http: // localhost: 7001");

This answer has more detail.

Community
  • 1
  • 1
hugh
  • 2,237
  • 1
  • 12
  • 25