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

**URL:** <https://community.wowza.com/t/invoke-publish-and-invoke-release-error-for-custom-module/45855>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [September 26, 2015, 8:28pm UTC](https://community.wowza.com/t/invoke-publish-and-invoke-release-error-for-custom-module/45855 "2015-09-26T20:28:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shubhank\_Gaur](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@Shubhank\_Gaur](https://community.wowza.com/u/Shubhank_Gaur)\
**Post date:** [September 26, 2015, 8:28pm UTC](https://community.wowza.com/t/invoke-publish-and-invoke-release-error-for-custom-module/45855/1 "2015-09-26T20:28:52Z")

</div>

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

Getting the following errors

```auto
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

```auto
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:

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

```

---

<div class="post-metadata">

**Author:** ![Shubhank\_Gaur](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@Shubhank\_Gaur](https://community.wowza.com/u/Shubhank_Gaur)\
**Post date:** [September 26, 2015, 8:36pm UTC](https://community.wowza.com/t/invoke-publish-and-invoke-release-error-for-custom-module/45855/2 "2015-09-26T20:36:07Z")

</div>

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