Announcement Announcement Module
Collapse
No announcement yet.
Error loading context: unknown protocol: jndi Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Can you post the problematic configuration?

    Rob

    Comment


    • #3
      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.

      Comment


      • #4
        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;

        Comment


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

          Comment


          • #6
            bumping. can anyone provide some insight on this?

            Comment


            • #7
              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.

              Comment


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

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

                Chris

                Comment


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

                  Comment


                  • #10
                    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

                    Comment


                    • #11
                      So you modified the framework itself? I haven't run into any other issues.

                      Comment


                      • #12
                        java.net.MalformedURLException: unknown protocol: jndi

                        Hi,

                        I have exactly the same issue on OC4J 9.0.4 where i get the exception java.net.MalformedURLException: unknown protocol: jndi returned from
                        the method PathMatchingResourcePatternResolver.findAllClassPa thResources which seems to be getting the URL jndi:C:\Java\JDev\j2ee\home\applications\LSB-MQS\Shared.jar/beanRefFactory.xml from the Class Loader (my source is jared up in Shared.jar)
                        The thing is this works fine using JDeveloper embedded server as none of the source is jared up but as soon as you deploy it too a standalone instance (on Windows and Linux) the thing screws up.

                        I am quite new to ClassLoader and Spring issues so has anyone got any example source for the SingletonBeanFactoryLocator which i could rip off?

                        Thanks
                        Dave

                        Comment


                        • #13
                          I created a custom Singleton that wraps the ClassPathXmlApplicationContext, the only downside is that I had to hardcode the xml file name to staticly load the spring configuration. And it works fine.

                          Comment

                          Working...
                          X