jndi

Need help understanding JNDI and a particular ClassCastException in J2EE

与世无争的帅哥 提交于 2019-12-12 12:27:22
问题 I have an enterprise application A and B deployed (in WLS 10.0). A is the "framework", B is a client app. The client issues the following calls: Object o = ctx.lookup(jndiName); // line 1 cf = (ConnectionFactory) o; // line 2 ConnectionFactory is an interface, defined as: public interface ConnectionFactory extends java.io.Serializable, javax.resource.Referenceable { ... } What happens is: If the jar containing the interface class is on the system classpath, line 2 is executed fine If the

@EJB injection fails but JNDI lookup works in web service class in Glassfish

﹥>﹥吖頭↗ 提交于 2019-12-12 12:24:57
问题 I have a @WebService class that injects an @EJB. The EJB is packaged in a .jar file which is in the same .war file as the web service classes. The @EJB injection always fails, but I can do a JNDI lookup on the EJB. I've tried making the EJB and its interface @Remote, but that didn't matter. Injection still fails and JNDI lookup still works. I'm using a version 3.0 web.xml. There's no ejb deployment descriptor in the ejb.jar file, but that is not suppose to matter in EJB 3.1. An I missing

Where can I get (matching) sources for com.sun.jndi.ldap.* packages?

老子叫甜甜 提交于 2019-12-12 12:07:07
问题 I am on JDK6_u26 and don't find com.sun.jndi.ldap package sources as part of sources.zip. I believe they could be available from OpenJDK6 project, but I am not sure; and I am reading that the sources don't match the binaries in some cases. Can someone shed some light as to how to get the sources (and if possible,exact matching the JDK binary build) for these packages for attaching them in the debugger? A URL link/pointer would be great... Thanks a lot in advance! 回答1: See here, "Java SE 6 JDK

How to limit number of rows returned from Oracle at the JDBC data source level?

末鹿安然 提交于 2019-12-12 11:57:19
问题 Is there a way to limit the rows returned at the Oracle datasource level in a Tomcat application? It seems maxRows is only available if you set it on the datasource in the Java code. Putting maxRows="2" on the datasource doesn't apply. Is there any other way limit the rows returned? Without a code change? 回答1: It isn't something that is available at the configuration level. You may want to double check that it does what you want it to do anyway: see the javadoc for setMaxRows. With Oracle it

What is JBOSS- “Empty name segment is not allowed for java” error

大憨熊 提交于 2019-12-12 11:24:17
问题 I am newbee to JBOSS developement and tring to run a project from eclipse but I am getting "Empty name segment is not allowed for java" error. I know such error comes when our jndi resource name is empty but in such case it specifies as "env" and not "java" which is in my case. Posting my stacktrace below. I am using JBOSS 7.1 version. 14:34:04,440 WARN [org.jboss.as.ee] (MSC service thread 1-5) JBAS011001: Could not resolve resource-env-ref java:/TransactionManager 14:34:04,440 ERROR [org

JBoss 7: JNDI lookup

纵然是瞬间 提交于 2019-12-12 10:44:49
问题 after quite a while I made the remote access to a stateless EJB run under JBoss 7.1.1. using Properties object: Properties jndiProps = new Properties(); jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4447"); jndiProps.put(Context.SECURITY_PRINCIPAL, "remote"); jndiProps.put(Context.SECURITY_CREDENTIALS, "remotepwd"); jndiProps.put("jboss.naming.client.ejb.context", true); Context

How to list all JNDI entries in “java:global” namespace

时光总嘲笑我的痴心妄想 提交于 2019-12-12 10:42:57
问题 Goal is to list all the JNDI entries programmatically. new InitialContext().list("java:global") doesn't work. EJB 3.1, Wildfly or Glassfish 4 回答1: I think that the safer way to navigate in JNDI namespace is first to lookup its root and then list its content. I've tried this way in WildFly 8.1.0 and it worked : Context root = (Context) new InitialContext().lookup("java:global"); NamingEnumeration<NameClassPair> names = root.list(""); 来源: https://stackoverflow.com/questions/26463970/how-to-list

Jetty: adding <resource-env-ref> programmatically

心已入冬 提交于 2019-12-12 09:18:38
问题 I have a standalone application with embedded Jetty and Wicket. I'd like to use CDI for injection. So I've found http://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#d0e5286 and now I'm trying to add this programatically, but it's quite complex. How do I code that? Other sources I've found are: http://osdir.com/ml/java.jetty.support/2007-02/msg00198.html http://docs.codehaus.org/display/JETTY/JNDI So far I have: Server server = new Server( 8080 ); Context ctx = new Context

JNDI lookup works fine using lookUp but not when used in persistence.xml of JPA

别说谁变了你拦得住时间么 提交于 2019-12-12 08:23:43
问题 I am using tomcat connection pool, jpa, hibernate. The datasource i created in context.xml of tomcat works fine if I try to get it using : source = (DataSource) ((Context) c.lookup("java:comp/env")).lookup("jdbc/kids"); but if i specify this jndi datasource in persistence.xml <persistence-unit name="kids-tomcat" transaction-type="JTA"> <jta-data-source>jdbc/kids</jta-data-source> </persistence-unit> I am getting following exception: org.hibernate.service.jndi.JndiException: Unable to lookup

Weblogic: Call DB2 stored procedure without schema name (property currentSchema)

穿精又带淫゛_ 提交于 2019-12-12 08:03:21
问题 I have a Java application that runs on Weblogic. The application needs to access a stored procedure in a DB2 data base, therefore a JDBC data source is configured and accessed by its JNDI name. Data source: ClassDriver: com.ibm.db2.jcc.DB2Driver Properties: user=MYUSER DatabaseName=MYDB The following example works as expected. Context env = null; DataSource pool = null; Hashtable ht = new Hashtable(); ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); ht.put