cancel
Showing results for 
Search instead for 
Did you mean: 

How do i test webscript using TestWebscriptserver?

tejashpatel
Champ in-the-making
Champ in-the-making
Hi,

please if anyone know how to use Testwebscript server for testing webscripts
then let me know how do i use it?

Tejash Patel
Cignex Inc.
7 REPLIES 7

davidc
Star Contributor
Star Contributor
I usually execute from within Eclipse where the classpath is setup.

Basically, you just need to execute TestWebScriptServer.  It supports a main function.  You'll see a prompt.  Type 'help' to see the available commands for testing.

sun
Champ in-the-making
Champ in-the-making
I try to create a unit testing for my java based web script, could anyone help how to do it? Thanks

agatap
Champ in-the-making
Champ in-the-making
I am having some troubles running the TestWebScriptServer.
After having located the class in the alfresco-web-client.jar, when I try to run the main method (from my Eclipse IDE), i get the following error:

12:44:16,854 ERROR [transform.magick.AbstractImageMagickContentTransformer] ImageMagickContentTransformer not available: Failed to perform ImageMagick transformation:
Execution result:
   os:         Windows XP
   command:    imconvert "C:\DOCUME~1\agatap\LOCALS~1\Temp\Alfresco\ImageMagickContentTransformer_init_source_58810.gif"  "C:\DOCUME~1\agatap\LOCALS~1\Temp\Alfresco\ImageMagickContentTransformer_init_target_58811.png"
   succeeded:  false
   exit code:  1
   out:       
   err:        Cannot run program "imconvert": CreateProcess error=2, The system cannot find the file specified
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverConnector' defined in class path resource [alfresco/core-services-context.xml]: Invocation of init method failed; nested exception is java.io.IOException: Cannot bind to URL [rmi://localhost:50500/alfresco/jmxrmi]: javax.naming.NameAlreadyBoundException: alfresco/jmxrmi [Root exception is java.rmi.AlreadyBoundException: alfresco/jmxrmi]
Caused by: java.io.IOException: Cannot bind to URL [rmi://localhost:50500/alfresco/jmxrmi]: javax.naming.NameAlreadyBoundException: alfresco/jmxrmi [Root exception is java.rmi.AlreadyBoundException: alfresco/jmxrmi]
   at javax.management.remote.rmi.RMIConnectorServer.newIOException(Unknown Source)
   at javax.management.remote.rmi.RMIConnectorServer.start(Unknown Source)
   at org.springframework.jmx.support.ConnectorServerFactoryBean.afterPropertiesSet(ConnectorServerFactoryBean.java:168)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1118)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
   at org.alfresco.web.scripts.TestWebScriptServer.getTestServer(TestWebScriptServer.java:198)
   at org.alfresco.web.scripts.TestWebScriptServer.main(TestWebScriptServer.java:168)
Caused by: javax.naming.NameAlreadyBoundException: alfresco/jmxrmi [Root exception is java.rmi.AlreadyBoundException: alfresco/jmxrmi]
   at com.sun.jndi.rmi.registry.RegistryContext.bind(Unknown Source)
   at com.sun.jndi.toolkit.url.GenericURLContext.bind(Unknown Source)
   at javax.naming.InitialContext.bind(Unknown Source)
   at javax.management.remote.rmi.RMIConnectorServer.bind(Unknown Source)
   … 15 more
Caused by: java.rmi.AlreadyBoundException: alfresco/jmxrmi
   at sun.rmi.registry.RegistryImpl.bind(RegistryImpl.java:123)
   at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
   at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386)
   at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
   at sun.rmi.transport.Transport$1.run(Transport.java:159)
   at java.security.AccessController.doPrivileged(Native Method)
   at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
   at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
   at java.lang.Thread.run(Thread.java:619)
   at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
   at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
   at sun.rmi.server.UnicastRef.invoke(Unknown Source)
   at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
   … 19 more


Obviously something is wrong with the setup, but … I cant find any special installation instructions in the Web Script Tutorial.
Hope somebody can help me out here  :cry:

Agata

sun
Champ in-the-making
Champ in-the-making
Thanks for sharing your experience. I think configuration is not setting properly.

I have similar exception. I have to add more and more things to classpath and exception keeps change every time. 

Where is the document to setup this testing environment?

agatap
Champ in-the-making
Champ in-the-making
Please, has anybody successfully used the TestWebscriptserver? Could you share how to set up Eclipse to run it?
I am using the latest Community Edition (2.1) together with Eclipse and Java 1.5.
Tried to run the thing on both Windows XP and OS X.
I have followed the instructions for installing the SDK, and can successfully deploy Alfresco in my environment.
However, as described above, it fails to run 😞
The same problem with running JUnit tests (from Custom Aspect Sample).

I hope somebody can help me out here …
Agata

steve
Champ in-the-making
Champ in-the-making
Hi Agata,

Your initial issues:
javax.naming.NameAlreadyBoundException: alfresco/jmxrmi [Root exception is java.rmi.AlreadyBoundException: alfresco/jmxrmi]
Caused by: java.io.IOException: Cannot bind to URL [rmi://localhost:50500/alfresco/jmxrmi]: javax.naming.NameAlreadyBoundException: alfresco/jmxrmi [Root exception is java.rmi.AlreadyBoundException: alfresco/jmxrmi]

Is because something is already running on port 50500. This could be an instance of Alfresco that you have not shut down properly/completely, or could be another application you are running.
If you free up this port and restart Alfresco then you should no longer get this problem.

Hope this helps,

Steve

agatap
Champ in-the-making
Champ in-the-making
I feel kind of stupid now - perhaps I am missing the obvious here? But I am really determined to make this work, it is so important for me to unit test my work, and I am so much looking forward to be able to test my webscripts!

When I list the open ports ( Mac Airbook, OSX Leopard), I get the following ports (none of them is 55000):
 sudo lsof -i -P | grep -i "listen"
launchd       1               root   13u  IPv6 0x3c3cbe8      0t0    TCP localhost:631 (LISTEN)
launchd       1               root   14u  IPv4 0x40a9e64      0t0    TCP localhost:631 (LISTEN)
launchd       1               root   53u  IPv6 0x3c3c984      0t0    TCP *:548 (LISTEN)
launchd       1               root   55u  IPv4 0x40a9a68      0t0    TCP *:548 (LISTEN)
httpd        27               root    3u  IPv6 0x3c3c720      0t0    TCP *:80 (LISTEN)
krb5kdc      55               root   12u  IPv6 0x3f174bc      0t0    TCP *:88 (LISTEN)
krb5kdc      55               root   13u  IPv4 0x3b54a68      0t0    TCP *:88 (LISTEN)
httpd        63               _www    3u  IPv6 0x3c3c720      0t0    TCP *:80 (LISTEN)
mysqld      131             _mysql   10u  IPv4 0x4c8fe64      0t0    TCP *:3306 (LISTEN)
Skype      2158 agataprzybyszewska   29u  IPv4 0x63eba68      0t0    TCP *:55539 (LISTEN)
cupsd     15267               root    4u  IPv6 0x3c3cbe8      0t0    TCP localhost:631 (LISTEN)
cupsd     15267               root    6u  IPv4 0x40a9e64      0t0    TCP localhost:631 (LISTEN)
Xquartz   15959 agataprzybyszewska    1u  IPv6 0x3f17720      0t0    TCP *:6000 (LISTEN)
Xquartz   15959 agataprzybyszewska    6u  IPv4 0xb600270      0t0    TCP *:6000 (LISTEN)

but when I try to run the TestWebServer from eclipse, I still get the stack trace:


12:57:38,019 ERROR [transform.magick.AbstractImageMagickContentTransformer] ImageMagickContentTransformer not available: Failed to perform ImageMagick transformation:
Execution result:
   os:         Mac OS X
   command:    convert /tmp/Alfresco/ImageMagickContentTransformer_init_source_24342.gif  /tmp/Alfresco/ImageMagickContentTransformer_init_target_24343.png
   succeeded:  false
   exit code:  1
   out:       
   err:        convert: not found
12:57:40,516 WARN  [remoting.rmi.RmiRegistryFactoryBean] Could not detect RMI registry - creating new one
12:57:42,059 WARN  [alfresco.util.OpenOfficeConnectionTester] A connection to OpenOffice could not be established.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webscripts.classpathstore$child#1' defined in class path resource [alfresco/web-scripts-application-context.xml]: Invocation of init method failed; nested exception is org.alfresco.web.scripts.WebScriptException: Web Script Store classpath:alfresco/templates/webscripts must exist; it was not found
Caused by: org.alfresco.web.scripts.WebScriptException: Web Script Store classpath:alfresco/templates/webscripts must exist; it was not found
   at org.alfresco.web.scripts.ClassPathStore.afterPropertiesSet(ClassPathStore.java:102)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1118)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:273)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
   at org.alfresco.web.scripts.TestWebScriptServer.getTestServer(TestWebScriptServer.java:198)
   at org.alfresco.web.scripts.TestWebScriptServer.main(TestWebScriptServer.java:168)

On the other hand, I have no problem running my Hello World module (deployed as an AMP file using ant) by starting Alfresco using the startup script.
So I am sure something is wrong with my Eclipse setup.

I hope some of you guys can help me out here!
Agata