alexo / wro4j

New project location is:https://github.com/wro4j/wro4j
442 stars 110 forks source link

Runtime solution : 404 Not found - Syntax error #172

Closed likeavirgil closed 10 years ago

likeavirgil commented 10 years ago

Hi, i try to use wro4j in my maven project.

I get a 404 Not found when i use this in my xhtml page : <script type="text/javascript" src="/wro/core.js"></script>

My wro.xml :

<?xml version="1.0" encoding="UTF-8"?>
<groups xmlns="http://www.isdc.ro/wro">
  <group name='core'>
    <js>http://code.jquery.com/jquery-1.11.0.min.js</js>
  </group>
</groups>

part of my web.xml :

<filter>
  <filter-name>wroContextFilter</filter-name>
  <filter-class>ro.isdc.wro.http.WroContextFilter</filter-class>
</filter>
<filter>
  <filter-name>WebResourceOptimizer</filter-name>
  <filter-class>ro.isdc.wro.http.WroFilter</filter-class>
</filter>

<filter-mapping>
  <filter-name>wroContextFilter</filter-name>
  <url-pattern>/*</url-pattern>
  <dispatcher>REQUEST</dispatcher>
  <dispatcher>ERROR</dispatcher>
</filter-mapping>
<filter-mapping>
  <filter-name>WebResourceOptimizer</filter-name>
  <url-pattern>/wro/*</url-pattern>
</filter-mapping>

I use Glassfish 3 on Ubuntu 12.04 and i add this in my pom.xml :

<dependency>
  <groupId>ro.isdc.wro4j</groupId>
  <artifactId>wro4j-core</artifactId>
  <version>1.7.0</version>
</dependency>

<dependency>
  <groupId>ro.isdc.wro4j</groupId>
  <artifactId>wro4j-extensions</artifactId>
  <version>1.7.0</version>
</dependency>

Thanks.

likeavirgil commented 10 years ago

Ok i solve my problem :

<script type="text/javascript" src="/my-project/wro/core.js"></script>

instead of :

<script type="text/javascript" src="/wro/core.js"></script>

But now i have this error :

core.js : SyntaxError: syntax error

When i click on core.js it's my html code who is displayed.

alexo commented 10 years ago

What processor do you use? In case the default processor breaks the output, you could replace it with a different one.

likeavirgil commented 10 years ago

I don't use processor right now. Should i ?

alexo commented 10 years ago

You probably use without knowing it. By default, the jsMin processor is used, but you can easily configure a different list or processors. If you would have no processors, the returned javascript would be original one.

likeavirgil commented 10 years ago

Ok :) so if i just want minify my core.js, i don't need to add other processors, right ?

alexo commented 10 years ago

The minify operation is performed by a processor. If no processor is used, nothing but merge is performed.

By default the following processors are configured:

addPreProcessor(new CssUrlRewritingProcessor());
addPreProcessor(new CssImportPreProcessor());
addPreProcessor(new SemicolonAppenderPreProcessor());
addPreProcessor(new JSMinProcessor());
addPreProcessor(new JawrCssMinifierProcessor());
addPostProcessor(new CssVariablesProcessor());

Since you are using already minified resource, you can skip the minification using minimize="false" attribute.

<groups xmlns="http://www.isdc.ro/wro">
    <group name='core'>
      <js minimize="false">http://code.jquery.com/jquery-1.11.0.min.js</js>
    </group>
 </groups>
likeavirgil commented 10 years ago

Ok. But i still have my syntax error.

alexo commented 10 years ago

How does the response to this resource looks like? On 11 Mar 2014 13:45, "Virgil Calabrese" notifications@github.com wrote:

Ok. But i still have my syntax error.

Reply to this email directly or view it on GitHubhttps://github.com/alexo/wro4j/issues/172#issuecomment-37286884 .

likeavirgil commented 10 years ago
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>

and the rest of my index page

alexo commented 10 years ago

Do you see anything relevant in logs? It doesn't seem to be served by wro4j On 11 Mar 2014 14:34, "Virgil Calabrese" notifications@github.com wrote:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

and the rest of my index page

Reply to this email directly or view it on GitHub.

likeavirgil commented 10 years ago

Yes I have this in Glassfish logs :

Avertissement: StandardWrapperValve[default]: PWC1406: Servlet.service() for servlet default threw exception
java.lang.ClassNotFoundException: org.apache.commons.io.input.BOMInputStream
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
    at ro.isdc.wro.model.group.processor.InjectorBuilder.<init>(InjectorBuilder.java:47)
    at ro.isdc.wro.model.group.processor.InjectorBuilder.create(InjectorBuilder.java:69)
    at ro.isdc.wro.http.WroFilter.getInjector(WroFilter.java:316)
    at ro.isdc.wro.http.WroFilter.handledWithRequestHandler(WroFilter.java:299)
    at ro.isdc.wro.http.WroFilter.doFilter(WroFilter.java:266)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:744)
alexo commented 10 years ago

Don't you use the maven for dependency management? If not, you have to add the required dependency: commons-io.

likeavirgil commented 10 years ago

Yes no more errors on Glassfish logs bug still have Syntax error. In my network monitor i have core.js : 302 Moved Temporarily. I think it's a configuration problem in my project. Thanks for you help ;)

alexo commented 10 years ago

You should check the content of the /my-project/wro/core.js.. When the response is a javascript, that's a sign that it was successfully processed by wro4j. I'm closing this issue with invalid resolution. If you encounter any issue or have any question, don't hesitate to ask here or on the mailing list.