Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » JavaLaunchDelegate - java.net.MalformedURLException: unknown protocol: pla
JavaLaunchDelegate - java.net.MalformedURLException: unknown protocol: pla [message #1108193] Fri, 13 September 2013 13:30
Marek Jagielski is currently offline Marek Jagielski
Messages: 63
Registered: April 2012
Member
Hi,
I launch new java process from my eclipse plugin:
   <extension point="org.eclipse.debug.core.launchConfigurationTypes">
      <launchConfigurationType
            name="%systemincloud.launch.type.name"
      		delegateDescription="%systemincloud.launch.type.description"
            id="com.systemincloud.modeler.systemincloudLaunchConfigurationType"
            delegate="com.systemincloud.modeler.launch.SystemInCloudLaunchDelegate"
            sourceLocatorId="com.systemincloud.modeler.launch.SystemInCloudSourceLocator"
            sourcePathComputerId="com.systemincloud.modeler.launch.SystemInCloudSourceComputer"
            modes="run" public="true"/>
   </extension>


My delegate extends JavaLaunchDelegate:
public class SystemInCloudLaunchDelegate extends JavaLaunchDelegate {


I added in Delegate my plugin API_PLUGIN_ID in classpath to be able to access their classes from new process.

	@Override
	public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
		List<String> extendedClasspath = new ArrayList<String>();
		Collections.addAll(extendedClasspath, super.getClasspath(configuration));
		if (!Platform.inDevelopmentMode()) {
			try {
				extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.API_PLUGIN_ID));
			} catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, SystemInCloudConstants.LAUNCHER_PLUGIN_ID, IStatus.OK, "Failed to compose classpath!", e)); }
		} else {
			try {
				extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.API_PLUGIN_ID) + "target/classes");
			} catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, SystemInCloudConstants.LAUNCHER_PLUGIN_ID, IStatus.OK, "Failed to compose classpath!", e)); }
		}
		try {
			extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.EMF_ECORE_PLUGIN_ID));
			extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.EMF_COMMON_PLUGIN_ID));
			extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.EMF_TRANSACTION_PLUGIN_ID));
			extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.EMF_XMI_PLUGIN_ID));
			extendedClasspath.add(pluginIdToJarPath(SystemInCloudConstants.GRAPHITI_MM_PLUGIN_ID));
		} catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, SystemInCloudConstants.LAUNCHER_PLUGIN_ID, IStatus.OK, "Failed to compose classpath!", e)); }
		return extendedClasspath.toArray(new String[extendedClasspath.size()]);
	}


In one class of my plugin I read resource file:
	protected InputStream getServiceConfig() {
		InputStream is = null;
		try {
			URL url = new URL("platform:/plugin/" + SystemInCloudConstants.API_PLUGIN_ID + "/service.properties");
		    is = url.openConnection().getInputStream();
		} catch (IOException e) { e.printStackTrace(); }
		return is;
	}


When I am using this method inside plugin there is no problem. When I use this class inside new process I get an exception:
java.net.MalformedURLException: unknown protocol: platform
	at java.net.URL.<init>(URL.java:592)
	at java.net.URL.<init>(URL.java:482)
	at java.net.URL.<init>(URL.java:431)
	at com.systemincloud.modeler.api.SicConnectionModeler.getServiceConfig(SicConnectionModeler.java:25)
	at com.systemincloud.api.java.SicConnection.<init>(SicConnection.java:66)


Is there an eclipse plugin that I can add to classpath or I should translate this url to non-relative path before using it?

Thanks for any hint,

Marek
Previous Topic:Windows Builder Pro Version difference between Indigo and the following
Next Topic:The container 'Maven Dependencies' references non existing library
Goto Forum:
  


Current Time: Thu Oct 02 10:46:44 GMT 2014

Powered by FUDForum. Page generated in 0.02199 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software