VMware Cloud Community
heikki_hyperic
Contributor
Contributor

HQU Plugin unable to load content from public dir

I've put some JavaScript and images in my HQU plugin's public directory:

myplugin/
  public/
  myscript.js
  images/
    myimage.png

I then tried to reference these in my .gps file:

<img src="<%= urlFor(asset:"images") + "myimage.png" %>">
<script src="<%= urlFor(asset:"myscript.js") %>" type="text/javascript"></script>

The URLs produced look like:

hqu/myplugin/public/images/myimage.png
hqu/myplugin/public/myscript.js

What I see is a placeholder for the image (couldn't load it) and I also see that the script wasn't loaded since I can't call any code in it. Trying to view just the image I get an error page with stack:

THROWABLE-WAS-NULL (at java.lang.Exception at org.hyperic.util.StringUtil.getStackTrace(StringUtil.java:407) at org.apache.jsp.common.GenericError_jsp._jspService(Unknown Source) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:465) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301) at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:362) at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:283) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112) at java.lang.Thread.run(Thread.java:619) )

Trying to view just the script URL gives the same kind of error.


Is there something else I need to do to make this work? I have observed this with both 3.2.3 and latest svn trunk.
0 Kudos
4 Replies
admin
Immortal
Immortal

Not a very informative stacktrace ... nothing else shows up?

The alertcenter uses this functionality (through it's used in
the .groovy controller).

-- Jon



On Jun 6, 2008, at 11:22 AM, Heikki Toivonen wrote:

> I've put some JavaScript and images in my HQU plugin's public
> directory:
>
> myplugin/
>   public/
>   myscript.js
>   images/
>     myimage.png
>
> I then tried to reference these in my .gps file:
>
> <img src="<%= urlFor(asset:"images") + "myimage.png" %>">
> <script src="<%= urlFor(asset:"myscript.js") %>" type="text/
> javascript"></script>
>
> The URLs produced look like:
>
> hqu/myplugin/public/images/myimage.png
> hqu/myplugin/public/myscript.js
>
> What I see is a placeholder for the image (couldn't load it) and I
> also see that the script wasn't loaded since I can't call any code
> in it. Trying to view just the image I get an error page with stack:
>
> THROWABLE-WAS-NULL (at java.lang.Exception at
> org.hyperic.util.StringUtil.getStackTrace(StringUtil.java:407) at
> org.apache.jsp.common.GenericError_jsp._jspService(Unknown Source)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:
> 97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
> (ApplicationFilterChain.java:252) at
> org.apache.catalina.core.ApplicationFilterChain.doFilter
> (ApplicationFilterChain.java:173) at
> org.apache.catalina.core.ApplicationDispatcher.invoke
> (ApplicationDispatcher.java:672) at
> org.apache.catalina.core.ApplicationDispatcher.processRequest
> (ApplicationDispatcher.java:465) at
> org.apache.catalina.core.ApplicationDispatcher.doForward
> (ApplicationDispatcher.java:398) at
> org.apache.catalina.core.ApplicationDispatcher.forward
> (ApplicationDispatcher.java:301) at
> org.apache.catalina.core.StandardHostValve.custom
> (StandardHostValve.java:362) at
> org.apache.catalina.core.StandardHostValve.status
> (StandardHostValve.java:283) at
> org.apache.catalina.core.StandardHostValve.invoke
> (StandardHostValve.java:136) at
> org.apache.catalina.valves.ErrorReportValve.invoke
> (ErrorReportValve.java:105) at
> org.apache.catalina.core.StandardEngineValve.invoke
> (StandardEngineValve.java:107) at
> org.apache.catalina.connector.CoyoteAdapter.service
> (CoyoteAdapter.java:148) at
> org.apache.coyote.http11.Http11Processor.process
> (Http11Processor.java:856) at
> org.apache.coyote.http11.Http11Protocol
> $Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
> at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket
> (PoolTcpEndpoint.java:527) at
> org.apache.tomcat.util.net.MasterSlaveWorkerThread.run
> (MasterSlaveWorkerThread.java:112) at java.lang.Thread.run
> (Thread.java:619) )
>
> Trying to view just the script URL gives the same kind of error.
>
>
> Is there something else I need to do to make this work? I have
> observed this with both 3.2.3 and latest svn trunk.


0 Kudos
heikki_hyperic
Contributor
Contributor

Nope, that is all there is.

But when I tried to make a sample plugin to attach here, things got really weird. I found out things work/don't work based on the *name* of the plugin and controller. In my experiment I created a plugin with the ant hqu-gen-scaffold command, uncommented the addView method in the Plugin.groovy file and changed it from masthead to admin. This plugin:

ant hqu-gen-scaffold -Dplugin=atlantis -Dcontroller=Plato -DcontrollerDir=plato

appeared in the plugin list on the Administrator page, but would not load. Some other plugin name/controller name combination wouldn't even appear on the Administrator page. Plugin name foo, controller name Foobar, view foobar worked ok - including loading files from public. And the production plugin I have been working on works otherwise except it can't load things from public dir.

Grepping for the the names of the plugin or controller from hyperic source found no matches for some problem plugins I checked. I will check if I can spot anything wrong with the PostgreSQL database, but other than that I am pretty much out of ideas why this would be happening. If all else fails, I could try working around this by creating dummy plugins to test what name combinations seem to work, but there's no telling if something I didn't test won't work or if something that works now stops working later for no apparent reason.

PS. One obvious thing which also seems to not work is to create a plugin with the same name as the controller and view.
0 Kudos
heikki_hyperic
Contributor
Contributor

So it seems the reason I could not load files from public/ was because I was using symlinks. Should I file a bug?

The other weirdness seems happen because some cruft that accumulates in the database. Once I dropped the hq database, recreated it, and did a clean build everything worked as expected. I wonder if the plugin_mon plugin would have helped here (seems to be incompatible with svn trunk)?
0 Kudos
admin
Immortal
Immortal

When changing your plugins views (via addView in Plugin.groovy),
you'll need to remove the plugin to pick up the changes. This is a
known bug to be fixed in 4.0.

The fact that plugin_mon isn't working in HEAD is an issue. In the
short term, you can remove the errant view from EAM_UI_VIEW

-- Jon


On Jun 10, 2008, at 12:20 PM, Heikki Toivonen wrote:

> So it seems the reason I could not load files from public/ was
> because I was using symlinks. Should I file a bug?
>
> The other weirdness seems happen because some cruft that
> accumulates in the database. Once I dropped the hq database,
> recreated it, and did a clean build everything worked as expected.
> I wonder if the plugin_mon plugin would have helped here (seems to
> be incompatible with svn trunk)?


0 Kudos