Announcement Announcement Module
Collapse
No announcement yet.
Yet another help request for HttpInvoker-testing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Yet another help request for HttpInvoker-testing

    Hi,

    I got this error in my test after calling this instruction:

    private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] { "/springapp-servlet.xml"});

    .....

    this.jetty = (Server) applicationContext.getBean("Server");

    Code:
    Caused by: java.lang.SecurityException: sealing violation: package org.mortbay.jetty is sealed
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:227)
    	at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    	at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    	at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    	at org.springframework.util.ClassUtils.forName(ClassUtils.java:183)
    	at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:317)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1044)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:351)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:197)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:265)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1019)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:809)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
    	... 22 more

    this is my jetty.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
        <bean id="Server"
              class="org.mortbay.jetty.Server" init-method="start" destroy-method="stop">
            <property name="connectors">
                <list>
                    <bean id="Connector" class="org.mortbay.jetty.nio.SelectChannelConnector">
                        <property name="port" value="8080"/>
                    </bean>
                </list>
            </property>
    
            <property name="handler">
                <bean id="handlers"
                      class="org.mortbay.jetty.handler.HandlerCollection">
                    <property name="handlers">
                        <list>
                            <bean id="contexts"
                                  class="org.mortbay.jetty.handler.ContextHandlerCollection">
                                <property name="handlers">
                                    <list>
                                        <bean class="org.mortbay.jetty.webapp.WebAppContext">
                                            <property name="contextPath" value="/WEB-INF"/>
                                            <property name="war" value="../conf/web">
                                            </property>
                                        </bean>
                                    </list>
                                </property>
                            </bean>
                        </list>
                    </property>
                </bean>
            </property>
        </bean>
    </beans>
    this is web.xml:

    Code:
    <!DOCTYPE web-app PUBLIC
     "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
     "http://java.sun.com/dtd/web-app_2_3.dtd" >
    
    <web-app>
        <display-name>Foo</display-name>
        <description>Bar</description>
        
        <context-param>
    		<param-name>webAppRootKey</param-name>
    		<param-value>transactions.root</param-value>
    	</context-param>
    
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                classpath*:/springapp-servlet.xml
            </param-value>
        </context-param>
    
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
         
        <servlet>
            <servlet-name>springapp</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>2</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>springapp</servlet-name>
            <url-pattern>*.htm</url-pattern>
        </servlet-mapping>
      
    </web-app>
    this is my service on springapp-servlet.xml:

    Code:
    <!-- url mapping -->
    	 <bean id="urlMapping"
    	 	class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	 	<property name="mappings">
    	 		<props>
    	 			<prop key="/service.htm">accountServiceHttp</prop>
    	 		</props>
    	 	</property>
    	 </bean>
    
    
    	 <!-- http invoker -->
    	<bean name="accountServiceHttp"
    		class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
    		<property name="service" ref="accountService" />
    		<property name="serviceInterface"
    			value="org.test.jetty.AccountService" />
    	</bean>
    
    	<bean id="httpInvokerProxy"
    		class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    		<property name="serviceUrl"
    			value="http://localhost:8181/remoting/AccountService" />
    		<property name="serviceInterface"
    			value="org.test.jetty.AccountService" />
    	</bean>
    	
    	<bean name="accountService" class="org.test.jetty.AccountServiceImpl" />
    this is my sample code of service (by spring documentation):

    Code:
    package org.test.jetty;
    
    import java.io.Serializable;
    
    public class Account implements Serializable {
    
            private String name;
    
              public String getName() {
                      return this.name;
              }
    
              public void setName(String name) {
                this.name = name;
              }
              
    }
    
    --------------------------
    
    package org.test.jetty;
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class AccountServiceImpl implements AccountService  {
    
            public List getAccounts(String name) {
    
                    List list = new ArrayList();
                    list.add("foo");
                    return list;
            }
    
            public void insertAccount(Account account) {
                    // TODO Auto-generated method stub
            }
    
    }
    
    -------------------------
    
    package org.test.jetty;
    
    import java.util.List;
    
    public interface AccountService {
    
            public void insertAccount(Account account);
    
            public List getAccounts(String name);
    }
    
    ----------------------------
    
    package org.test.jetty;
    
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    import java.util.List;
    
    public interface RemoteAccountService extends Remote {
    
            public void insertAccount(Account account) throws RemoteException;
    
            public List getAccounts(String name) throws RemoteException;
    
    }
    have you any idea how to avoid that exception?

    and eventually, how can I test above simple service solved that exception-problem?

    Thanks,
    Julio

  • #2
    Code:
    Caused by: java.lang.SecurityException: sealing violation: package org.mortbay.jetty is sealed
    problem solved!

    in maven I must use jetty-embedded (you cannot call class in jetty from external class - more and less the sense of exception above)

    and this little modify to jetty.xml:

    Code:
    <bean id="contexts"
                                  class="org.mortbay.jetty.handler.ContextHandlerCollection">
                                <property name="handlers">
                                    <list>
                                        <bean class="org.mortbay.jetty.webapp.WebAppContext">
                                            <property name="contextPath" value="/myapp"/>
                                            <property name="war" value="src/main/webapp" />
                                        </bean>
                                    </list>
                                </property>
                            </bean>
    Ok, now I get a running auto-deploying application in jetty.

    Can you suggest me how test above service?

    URL url=new URL("http://localhost:8080/myapp/service.htm");
    ...

    or

    instance of a bean with service-client( org.springframework.remoting.httpinvoker.HttpInvok erProxyFactoryBean)

    ?

    is there an example?

    Thanks,
    Julio

    Comment


    • #3
      ok solved with second option

      Julio

      Comment


      • #4
        execution error for java program

        Hi I am YDRAO. I am getting the following errors when running java applications on windowsXP system.

        I am using j2sdk5.2 enterprise edition.
        JDK was installed in the following directory: C:\Program files\Java. According to that I set the path and classpath.
        PATH variable value=%PATH%;C:\Program Files\Java\jdk\bin
        CLASSPATH variable value =.;C:\Program Files\Java\jdk\bin; C:\Program Files\Java\jdk\lib; C:\Program Files\Java\jdk\jre

        My program is p1.java

        import java.io.*;

        public class p1
        {
        public static void main(String args[])
        {
        Syste.out.println(“WELCOME TO THE JAVA”);
        }
        }


        if I load this program in the directory C:\Program Files\Java\jdk\bin , compiled and executed successfully.i am getting correct output.fine

        if I run the same program in different directory C:\Documents and Settings\ydrao it is giving the following error. Compilation is ok, but I am getting error in execution as


        C:\DOCUME~1\ydrao>java p1
        Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version n
        umber in .class file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknow n Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)

        but by running the java debugger I am getting the output
        C:\DOCUME~1\ydrao>jdb
        Initializing jdb ...
        > run p1
        run p1
        Set uncaught java.lang.Throwable
        Set deferred uncaught java.lang.Throwable
        >
        VM Started: WELCOME TO THE JAVA

        The application exited


        Java version is “1.5.0_03”
        Javac version is “1.6.0”


        Pls find the problem and send reply. I am waiting for ur reply

        Comment

        Working...
        X