Skip to main content

"java.net.UnknownServiceException: no content-type"

14 replies [Last post]
grzewal
Offline
Joined: 2008-12-10
Points: 0

Hi,

here's the situation description:

In an application I use a third party jar (from Pentaho Data Integration - pdi).

A piece of code in a class from that jar is:

<br />
try {<br />
    		// try reading plugins defined in JAR file META-INF/kettle-partition-plugins.xml<br />
        	Enumeration resources = getClass().getClassLoader().getResources("META-INF/kettle-partition-plugins.xml");<br />
        	while( resources.hasMoreElements() )<br />
        	{<br />
        		URL url = resources.nextElement();<br />
        		Object content = url.getContent();<br />
        		if( content instanceof InputStream )<br />
        		{<br />
        			readPluginFromResource( (InputStream) content, null, null, StepPlugin.TYPE_NATIVE );<br />
        		}<br />
        	}<br />
    		// also look in /kettle-partition-plugins.xml<br />
        	resources = getClass().getClassLoader().getResources("kettle-partition-plugins.xml");<br />
        	while( resources.hasMoreElements() )<br />
        	{<br />
        		URL url = resources.nextElement();<br />
        		Object content = url.getContent();<br />
        		if( content instanceof InputStream )<br />
        		{<br />
        			readPluginFromResource( (InputStream) content, null, null, StepPlugin.TYPE_NATIVE );<br />
        		}<br />
        	}<br />
    	} catch (Exception e) {<br />
    		throw new KettleException("Unable to load plugins specified in 'META-INF/kettle-partition-plugins.xml' files", e);<br />
    	}<br />

this code works perfectly when launched from J2SE application (the file META-INF/kettle-partition-plugins.xml is of course present in the jar).

But I use it (well actually I call a method that uses it) from a J2EE app EJB and I get an exception.

The method containing this code is called from a @Timeout method in an EJB.
With the invocation an exception is thrown: UnknownServiceException saying that there is no content type specified for the file.

Any idea's why the change of behavior between J2SE and J2EE application?
The app server is Glassfish V2 and the EJB is compilant to EJB 3.0 specfication.

BTW:
ulr.toString() returns a perfectly valid path.

<br />
stack trace:<br />
[#|2008-12-09T18:47:24.878+0100|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=18;_ThreadName=p:<br />
thread-pool-1; w: 4;_RequestID=dac5e0d1-596f-40c4-b40b-09163f0d26f2;|<br />
org.pentaho.di.core.exception.KettleException:<br />
Unable to load plugins specified in<br />
'META-INF/kettle-partition-plugins.xml' files<br />
no content-type</p>
<p>       at org.pentaho.di.trans.StepLoader.readPlugins(StepLoader.java:361)<br />
       at org.pentaho.di.trans.StepLoader.init(StepLoader.java:110)<br />
       at org.pentaho.di.trans.StepLoader.init(StepLoader.java:119)<br />
       at org.test.DailyProcessingScheduleBean.startDailySchedule(DailyProcessingScheduleBean.java:157)<br />
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />
       at java.lang.reflect.Method.invoke(Method.java:597)<br />
       at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)<br />
       at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)<br />
       at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)<br />
       at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:2824)<br />
       at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1401)<br />
       at com.sun.ejb.containers.EJBTimerService.access$100(EJBTimerService.java:99)<br />
       at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:1952)<br />
       at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.service(EJBTimerService.java:1948)<br />
       at com.sun.ejb.containers.util.WorkAdapter.doWork(WorkAdapter.java:75)<br />
       at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)<br />
Caused by: java.net.UnknownServiceException: no content-type<br />
       at java.net.URLConnection.getContentHandler(URLConnection.java:1192)<br />
       at java.net.URLConnection.getContent(URLConnection.java:689)<br />
       at java.net.URL.getContent(URL.java:1023)<br />
       at org.pentaho.di.trans.StepLoader.readPlugins(StepLoader.java:343)<br />
       ... 17 more<br />
|#]</p>
<p>

Regards.
GW

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sahoo

I don't think so especially because getResources() returned the URL of
the resource you are looking for.

Sahoo

glassfish@javadesktop.org wrote:
> Or maybe it's a problem with the application structure on the EE server:
>
> The structure is as follows:
> [code]
> KettleLoadTestProject
> |- KettleLoadTestProject_ejb_jar - where the EJB are located
> |- KettleLoadTestProject_web_war
> |- lib
> |-the Pentaho lib (along with all the others) is here
> |- META-INF
> [/code]
>
> Regards,
> GW
> [Message sent by forum member 'grzewal' (grzewal)]
>
> http://forums.java.net/jive/thread.jspa?messageID=321027
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

grzewal
Offline
Joined: 2008-12-10
Points: 0

True, the url seems to be ok.

So what can be the underlying cause?

Regards,

Sahoo

Don't know. Try asking it in some Java forum like [1].

Thanks,
Sahoo

[1] http://forums.sun.com/forum.jspa?forumID=536

glassfish@javadesktop.org wrote:
> True, the url seems to be ok.
>
> So what can be the underlying cause?
>
> Regards,
> [Message sent by forum member 'grzewal' (grzewal)]
>
> http://forums.java.net/jive/thread.jspa?messageID=321173
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

grzewal
Offline
Joined: 2008-12-10
Points: 0

Hi.

Already been there (well not exactly there, but on ejb sun forum) and the suggestion was that it's a glassfish issue especially that SE application works fine.

Regards,
GW

Sahoo

Sun EJB forum is as similar to this forum, so I suggest you try the JDK
forum I mentioned in my last email. They may be able to assist why
java.net package is behaving differently.

Thanks,
Sahoo

glassfish@javadesktop.org wrote:
> Hi.
>
> Already been there (well not exactly there, but on ejb sun forum) and the suggestion was that it's a glassfish issue especially that SE application works fine.
>
> Regards,
> GW
> [Message sent by forum member 'grzewal' (grzewal)]
>
> http://forums.java.net/jive/thread.jspa?messageID=321180
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

glassfish@javadesktop.org wrote:
> BTW:
> ulr.toString() returns a perfectly valid path.
>
For some reason, the URL scheme seems to be unknown in the running JVM.
Can you print url.toString()?

Thanks,
Sahoo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

grzewal
Offline
Joined: 2008-12-10
Points: 0

Yes I can,

And it returns:
[code]
jar:file:/C:/user/jee/glassfish/domains/domain1/applications/j2ee-apps/KettleLoadTestProject/lib/kettle-engine.jar!/META-INF/kettle-partition-plugins.xml
[/code]

Regards,

Sahoo

OK, I was wrong in my previous interpretation of the exception. That
exception does not mean "scheme is not recognized," that means the
content type header was either null or unrecognized [1]. I think the
content type header was null; you can check by adding a debug statement
to print url.getContentType(). What is surprising to me is that you said
this worked in Java SE mode. Can you please let us know what
url.getContentType() prints in both the environments. May be that would
provide some hint. I should also warn you that I don't have in-depth
knowledge in java.net package, so don't curse me if this turns out to be
a futile exercise.

Thanks,
Sahoo

[1]
http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLConnection.html#getContent()
glassfish@javadesktop.org wrote:
> Yes I can,
>
> And it returns:
> [code]
> jar:file:/C:/user/jee/glassfish/domains/domain1/applications/j2ee-apps/KettleLoadTestProject/lib/kettle-engine.jar!/META-INF/kettle-partition-plugins.xml
> [/code]
>
> Regards,
> [Message sent by forum member 'grzewal' (grzewal)]
>
> http://forums.java.net/jive/thread.jspa?messageID=320978
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

grzewal
Offline
Joined: 2008-12-10
Points: 0

[code]
url.openConnection().getContentType()
[/code]

returned:
J2SE:
application/xml

J2EE:
null

Regards,

Sahoo

What does url.toString() print on Java SE?

Thanks,
Sahoo

glassfish@javadesktop.org wrote:
> [code]
> url.openConnection().getContentType()
> [/code]
>
> returned:
> J2SE:
> application/xml
>
> J2EE:
> null
>
> Regards,
> [Message sent by forum member 'grzewal' (grzewal)]
>
> http://forums.java.net/jive/thread.jspa?messageID=320988
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

grzewal
Offline
Joined: 2008-12-10
Points: 0

Physically this is a different file (actualy a copy of the .jar from enterprise application)

[code]
URL: jar:file:/C:/user/Workspace/KettleApiTest/lib/kettle-engine.jar!/META-INF/kettle-partition-plugins.xml
[/code]

Sahoo

I don't know why the same URL is behaving differently. If you can change
the code, you may like to experiment by replacing getContent() with
getInputStream() which does not look for content-type. This should
suffice as the code you had earlier sent out expected getContent() to
return an InputStream.

HTH,
Sahoo

glassfish@javadesktop.org wrote:
> Physically this is a different file (actualy a copy of the .jar from enterprise application)
>
> [code]
> URL: jar:file:/C:/user/Workaspace/KettleApiTest/lib/kettle-engine.jar!/META-INF/kettle-partition-plugins.xml
> [/code]
> [Message sent by forum member 'grzewal' (grzewal)]
>
> http://forums.java.net/jive/thread.jspa?messageID=321002
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

grzewal
Offline
Joined: 2008-12-10
Points: 0

Or maybe it's a problem with the application structure on the EE server:

The structure is as follows:
[code]
KettleLoadTestProject
|- KettleLoadTestProject_ejb_jar - where the EJB are located
|- KettleLoadTestProject_web_war
|- lib
|-the Pentaho lib (along with all the others) is here
|- META-INF
[/code]

Regards,
GW

grzewal
Offline
Joined: 2008-12-10
Points: 0

And another thing:

this piece of code:
[code]
System.out.println("Creating input stream");
InputStream is = this.getClass().getClassLoader().getResourceAsStream(
"META-INF/kettle-partition-plugins.xml");
StringBuilder transXml = new StringBuilder();
int c;
while ((c = is.read()) != -1) {
System.out.println("Read: " + (char)c);
transXml.append((char)c);
}

System.out.println(transXml.toString());
[/code]

works fine in the @Timeout method and prints to the server output log contents of the xml file.

???

Regards,
GW