Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String Index out of Range error #185

Closed
crajarshi opened this issue Jan 2, 2015 · 2 comments
Closed

String Index out of Range error #185

crajarshi opened this issue Jan 2, 2015 · 2 comments

Comments

@crajarshi
Copy link

My pom file is as below :-

org.apache.maven.plugins
maven-war-plugin
2.3



package

war


src/main/minified
UTF-8




false
src/main/minified
UTF-8


${project.build.directory}/min





net.alchim31.maven
yuicompressor-maven-plugin
1.5.1


compressyui
process-resources

compress


true
src/main/minified
${project.build.directory}/min
false
true


And when I do a maven clean and build in Netbeans I get the following output and failure.

Can anyone please help what's wrong here :-

This is the stacktrace --- [INFO] --- yuicompressor-maven-plugin:1.5.1:compress (compressyui) @ icoreWeb ---
[INFO] accountmgmt.css (28786b) -> accountmgmt.css (20283b)[70%]
[INFO] fields.css (10674b) -> fields.css (7808b)[73%]
[INFO] footer.css (5406b) -> footer.css (3790b)[70%]
[INFO] apex-popup.css (2789b) -> apex-popup.css (1985b)[71%]
[INFO] apex.css (65467b) -> apex.css (46778b)[71%]
[INFO] bookingDisclosure.css (683b) -> bookingDisclosure.css (505b)[73%]
[INFO] fields.css (9684b) -> fields.css (6622b)[68%]
[INFO] apex.css (6439b) -> apex.css (4899b)[76%]
[INFO] ie.css (7575b) -> ie.css (5137b)[67%]
[INFO] rwd.css (27039b) -> rwd.css (18406b)[68%]
[INFO] circle.css (457b) -> circle.css (288b)[63%]
[INFO] contentOne.css (1105b) -> contentOne.css (699b)[63%]
[INFO] contentOneHeader.css (56b) -> contentOneHeader.css (36b)[64%]
[INFO] disclosure.css (11116b) -> disclosure.css (8832b)[79%]
[INFO] footer.css (4983b) -> footer.css (3676b)[73%]
[INFO] hispanicFieldStyle.css (2663b) -> hispanicFieldStyle.css (1627b)[61%]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.225s
[INFO] Finished at: Fri Jan 02 09:11:12 EST 2015
[INFO] Final Memory: 26M/64M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:yuicompressor-maven-plugin:1.5.1:compress (compressyui) on project icoreWeb: Execution compressyui of goal net.alchim31.maven:yuicompressor-maven-plugin:1.5.1:compress failed: String index out of range: 76892 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.alchim31.maven:yuicompressor-maven-plugin:1.5.1:compress (compressyui) on project icoreWeb: Execution compressyui of goal net.alchim31.maven:yuicompressor-maven-plugin:1.5.1:compress failed: String index out of range: 76892
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:60)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:354)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution compressyui of goal net.alchim31.maven:yuicompressor-maven-plugin:1.5.1:compress failed: String index out of range: 76892
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 76892
at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:879)
at java.lang.StringBuffer.substring(StringBuffer.java:416)
at com.yahoo.platform.yui.compressor.CssCompressor.compress(CssCompressor.java:125)
at net_alchim31_maven_yuicompressor.YuiCompressorMojo.compressCss(YuiCompressorMojo.java:259)
at net_alchim31_maven_yuicompressor.YuiCompressorMojo.processFile(YuiCompressorMojo.java:216)
at net_alchim31_maven_yuicompressor.MojoSupport.processDir(MojoSupport.java:216)
at net_alchim31_maven_yuicompressor.MojoSupport.execute(MojoSupport.java:151)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
... 20 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
is this a problem with the plugin? what can be the possible solution? I can't use any other plugin as those are not in our nexus repository. Please help me understand what is wromg here

@tml
Copy link
Contributor

tml commented Jan 9, 2015

I believe this is an old bug that was fixed in the 2.4.8 release; however, because of issues #78 and #130, the maintainer of yuicompressor-maven-plugin has opted to continue depending on 2.4.7 for the time being. Without a test case of the problem against 2.4.8, there's not a lot I can do to help you out here.

If you're able to get 2.4.8 into your environment, and recreate the problem, please feel free to reopen this issue, and thanks for your interest in improving the YUICompressor project!

@tml tml closed this as completed Jan 9, 2015
@bitcompiler
Copy link

bitcompiler commented Apr 30, 2019

The below code produce an error

java.lang.StringIndexOutOfBoundsException: String index out of range

HtmlCompressor compressor = new HtmlCompressor();

compressor.setEnabled(true); //if false all compression is off (default is true)
compressor.setRemoveComments(true); //if false keeps HTML comments (default is true)
compressor.setRemoveMultiSpaces(true); //if false keeps multiple whitespace characters (default is true)
compressor.setRemoveIntertagSpaces(true);//removes iter-tag whitespace characters
compressor.setRemoveQuotes(true); //removes unnecessary tag attribute quotes
compressor.setCompressCss(true); //compress css using Yahoo YUI Compressor
compressor.setCompressJavaScript(true); //compress js using Yahoo YUI Compressor
compressor.setYuiCssLineBreak(80); //--line-break param for Yahoo YUI Compressor
compressor.setYuiJsDisableOptimizations(true); //--disable-optimizations param for Yahoo YUI Compressor
compressor.setYuiJsLineBreak(-1); //--line-break param for Yahoo YUI Compressor
compressor.setYuiJsNoMunge(true); //--nomunge param for Yahoo YUI Compressor
compressor.setYuiJsPreserveAllSemiColons(true);//--preserve-semi param for Yahoo YUI Compressor

String str = "<html><body><p>Hover over the checkbox to simulate a mouse-click.</p><form><input type=\"checkbox\" id=\"myCheck\" onmouseover=\"myFunction()\" onclick=\"alert('click event occured')\"></form><script>function myFunction(){document.getElementById(\"myCheck\").click();}</script></body></html>";
System.out.println(compressor.compress(str));

If remove the <script> tag and its contents, then its working fine.
or
if comment 'compressor.setCompressJavaScript(true); ' this line, then its working fine.

#323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants