Wowza Community

invoke(publish) and invoke(release) error for custom module

Created a custom module to match a streamName with a applicationProperty name

Getting the following errors

invoke(publish): java.lang.reflect.InvocationTargetException|at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)|at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)|at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)|at java.lang.reflect.Method.invoke(Method.java:483)|at com.wowza.wms.module.ModuleFunction.invoke(ModuleFunction.java:369)|
invoke(releaseStream): java.lang.reflect.InvocationTargetException|at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)|at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)|at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)|at java.lang.reflect.Method.invoke(Method.java:483)|at com.wowza.wms.module.ModuleFunction.invoke(ModuleFunction.java:369)|

The module is custom.jar (in WMSPATH/lib/ folder) and is as follows

package custom;
import com.wowza.wms.application.*;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
import com.wowza.wms.stream.*;
import com.wowza.wms.rtp.model.*;
import com.wowza.wms.httpstreamer.model.*;
import com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.*;
import com.wowza.wms.httpstreamer.smoothstreaming.httpstreamer.*;
public class ModuleOverride extends ModuleBase {
		IApplicationInstance appInstance = null;
		public void onAppStart(IApplicationInstance appInstance)
	{
		this.appInstance = appInstance;
	}
	
		public void publish(IClient client, RequestFunction function,
		        AMFDataList params) {
			getLogger().info("Overriding Publish");
			
			String allowedStream = client.getProperties().getPropertyStr("allowedStream");
			
			String streamName = extractStreamName(client, function, params);
			
			if (allowedStream.equals(streamName))
			{
				invokePrevious(client, function, params);
			} else {
				sendClientOnStatusError(client, "NetStream.Publish.BadName", "Invalid Stream Name");
				getLogger().info("Stream Name Rejected: " + streamName);
			}
		}
	public void releaseStream(IClient client, RequestFunction function, AMFDataList params)
		{
			String streamName = extractStreamName(client, function, params);
			
			String allowedStream = client.getProperties().getPropertyStr("allowedStream");
			if (allowedStream.equals(streamName))
			{
				invokePrevious(client, function, params);
			}	else {
				sendClientOnStatusError(client, "NetStream.Publish.BadName", "Invalid Stream Name");
				getLogger().info("Stream Name Rejected: " + streamName);
			}	
		}
		
		public String extractStreamName(IClient client, RequestFunction function, AMFDataList params)
	{
		String streamName = params.getString(PARAM1);
		if (streamName != null)
		{
			String streamExt = MediaStream.BASE_STREAM_EXT;
			
			String[] streamDecode = ModuleUtils.decodeStreamExtension(streamName, streamExt);
			streamName = streamDecode[0];
			streamExt = streamDecode[1];
			
			streamName = streamName.split("\\?")[0];
		}
		return streamName;
	}
}

Application.xml (for live application) has the following added at their relevant place:

<Module>
        <Name>CustomOverrides</Name>
        <Description>Override publish</Description>
        <Class>custom.ModuleOverride</Class>
</Module>
<Property>
        <Name>allowedStream</Name>
        <Value>live</Value>
</Property>

Just to add, I created the module using a Windows IDE and the actual WMS server (and the module) is on a linux server