Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Error loading context: unknown protocol: jndi

  1. #1

    Default Error loading context: unknown protocol: jndi

    I'm trying to use ContextSingletonBeanFactoryLocator for a shared factory. However, when I try load the context I get the following error:
    Code:
    Caused by: org.springframework.context.ApplicationContextException: I/O error parsing XML document for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=536608]; nested exception is java.net.MalformedURLException: unknown protocol: jndi
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:94)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:262)
    	at org.springframework.context.access.ContextSingletonBeanFactoryLocator.initializeDefinition(ContextSingletonBeanFactoryLocator.java:136)
    	at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:386)
    Caused by: java.net.MalformedURLException: unknown protocol: jndi
    	at java.net.URL.<init>&#40;URL.java&#58;544&#41;
    	at java.net.URL.<init>&#40;URL.java&#58;434&#41;
    	at java.net.URL.<init>&#40;URL.java&#58;383&#41;
    	at org.springframework.core.io.UrlResource.<init>&#40;UrlResource.java&#58;56&#41;
    	at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findAllClassPathResources&#40;PathMatchingResourcePatternResolver.java&#58;228&#41;
    	at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources&#40;PathMatchingResourcePatternResolver.java&#58;191&#41;
    	at org.springframework.context.support.AbstractApplicationContext.getResources&#40;AbstractApplicationContext.java&#58;661&#41;
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions&#40;AbstractXmlApplicationContext.java&#58;103&#41;
    	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions&#40;AbstractXmlApplicationContext.java&#58;71&#41;
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory&#40;AbstractRefreshableApplicationContext.java&#58;87&#41;
    It seems it has a problem with the jndi refs in the context I'm trying to reference. The weird thing is that I've been using this context file all along, just not via ContextSingletonBeanFactoryLocator.

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Can you post the problematic configuration?

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  3. #3

    Default

    beanRefContext.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    
    	<bean id="ejb-context" class="org.springframework.context.support.ClassPathXmlApplicationContext">
    		<constructor-arg>
    			<list>
    				<value>applicationContext_ejb.xml</value>
    			</list>
    		</constructor-arg>
    	</bean>
    
    </beans>
    applicationContext_ejb.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <!--
      - Application context definition
      - Accessing beans from business layer
      -->
    <beans>
    	<bean id="userDelegate" class="mil.navy.fvm.ejb.UserDelegate" singleton="false" >
    		<property name="service">
    			<ref local="userBean"/>
    		</property>
    	</bean>
    	<bean id="careerDelegate" class="mil.navy.fvm.ejb.CareerDelegate" singleton="false" >
    		<property name="service">
    			<ref local="careerBean"/>
    		</property>
    	</bean>  
    	<bean id="relationshipDelegate" class="mil.navy.fvm.ejb.RelationshipDelegate" singleton="false" >
    		<property name="service">
    			<ref local="relationshipBean"/>
    		</property>
    	</bean>
    	<bean id="statusDelegate" class="mil.navy.fvm.ejb.StatusDelegate" singleton="false" >
    		<property name="service">
    			<ref local="statusBean"/>
    		</property>
    	</bean>
    
    	<bean id="cacheDelegate" class="mil.navy.fvm.ejb.CacheDelegate" singleton="false" />
    
    	<!-- Stateless -->
        <bean id="userBean" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
            <property name="jndiName">
                <value>ejb/UserLocalHome</value>
            </property>        
            <property name="resourceRef">
                <value>true</value>
            </property>        
            <property name="businessInterface">
                <value>mil.navy.fvm.interfaces.IUser</value>
            </property>        
        </bean>
        <bean id="careerBean" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
            <property name="jndiName">
                <value>ejb/CareerLocalHome</value>
            </property>        
            <property name="resourceRef">
                <value>true</value>
            </property>        
            <property name="businessInterface">
                <value>mil.navy.fvm.interfaces.ICareer</value>
            </property>        
        </bean>
        <bean id="relationshipBean" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
            <property name="jndiName">
                <value>ejb/RelationshipLocalHome</value>
            </property>        
            <property name="resourceRef">
                <value>true</value>
            </property>        
            <property name="businessInterface">
                <value>mil.navy.fvm.interfaces.IRelationship</value>
            </property>        
        </bean>
        <bean id="statusBean" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
            <property name="jndiName">
                <value>ejb/StatusLocalHome</value>
            </property>        
            <property name="resourceRef">
                <value>true</value>
            </property>        
            <property name="businessInterface">
                <value>mil.navy.fvm.interfaces.IStatus</value>
            </property>        
        </bean>
    </beans>
    I'm running on oc4j 10.1.2

    I can create a new ClassPathXmlApplicationContext no problem with applicationContext_ejb.xml. Isn't this what ContextSingletonBeanFactoryLocator does?

    Thanks alot.

  4. #4

    Default

    Oh, and here's my code to load the appContext:
    Code:
    public class BeanFactoryUtil &#123;
        
        private static final BeanFactoryLocator locator;
        private static final BeanFactoryReference ref;
        private static final BeanFactory beanFactory;
        private static Logger logger = Logger.getLogger&#40;SkillObjectFactory.class&#41;;
        
        static &#123;
            logger.info&#40;"Loading ContextSingletonBeanFactoryLocator..."&#41;;
            locator = ContextSingletonBeanFactoryLocator.getInstance&#40;&#41;;
            logger.info&#40;"Loading ejb-context..."&#41;;
            ref = locator.useBeanFactory&#40;"ejb-context"&#41;;
            logger.info&#40;"Loading beanFactory..."&#41;;
            beanFactory = ref.getFactory&#40;&#41;;
        &#125;
        
        public static BeanFactory getBeanFactory&#40;&#41; &#123;
            return beanFactory;
        &#125;
    &#125;

  5. #5

    Default

    It must be prepending the value with jndi://. Is there a workaround?

  6. #6

    Default

    bumping. can anyone provide some insight on this?

  7. #7

    Default

    Well, I've tried everything and can't solve the problem. It appears that there was an issue with this (key: SPR-322) that I found via Google. It also appeared that the problem was supposed to be fixed, but I just can't get it to work.

  8. #8
    Join Date
    Sep 2004
    Location
    Christchurch, New Zealand
    Posts
    73

    Default

    This is looks like a known defect in OC4J 10.1.2, see SPR-665:

    http://opensource.atlassian.com/proj...browse/SPR-665

    Chris

  9. #9

    Default

    It doesn't surprise me actually. We've had so many headaches with OC4J. Thanks for the reply.

  10. #10
    Join Date
    Sep 2004
    Location
    Christchurch, New Zealand
    Posts
    73

    Default

    I have worked-arround this issue by modifying org.springframework.beans.factory.access.Singleton BeanFactoryLocator and then replacing the default bean factory locator in org.springframework.ejb.support.AbstractStatelessS essionBean.

    We are a few months from deploying a Spring based app to OC4J 10.1.2, is there anything in particular I should watch out for?

    thanks,
    Chris

Similar Threads

  1. how to bind application context to jndi
    By shadowek in forum EJB
    Replies: 5
    Last Post: Oct 27th, 2005, 02:46 PM
  2. Replies: 2
    Last Post: Oct 13th, 2005, 02:47 PM
  3. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  4. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  5. How to bind the application context to JNDI name
    By macroangle in forum Container
    Replies: 0
    Last Post: Apr 21st, 2005, 10:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •