Java file not executing from exec but runs fine as application – clazz is null [closed]

I have a java jar file which I am trying to run from exec in a PHP script when a user clicks on a map. The application runs fine and generates the GeoJSON as intended, but from exec I get an error half way through the script:

Exception in thread "main" java.lang.RuntimeException
    at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:176)
    at org.geotools.devmap.CreateSites.main(CreateSites.java:176)
Caused by: java.io.IOException
    at org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:650)
    at org.geotools.jdbc.JDBCFeatureStore.getReaderInternal(JDBCFeatureStore.java:218)
    at org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:636)
    at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:174)
    ... 1 more
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Class.isArray()" because "clazz" is null
    at org.geotools.jdbc.JDBCDataStore.getMapping(JDBCDataStore.java:671)
    at org.geotools.jdbc.PreparedStatementSQLDialect.setValue(PreparedStatementSQLDialect.java:131)
    at org.geotools.jdbc.JDBCDataStore.setPreparedFilterValues(JDBCDataStore.java:3818)
    at org.geotools.jdbc.JDBCDataStore.selectSQLPS(JDBCDataStore.java:3731)
    at org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:613)
    ... 4 more

line 176 is:

newthreesitesiterator = threesitesfeatures.features();

from this code:

public class CreateSites 
{
    public static DataStore dataStore;
    public static DataStore dataStore2;
    public static FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    public static SimpleFeature usersite = null;
    public static Geometry usersitegeom = null;
    public static SimpleFeature newtwositesfeature = null;
    public static Geometry newtwositesfeaturegeom = null;
    public static Filter threesitesfilter = null;
    public static SimpleFeatureIterator newthreesitesiterator = null;
    public static SimpleFeatureCollection threesitesfeatures = null;
    public static SimpleFeature twositesfeature = null;
    public static Geometry twositesfeaturegeom = null;
    public static SimpleFeature threesitesfeature = null;
    public static Geometry threesitesfeaturegeom = null;
    public static SimpleFeature foursitesfeature = null;
    public static Geometry foursitesfeaturegeom = null;
    public static BigDecimal usersiteuprns = new BigDecimal(0);
    public static String postcode = "";
    public static String oa = "";
    public static String lsoa = "";
    
    public static void main( String[] args ) throws IOException, CQLException, ScriptException
    {
        Map<String, Object> params = new HashMap<>();
        params.put("dbtype", "postgis");
        params.put("host", "localhost");
        params.put("port", 5432);
        params.put("schema", "public");
        params.put("database", "devmap");
        params.put("user", "postgres");
        params.put("passwd", "postgres");
        params.put("preparedStatements", true);
        params.put("encode functions", true);

        
        dataStore = DataStoreFinder.getDataStore(params);
        dataStore2 = DataStoreFinder.getDataStore(params);
        
        String inputTypeName = "singlesites";
        SimpleFeatureType inputType = dataStore.getSchema(inputTypeName);

        FeatureSource<SimpleFeatureType, SimpleFeature> singlesource = dataStore.getFeatureSource(inputTypeName);
        
        String siteidl = "18644777";//args[0].toString();
        Integer siteid = Integer.parseInt(siteidl);
        String s = "siteid = " + siteid;

        Filter filter = ff.equals( ff.property( "siteid"), ff.literal( siteid ) );
        SimpleFeatureCollection usersitefeature = (SimpleFeatureCollection) singlesource.getFeatures(filter);
        
        List<SimpleFeature> usersitesfeatures = new ArrayList<>();
        
        SimpleFeatureIterator iterator = usersitefeature.features();
        try {
            while( iterator.hasNext()  ){
                usersite = iterator.next();
                usersitegeom = (Geometry) usersite.getDefaultGeometry();
                usersitesfeatures.add(usersite);
            }
        }
        finally {
            iterator.close();
        }

        String pgsiteid = usersite.getProperty("siteid").getValue().toString();
        System.out.println("Java Site ID = " + pgsiteid);
        usersiteuprns = (BigDecimal) usersite.getProperty("siteuprns").getValue();
        int usersitestitleno = (int) usersite.getProperty("title_no").getValue();
        
        List<SimpleFeature> newtwositesfeatures = new ArrayList<>();
        Filter twositesfilter = ff.touches("geom", usersitegeom);
        SimpleFeatureCollection singlesitesfeatures = (SimpleFeatureCollection) singlesource.getFeatures();
        SimpleFeatureCollection twositesfeatures = singlesitesfeatures.subCollection(twositesfilter);
        
        try (SimpleFeatureIterator twositesitr = twositesfeatures.features()) {
            while (twositesitr.hasNext()) {
                twositesfeature = twositesitr.next();
                BigDecimal twositesuprns = (BigDecimal) twositesfeature.getProperty("siteuprns").getValue();
                BigDecimal uprnresult = usersiteuprns.add(twositesuprns);
                int twositestitleno = (int) twositesfeature.getProperty("title_no").getValue();
                twositesfeaturegeom = (Geometry) twositesfeature.getDefaultGeometry();
                GeometryCollector newtwositesgeom = new GeometryCollector();
                newtwositesgeom.add(usersitegeom);
                newtwositesgeom.add(twositesfeaturegeom);
                GeometryCollection newtwositesgeomcollection = newtwositesgeom.collect();
                twositesfeaturegeom = newtwositesgeomcollection.union();
                twositesfeature.setAttribute("geom", twositesfeaturegeom);
                double sizeac = twositesfeaturegeom.getArea() * 0.000247105;
                twositesfeature.setAttribute("sizeac", sizeac);
                twositesfeature.setAttribute("siteuprns", uprnresult);
                twositesfeature.setAttribute("title1", usersitestitleno);
                twositesfeature.setAttribute("title2", twositestitleno);
                twositesfeature.setAttribute("blpucnt", "2");
                newtwositesfeatures.add(twositesfeature);
                usersitesfeatures.add(twositesfeature);
            }
            twositesitr.close();
        }
        
        FeatureSource<SimpleFeatureType, SimpleFeature> singlesource2 = dataStore2.getFeatureSource("singlesites");
        SimpleFeatureCollection singlesitesfeatures2 = (SimpleFeatureCollection) singlesource2.getFeatures();
        
        SimpleFeatureCollection newtwositesfeaturescollection = DataUtilities.collection(newtwositesfeatures);
        System.out.println("Java Two Sites Count = " + newtwositesfeatures.size());
        
        List<SimpleFeature> newthreesitesfeaturestouching = new ArrayList<>();
        List<SimpleFeature> newthreesitesfeatures = new ArrayList<>();
        
        try (SimpleFeatureIterator newtwositesitr = newtwositesfeaturescollection.features()) {
            while (newtwositesitr.hasNext()) {
                newtwositesfeature = newtwositesitr.next();
                newtwositesfeaturegeom = (Geometry) newtwositesfeature.getDefaultGeometry();
                threesitesfilter = ff.touches("geom", newtwositesfeaturegeom);
                threesitesfeatures = singlesitesfeatures2.subCollection(threesitesfilter);
                System.out.println("Java Three Sites Count = " + threesitesfeatures.size());
                newthreesitesiterator = threesitesfeatures.features(); 
                while (newthreesitesiterator.hasNext()) {
                    SimpleFeature threetoadd = newthreesitesiterator.next();
                    newthreesitesfeaturestouching.add(threetoadd);
                }
                newthreesitesiterator.close();
            }
            newtwositesitr.close();
        }
                
        SimpleFeatureCollection threesitesfeaturescollection = DataUtilities.collection(newthreesitesfeaturestouching);
        SimpleFeatureIterator allthreesitesitr = threesitesfeaturescollection.features();
        while (allthreesitesitr.hasNext()) {
            SimpleFeature threetoadd = allthreesitesitr.next();
            Geometry threetoaddfeaturegeom = (Geometry) threetoadd.getDefaultGeometry();
            SimpleFeatureIterator newtwositesitr = newtwositesfeaturescollection.features();
            while (newtwositesitr.hasNext()) {
                SimpleFeature newtwositesfeature = newtwositesitr.next();
                List<SimpleFeature> newlist = new ArrayList<>();
                newlist.add(newtwositesfeature);
                SimpleFeatureCollection newcollection = DataUtilities.collection(newlist);
                Geometry newtwositesfeaturegeom = (Geometry) newtwositesfeature.getDefaultGeometry();
                Filter threesitesfilter = ff.touches("geom", threetoaddfeaturegeom);
                SimpleFeatureCollection threesitesfeatures = newcollection.subCollection(threesitesfilter);
                if (newcollection.size() == 1) {
                    BigDecimal newtwositesuprns = (BigDecimal) newtwositesfeature.getProperty("siteuprns").getValue();
                    BigDecimal newsinglesitesuprns = (BigDecimal) threetoadd.getProperty("siteuprns").getValue();
                    BigDecimal uprnresult = newtwositesuprns.add(newsinglesitesuprns);
                    int threesitestitleno = (int) threetoadd.getProperty("title_no").getValue();
                    int threesitestitle1 = (int) newtwositesfeature.getProperty("title1").getValue();
                    int threesitestitle2 = (int) newtwositesfeature.getProperty("title2").getValue();
                    //threesitesfeaturegeom = (Geometry) threesitesfeature.getDefaultGeometry();
                    GeometryCollector newthreesitesgeom = new GeometryCollector();
                    newthreesitesgeom.add(newtwositesfeaturegeom);
                    newthreesitesgeom.add(threetoaddfeaturegeom);
                    GeometryCollection newthreesitesgeomcollection = newthreesitesgeom.collect();
                    threesitesfeaturegeom = newthreesitesgeomcollection.union();
                    threetoadd.setAttribute("geom", threesitesfeaturegeom);
                    double sizeac = threesitesfeaturegeom.getArea() * 0.000247105;
                    threetoadd.setAttribute("sizeac", sizeac);
                    threetoadd.setAttribute("siteuprns", uprnresult);
                    threetoadd.setAttribute("title1", threesitestitleno);
                    threetoadd.setAttribute("title2", threesitestitle1);
                    threetoadd.setAttribute("title3", threesitestitle2);
                    threetoadd.setAttribute("blpucnt", "3");
                    newthreesitesfeatures.add(threetoadd);
                    usersitesfeatures.add(threetoadd);
                }
            }
            newtwositesitr.close();
        }
        allthreesitesitr.close();
        
        SimpleFeatureCollection allthreesitesfeaturescollection = DataUtilities.collection(newthreesitesfeatures);
        System.out.println("Java Three Sites Count = " + allthreesitesfeaturescollection.size());

        List<SimpleFeature> newfoursiteseaturestouching = new ArrayList<>();
        List<SimpleFeature> newfoursiteseatures = new ArrayList<>();
        
        try (SimpleFeatureIterator newthreesitesitr = allthreesitesfeaturescollection.features()) {
            while (newthreesitesitr.hasNext()) {
                SimpleFeature newthreesitesfeature = newthreesitesitr.next();
                Geometry newthreesitesfeaturegeom = (Geometry) newthreesitesfeature.getDefaultGeometry();
                Filter foursitesfilter = ff.touches("geom", newthreesitesfeaturegeom);
                
                SimpleFeatureCollection foursitesfeatures = singlesitesfeatures.subCollection(foursitesfilter);
                try (SimpleFeatureIterator newfoursitesitr = foursitesfeatures.features()) {
                    while (newfoursitesitr.hasNext()) {
                        SimpleFeature fourtoadd = newfoursitesitr.next();
                        newfoursiteseaturestouching.add(fourtoadd);
                    }
                    newfoursitesitr.close();
                }
            }
            newthreesitesitr.close();
        }
        
        SimpleFeatureCollection foursitesfeaturescollection = DataUtilities.collection(newfoursiteseaturestouching);
        SimpleFeatureIterator allfoursitesitr = foursitesfeaturescollection.features();
        while (allfoursitesitr.hasNext()) {
            SimpleFeature fourtoadd = allfoursitesitr.next();
            Geometry fourtoaddfeaturegeom = (Geometry) fourtoadd.getDefaultGeometry();
            SimpleFeatureIterator newthreesitesitr = allthreesitesfeaturescollection.features();
            while (newthreesitesitr.hasNext()) {
                SimpleFeature newthreesitesfeature = newthreesitesitr.next();
                List<SimpleFeature> newlist = new ArrayList<>();
                newlist.add(newthreesitesfeature);
                SimpleFeatureCollection newcollection = DataUtilities.collection(newlist);
                Geometry newthreesitesfeaturegeom = (Geometry) newthreesitesfeature.getDefaultGeometry();
                Filter foursitesfilter = ff.touches("geom", fourtoaddfeaturegeom);
                SimpleFeatureCollection foursitesfeatures = newcollection.subCollection(foursitesfilter);
                if (newcollection.size() == 1) {
                    BigDecimal newthreesitesuprns = (BigDecimal) newthreesitesfeature.getProperty("siteuprns").getValue();
                    BigDecimal newsinglesitesuprns = (BigDecimal) fourtoadd.getProperty("siteuprns").getValue();
                    BigDecimal uprnresult = newthreesitesuprns.add(newsinglesitesuprns);
                    int foursitestitleno = (int) fourtoadd.getProperty("title_no").getValue();
                    int foursitestitle1 = (int) newthreesitesfeature.getProperty("title1").getValue();
                    int foursitestitle2 = (int) newthreesitesfeature.getProperty("title2").getValue();
                    int foursitestitle3 = (int) newthreesitesfeature.getProperty("title3").getValue();
                    GeometryCollector newfoursitesgeom = new GeometryCollector();
                    newfoursitesgeom.add(newthreesitesfeaturegeom);
                    newfoursitesgeom.add(fourtoaddfeaturegeom);
                    GeometryCollection newfoursitesgeomcollection = newfoursitesgeom.collect();
                    foursitesfeaturegeom = newfoursitesgeomcollection.union();
                    fourtoadd.setAttribute("geom", foursitesfeaturegeom);
                    double sizeac = threesitesfeaturegeom.getArea() * 0.000247105;
                    fourtoadd.setAttribute("sizeac", sizeac);
                    fourtoadd.setAttribute("siteuprns", uprnresult);
                    fourtoadd.setAttribute("title1", foursitestitleno);
                    fourtoadd.setAttribute("title2", foursitestitle1);
                    fourtoadd.setAttribute("title3", foursitestitle2);
                    fourtoadd.setAttribute("title4", foursitestitle3);
                    fourtoadd.setAttribute("blpucnt", "4");
                    newfoursiteseatures.add(fourtoadd);
                    usersitesfeatures.add(fourtoadd);
                }
            }
            newthreesitesitr.close();
        }
        allfoursitesitr.close();
        
        SimpleFeatureCollection allfoursitesfeaturescollection = DataUtilities.collection(newfoursiteseatures);
        //System.out.println("Java Four Sites Count = " + allfoursitesfeaturescollection.size());
        
        SimpleFeatureCollection usersitesfeaturescollection = DataUtilities.collection(usersitesfeatures);
        
        inputTypeName = "postcodepolys";
        inputType = dataStore.getSchema(inputTypeName);

        FeatureSource<SimpleFeatureType, SimpleFeature> postcodesource = dataStore.getFeatureSource(inputTypeName);
        SimpleFeatureCollection postcodespolyscollection = (SimpleFeatureCollection) postcodesource.getFeatures();
        
        String oaTypeName = "oa";
        inputType = dataStore.getSchema(oaTypeName);

        FeatureSource<SimpleFeatureType, SimpleFeature> oasource = dataStore.getFeatureSource(oaTypeName);
        SimpleFeatureCollection oapolyscollection = (SimpleFeatureCollection) oasource.getFeatures();
        
        String lsoaTypeName = "lsoa";
        inputType = dataStore.getSchema(oaTypeName);

        FeatureSource<SimpleFeatureType, SimpleFeature> lsoasource = dataStore.getFeatureSource(lsoaTypeName);
        SimpleFeatureCollection lsoapolyscollection = (SimpleFeatureCollection) lsoasource.getFeatures();
        
        List<SimpleFeature> allfeatures = new ArrayList<>();
        
        try (SimpleFeatureIterator allsitesitr = usersitesfeaturescollection.features()) {
            while (allsitesitr.hasNext()) {
                SimpleFeature allsite = allsitesitr.next();
                Geometry allsitegeom = (Geometry) allsite.getDefaultGeometry();
                Filter pcpolysfilter = ff.intersects("wkb_geometry", allsitegeom);
                SimpleFeatureCollection pcpolyfeatures = postcodespolyscollection.subCollection(pcpolysfilter);
                try (SimpleFeatureIterator allpcpolysitr = pcpolyfeatures.features()){
                    while (allpcpolysitr.hasNext()) {               
                        SimpleFeature pcpoly = allpcpolysitr.next();
                        postcode = pcpoly.getProperty("postcodes").getValue().toString();
                        allsite.setAttribute("postcode", postcode);
                    }
                    allpcpolysitr.close();
                }
                Filter oapolysfilter = ff.intersects("geom", allsitegeom);
                SimpleFeatureCollection oapolyfeatures = oapolyscollection.subCollection(oapolysfilter);
                try (SimpleFeatureIterator alloapolysitr = oapolyfeatures.features()){
                    while (alloapolysitr.hasNext()) {               
                        SimpleFeature oapoly = alloapolysitr.next();
                        oa = oapoly.getProperty("oa21cd").getValue().toString();
                        allsite.setAttribute("oa", oa);
                    }
                    alloapolysitr.close();
                }
                Filter lsoapolysfilter = ff.intersects("geom", allsitegeom);
                SimpleFeatureCollection lsoapolyfeatures = lsoapolyscollection.subCollection(lsoapolysfilter);
                try (SimpleFeatureIterator alllsoapolysitr = lsoapolyfeatures.features()){
                    while (alllsoapolysitr.hasNext()) {             
                        SimpleFeature lsoapoly = alllsoapolysitr.next();
                        lsoa = lsoapoly.getProperty("lsoa21cd").getValue().toString();
                        allsite.setAttribute("lsoa", lsoa);
                    }
                    alllsoapolysitr.close();
                }
                inputTypeName = "ruralurban";
                FeatureSource<SimpleFeatureType, SimpleFeature> rusource = dataStore.getFeatureSource(inputTypeName);
                Filter rufilter = ff.equals( ff.property( "oa11cd"), ff.literal( oa ) );
                SimpleFeatureCollection rufeature = (SimpleFeatureCollection) rusource.getFeatures(rufilter);
                try (SimpleFeatureIterator ruitr = rufeature.features()){
                    while (ruitr.hasNext()) {               
                        SimpleFeature ru = ruitr.next();
                        String rutext = ru.getProperty("ruralurban").getValue().toString();
                        allsite.setAttribute("ruralurban", rutext);
                    }
                    ruitr.close();
                }
                String sizehastr = allsite.getProperty("sizeac").getValue().toString();
                double sizeha = Double.parseDouble(sizehastr) * 0.404686;
                allsite.setAttribute("sizeha", sizeha);
                if (sizeha <= 0.4) {
                    allsite.setAttribute("sizehadevarea", sizeha);
                }
                else if (sizeha > 0.4 && sizeha <= 2) {
                    allsite.setAttribute("sizehadevarea", sizeha * 0.8);
                }
                else if (sizeha > 2) {
                    allsite.setAttribute("sizehadevarea", sizeha * 0.6);
                }
                String sizehadevareastr = allsite.getProperty("sizehadevarea").getValue().toString();
                double sizehadevarea = Double.parseDouble(sizehadevareastr);
                allsite.setAttribute("ccdens", 150);
                allsite.setAttribute("urbdens", 100);
                allsite.setAttribute("suburbdens", 50);
                String ccdensstr = allsite.getProperty("ccdens").getValue().toString();
                int ccdens = Integer.parseInt(ccdensstr);
                String urbdensstr = allsite.getProperty("urbdens").getValue().toString();
                int urbdens = Integer.parseInt(urbdensstr);
                String suburbdensstr = allsite.getProperty("suburbdens").getValue().toString();
                int suburbdens = Integer.parseInt(suburbdensstr);
                String siteuprnsstr = allsite.getProperty("siteuprns").getValue().toString();
                int siteuprns = Integer.parseInt(siteuprnsstr);
                allsite.setAttribute("ccunits", ccdens * sizehadevarea);
                allsite.setAttribute("urbunits", urbdens * sizehadevarea);
                allsite.setAttribute("suburbunits", suburbdens * sizehadevarea);
                allsite.setAttribute("ccunitsdiff", (ccdens * sizehadevarea) - siteuprns);
                allsite.setAttribute("urbunitsdiff", (urbdens * sizehadevarea) - siteuprns);
                allsite.setAttribute("suburbunitsdiff", (suburbdens * sizehadevarea) - siteuprns);
                inputTypeName = "lsoa";
                FeatureSource<SimpleFeatureType, SimpleFeature> lsoaftsource = dataStore.getFeatureSource(inputTypeName);
                Filter lsoafilter = ff.equals( ff.property( "lsoa21cd"), ff.literal( lsoa ) );
                SimpleFeatureCollection lsoafeature = (SimpleFeatureCollection) lsoaftsource.getFeatures(lsoafilter);
                try (SimpleFeatureIterator lsitr = lsoafeature.features()){
                    while (lsitr.hasNext()) {               
                        SimpleFeature lsoaft = lsitr.next();
                        String lsoatext = lsoaft.getProperty("ppsqm").getValue().toString();
                        double ppsqmdb = Double.parseDouble(lsoatext);
                        allsite.setAttribute("ppsqm", ppsqmdb);
                        
                        String ccunitsstr = allsite.getProperty("ccunits").getValue().toString();
                        int ccunits = Integer.parseInt(ccunitsstr);
                        String devvaluecc = String.format("((%g * 88) * %d) - ((1750 * 88) * %d) - (((%g * 88) * %d) * 0.2)", ppsqmdb, ccunits, ccunits, ppsqmdb, ccunits);
                        double devvalueccint = eval(devvaluecc);
                        allsite.setAttribute("devvaluecc", devvalueccint);
                        String urbunitsstr = allsite.getProperty("urbunits").getValue().toString();
                        int urbunits = Integer.parseInt(urbunitsstr);
                        String devvalueurb = String.format("((%g * 88) * %d) - ((1750 * 88) * %d) - (((%g * 88) * %d) * 0.2)", ppsqmdb, urbunits, urbunits, ppsqmdb, urbunits);
                        double devvalueurbint = eval(devvalueurb);
                        allsite.setAttribute("devvalueurb", devvalueurbint);
                        String suburbunitsstr = allsite.getProperty("suburbunits").getValue().toString();
                        int suburbunits = Integer.parseInt(suburbunitsstr);
                        String devvaluesuburb = String.format("((%g * 88) * %d) - ((1750 * 88) * %d) - (((%g * 88) * %d) * 0.2)", ppsqmdb, suburbunits, suburbunits, ppsqmdb, suburbunits);
                        double devvaluesuburbint = eval(devvaluesuburb);
                        allsite.setAttribute("devvaluesuburb", devvaluesuburbint);
                        double usersitesizeac = allsitegeom.getArea();
                        double currentsitesizeac = allsitegeom.getArea();
                        String sitepctoftotalstr = String.format("%f / %f", usersitesizeac, currentsitesizeac);
                        double sitepctoftotal = eval(sitepctoftotalstr);
                        allsite.setAttribute("sitepctoftotal", sitepctoftotal);
                        String ccvaluexareastr = String.format("(%f * %f) / %g", devvalueccint, sitepctoftotal, usersiteuprns);
                        double ccvaluexarea = eval(ccvaluexareastr);
                        allsite.setAttribute("ccvaluexarea", ccvaluexarea);
                        String urbvaluexareastr = String.format("(%f * %f) / %g", devvalueurbint, sitepctoftotal, usersiteuprns);
                        double urbvaluexarea = eval(urbvaluexareastr);
                        allsite.setAttribute("urbvaluexarea", urbvaluexarea);
                        String suburbvaluexareastr = String.format("(%f * %f) / %g", devvaluesuburbint, sitepctoftotal, usersiteuprns);
                        double suburbvaluexarea = eval(suburbvaluexareastr);
                        allsite.setAttribute("suburbvaluexarea", suburbvaluexarea);
                    }
                    lsitr.close();
                }
                allfeatures.add(allsite);
            }
            allsitesitr.close();
        }
        SimpleFeatureCollection allsitesfeaturescollection = DataUtilities.collection(allfeatures);
        FeatureJSON featureJson = new FeatureJSON();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        featureJson.writeFeatureCollection(DataUtilities.collection(allfeatures), outputStream);
        outputStream.writeTo(outputStream);
        outputStream.close();
        System.out.println(outputStream.toString());

        dataStore.dispose();
    }

When I run the file as a Java application, all the console prints tell me that the script is running as intended, producing extra features and setting the attributes, outputting the GeoJSON at the end.

However, when run from exec it only executes the code correctly up to line 176 and then fails.

I have Googled what the problem might be but there is very little online related to clazz references like this so apologies if I can’t be more explicit but I’m not sure what the problem might be.

EDIT:
I realised the problem – I was trying to update the attributes of the datastore objects rather than creating new ones and adding the new SimpleFeatures to an arraylist. After building new features, the script ran fine from exec.

My PHP script is:

<?php

$siteid = isset($_POST["siteid"]) ? $_POST["siteid"] : 0;
strval($siteid);

$format = "java -jar C://Users//antjs//eclipse-workspace//DevMapWebsite//jars//createsites.jar ";
$string = sprintf($format, (strval($siteid)));
exec($string, $result);

$myarr=json_encode($result);
echo $myarr;
print_r($result)

?>

  • “The error message is caused by this line:” I rather doubt that, since the exception’s message says it occurred at a line containing clazz.isArray(). Edit your question and show us the entire stack trace for the exception.

    – 

  • Ok I’ve added all the stack trace and all the entire script, hope you can help…

    – 

  • Hard to tell what’s happening here. I would start by printing out the value of newtwositesfeaturegeom, to make sure it isn’t null.

    – 

Leave a Comment