1

I am developing an Eclipse RAP web application and would like to keep resource files (configuration etc.) in WEB-INF and load them with something like this:

Properties properties = new Properties();
properties.load(getServletContext().getResourceAsStream("/WEB-INF/foo.properties"));

The WAR is created with a Gradle build and that looks OK when deploying to a standalone Tomcat.

What I would like to do is getting this to work in my development cycle inside Eclipse. I.e. launch the project with a RAP or RWT launch configuration and have all contents in WEB-INF deployed to Jetty, too.

The following instructions have helped me to at least have my own web.xml in the runtime directory used by Jetty:

http://wiki.eclipse.org/RAP/FAQ#How_do_I_develop_an_RWT_standalone_application_with_RAP_.3E.3D_1.5

..\my_workspace\.metadata\.plugins\org.eclipse.rap.tools.launch.rwt\my.rap.app\web-app\WEB-INF\web.xml

But I cannot find a way for any other files under WEB-INF to be deployed when launching inside Eclipse. What I am hoping to achieve is this:

..\my_workspace\.metadata\.plugins\org.eclipse.rap.tools.launch.rwt\my.rap.app\web-app\WEB-INF\foo.properties

Does anybody know whether this is possible with an RWT or RAP launch configuration in Eclipse?

Is there a better approach to comfortably develop and debug a RAP application that loads resources from WEB-INF in Eclipse?

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
StaticNoiseLog
  • 1,370
  • 17
  • 27
  • Did you try to use the RWT lauch config with the option "run from web.xml"? I'm not sure but chances are that jetty treats it as a regular web application when launched from a web.xml. – ralfstx Sep 12 '15 at 15:42
  • @ralfstx: Yes, I am running my test application from a web.xml. This web.xml indeed gets deployed to the Jetty runtime directory. But any other files in WEB-INF are ignored. With the RWT application running I can manually copy the files over to WEB-INF (`..\eclipse_workspace_rcp_rap\.metadata\.plugins\org.eclipse.rap.tools.launch.rwt\my.test.app\web-app\WEB-INF\foo.properties`) and things work as I hoped they would. – StaticNoiseLog Sep 14 '15 at 07:47

1 Answers1

1

Unfortunately, a feature to copy resources to the WEB-INF directory never made it into the RWT launcher code base.

Since this would be a useful extension of the RWT launcher you may want to file an enhancement request.

I cannot think of a workaround other than putting the properties file on the class path and reading from there:

Properties properties = new Properties();
properties.load( getClass().getResourceAsStream( "foo.properties" ) );

If the resources meant to be located in the WEB-INF directory aren't changing much you could also try to copy them manually to my_workspace\.metadata\.plugins\org.eclipse.rap.tools.launch.rwt\my.rap.app\web-app\WEB-INF

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
  • Thanks a lot! I will use one of the two approaches, maybe an Ant script to automate copying of the resources. – StaticNoiseLog Sep 14 '15 at 07:49
  • I have filed an enhancement request: [https://bugs.eclipse.org/bugs/show_bug.cgi?id=477349](https://bugs.eclipse.org/bugs/show_bug.cgi?id=477349) – StaticNoiseLog Sep 14 '15 at 10:42