Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    VelocityException: Error initializing log

    We are occassionally having some trouble, with major impact, starting up the application in the browser. The issue vanishes after restarting the server (IBM WSphere). Is this a known issue? Feedback would be much appreciated.


    SmartClient Version: v9.0p_2013-09-22/PowerEdition Deployment (built 2013-09-22)

    2. IE 9, Version: 9.0.8112.16421


    Code:
    [1/10/14 15:01:52:690 CET] 00000057 SystemOut     O - dsRequest.execute() failed:  
    org.apache.velocity.exception.VelocityException: Error initializing log: Failed to initialize an instance of org.apache.velocity.runtime.log.SimpleLog4JLogSystem with the current runtime configuration. 	
    at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:875) 	
    at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:262) 	
    at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:646) 	
    at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:116) 	
    at com.isomorphic.velocity.Velocity.getEngine(Velocity.java:84) 	
    at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:321) 	
    at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64) 	
    at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2427) 	
    at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:215) 	
    at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:172) 	
    at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:137) 	
    at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73) 	
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:595) 	
    at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152) 	
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) 	
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1225) 	
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:775) 	
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:457) 	
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) 	
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) 	
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97) 	
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) 	
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) 	
    at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:246) 	
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) 	
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) 	
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928) 	
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025) 	
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3763) 	
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304) 	
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:975) 	
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662) 	
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195) 	
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515) 	
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306) 	
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:277) 	
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214) 	
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113) 	
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:166) 	
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) 	
    at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205) 	
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1691) 
    
    Caused by: org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.SimpleLog4JLogSystem with the current runtime configuration. 	
    at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:220) 	
    at org.apache.velocity.runtime.log.LogManager.updateLog(LogManager.java:269) 	
    at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:871) 	
    ... 43 more 
    
    Caused by: java.lang.ClassCastException: java.util.Vector incompatible with java.lang.String 	at org.apache.velocity.runtime.log.SimpleLog4JLogSystem.init(SimpleLog4JLogSystem.java:70) 	
    at org.apache.velocity.runtime.log.LogChuteSystem.init(LogChuteSystem.java:53) 	
    at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:166) 	
    ... 45 more

    Have by now tried to configure the log settings, but the com.isomorphic.velocity.Velocity class seems to be looking for the SimpleLog4JLogSystem class!

    Code:
    final VelocityEngine ve = new VelocityEngine();
    ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
    ve.setProperty("runtime.log.logsystem.log4j.category", "velocity");
    ve.init();
    UPDATE:
    Looking at the source of com.isomorphic.datasource.DataSourceDMI.java and com.isomorphic.velocity.Velocity.java, it seems like the properties used to initialise the apache VelocityEngine is hardcoded and the engine is retrieved via static definitions, preventing us to overwrite the definition. Any possible workarounds?

    Code:
    public class DataSourceDMI
        implements IScriptSource, FreeResourcesHandler
    {
    ...
        public DSResponse execute() throws Exception
        {
            ...
                VelocityEngine vEngine = Velocity.getEngine();
            ...
        }
    
        protected VelocityEngine getVelocityEngine()
            throws Exception
        {
            VelocityEngine vEngine = new VelocityEngine();
            Properties properties = new Properties();
            properties.put("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
            properties.put("runtime.log.logsystem.log4j.category", "org.apache.Velocity");
            vEngine.init(properties);
            return vEngine;
        }
    ...
    }
    Code:
    public class Velocity extends Base
    {
    
        public Velocity()
        {
        }
    
        public static VelocityEngine getEngine()
            throws Exception
        {
            if(vEngine != null)
            {
                return vEngine;
            } else
            {
                vEngine = new VelocityEngine();
                Properties properties = new Properties();
                properties.put("file.resource.loader.path", "");
                properties.put("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
                properties.put("runtime.log.logsystem.log4j.category", "org.apache.Velocity");
                vEngine.init(properties);
                return vEngine;
            }
        }
    ....
    }
    Last edited by GM_GWT; 10 Jan 2014, 07:30.

    #2
    Sorry, no, we have not seen this before.

    You refer to something in the code as hardcoded, but what is "hardcoded" is just the name of the class we're expecting to be able to use - this isn't really any more hardcoded than an ordinary Java import. It's just an ordinary dependency.

    Since you're reporting this as an intermittent problem with server *restart*, it doesn't seem like changing the class name to something else is a fix. It works fine, then something goes wrong in Websphere, possibly a classloader issue. We would suggest making sure you don't have duplicate copies of .jars in your classpath.

    Comment


      #3
      Hi Isomorphic,

      I guess you haven't understood the issue we are facing. By now we have managed to build a work-around to this issue by the following. Hope this helps you get into this issue.

      Code:
          private void initVelocity()
          {
              try
              {
                  // Initialize Apache velocity runtime engine (over Apache velocity engine)
                  final VelocityEngine ve = new VelocityEngine();
                  ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
                  ve.setProperty("runtime.log.logsystem.log4j.category", "org.apache.Velocity");
                  ve.init();
      
                  // Assign the initialized velocity engine to the isomorphic velocity proxy
                  final Field field = com.isomorphic.velocity.Velocity.class.getDeclaredField("vEngine");
                  field.setAccessible(true);
                  field.set(null, ve);
      
                  LOGGER.info("Isomorphic Velocity Runtime Engine initialization completed!");
              }
              catch (final Exception e)
              {
                  LOGGER.log(Level.SEVERE, "Cannot initialize Velocity", e);
              }
          }
      An ideal way would be, to make the apache velocity framework initialization some-how configurable for the clients.

      Comment


        #4
        No, we definitely do not have a clear picture of your issue.

        As best we can understand, you want to have Velocity use a log system other than log4j, but instead of saying this, you've brought up an issue where Websphere fails on restart.. which continues to appear to have been due to a bad classpath.

        If you can give a clear idea of what you actually want to achieve - not just claiming that something is "hardcoded", but clearly explaining the actual purpose you have in mind in changing it - we may be able to help.

        Comment


          #5
          To clarify further, we think your analysis of the problem is wrong.

          It doesn't make sense that we would need to tell Velocity in particular to use a log4j configuration that is different from *all the other logs that the SmartGWT Server logs*. It's not hardcoding to have Velocity use the same logging system.

          Now, have you tried Googling the error message? Most of the results suggest that either the directory where logs are written is not writable, or there is a classpath issue, or something similar. So we'd suggest looking into that. In our opinion your fix addresses a symptom and not a cause. If you disagree, explain clearly why.
          Last edited by Isomorphic; 14 Jan 2015, 09:27.

          Comment

          Working...
          X