0

This is the problem when I tried to save file .properties in weblogic java.lang.IllegalArgumentException: URI is not hierarchical

I deployed on WAS and Tomcat and works well but in weblogic I have the problem when I read and display the properties on .jsp is well but when I want to save is the problem.

public boolean setProperties(String data[]) {
    OutputStream outStream = null;
    File f;
    try {
        Properties props = new Properties();

        props.setProperty("url", data[0]);
        props.setProperty("method", "" + data[1]);
        props.setProperty("accept", "" + data[2]); 
        props.setProperty("key", "" + data[3]); 
        URL url= getClass().getResource("/access.properties");
        f = new File(url.toURI()); 
        outStream = new FileOutputStream(f);
        props.store(outStream, "");

        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return false;
}

1 Answers1

0

The original problem is because we cant write on the file because when weblogic deploy our war the src is convert to jar _wl_cls_gen.jar and we cant write.

I solved the next link teach about EAR and APP-INF where I putted my classes, properties and libs.

EAR EXAMPLE

I created weblogic-application.xml on EAR and putted

   <wls:prefer-application-packages>
    <wls:package-name>namePackages.*</wls:package-name>
</wls:prefer-application-packages>
<wls:prefer-application-resources>
    <wls:resource-name>access.properties</wls:resource-name>
</wls:prefer-application-resources>

The next link is important to understand about it DOC ORACLE CLASSLOADING