Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/398.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
尝试从IntelliJ IDEA 2017 Ultimate和JDK 9.0.1中的Java代码创建wsdl时出错_Java_Web Services_Intellij Idea - Fatal编程技术网

尝试从IntelliJ IDEA 2017 Ultimate和JDK 9.0.1中的Java代码创建wsdl时出错

尝试从IntelliJ IDEA 2017 Ultimate和JDK 9.0.1中的Java代码创建wsdl时出错,java,web-services,intellij-idea,Java,Web Services,Intellij Idea,错误-С:\Program Files\Java\jdk-9.0.1\bin\Java-类路径 C:/Users/karan/DistributedWebService/out/production/DistributedWebService -Djava.util.logging.config.file=C:\Users\karan\AppData\Local\Temp\logging3997.config -Xmx128M com.sun.tools.ws.WsGen-wsdl-rc:/Us

错误-С:\Program Files\Java\jdk-9.0.1\bin\Java-类路径 C:/Users/karan/DistributedWebService/out/production/DistributedWebService -Djava.util.logging.config.file=C:\Users\karan\AppData\Local\Temp\logging3997.config -Xmx128M com.sun.tools.ws.WsGen-wsdl-rc:/Users/karan/DistributedWebService/src/Server-servicename {}ServerDVL-portname{}ServerDVL-d C:\Users\karan\AppData\Local\Temp\jaxwsgen2-cp。Server.ServerDVL 错误:无法找到或加载主类com.sun.tools.ws.WsGen 作者:java.lang.ClassNotFoundException:com.sun.tools.ws.WsGen

源代码

package Server;


import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.HashMap;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.Endpoint;

@WebService
@SOAPBinding(style=Style.RPC)
public class ServerWST implements Runnable{
    String fileName = "log_WST.txt";

    File file = new File(fileName);
    FileWriter writer = null;
    static HashMap<String,HashMap<Integer,HashMap<String,String>>> outerMap = new HashMap<>();

    static ArrayList<HashMap<String,String>> innerArr = new ArrayList<HashMap<String,String>>();
    static ArrayList<HashMap<Integer,HashMap<String,String>>> outerArr = new ArrayList<HashMap<Integer,HashMap<String,String>>>();
    static HashMap<String,Integer> outerDateIndexMap = new HashMap<String, Integer>();
    static HashMap<Integer,Integer> innerRoomIndexMap = new HashMap<Integer,Integer>();

    // this is for the booking ID implementation in the Book Room and the cancel Room methods and for changing the reservation in the upcoming assignment

    static ArrayList<String> components = new ArrayList<String>();
    static HashMap<String, ArrayList<String>> bookingIDMap = new HashMap<String,ArrayList<String>>();
    String bookingID = "";
    int rr = 1500;
    static HashMap<ArrayList<String>, String> studentIDMap = new HashMap<ArrayList<String>, String>();

    // ends here ----------------------------------------------------------------------------------------------


    static  HashMap<String,Integer> countRestriction = new HashMap<>();



    // main method starts here
    public static void main(String args[] )
    {

        UDPWST ut1 = new UDPWST();
        Thread t = new Thread(ut1);
        t.start();

        Object implementor = new ServerWST ();
        String address = "http://localhost:9002/ServerWST";
        Endpoint.publish(address, implementor);

    }

    public void createRecord(String date, int roomNo, String timeSlot, String id)
    {
        innerArr.add(new HashMap<String, String>());
        int innerIndex = innerArr.size() - 1;
        innerArr.get(innerIndex).put(timeSlot, id);

        outerArr.add(new HashMap<Integer, HashMap<String, String>>());
        int outerIndex = outerArr.size() - 1;
        outerArr.get(outerIndex).put(roomNo, innerArr.get(innerIndex));

        outerMap.put(date, outerArr.get(outerIndex));
        innerRoomIndexMap.put(roomNo, innerIndex);
        outerDateIndexMap.put(date, outerIndex);


    }



    private void flush() {
        // TODO Auto-generated method stub

    }


    public String deleteRoom(String date, int roomNo, String timeSlot) {


        if (outerMap.get(date).get(roomNo).get(timeSlot) != null)
        {
            outerMap.get(date).get(roomNo).remove(timeSlot);
            System.out.println("Deletion Succesfull");
            return "Deletion Succesfull";
        } else {
            System.out.println("No such record found for the entries provided:");
            return "No such record found for the entries provided:";
        }

    }
    synchronized public String bookRoom(String date, int roomNo, String timeSlot,String id, String campusName) {

        if (campusName.startsWith("WST", 0)) {
            if (outerMap.get(date).get(roomNo).get(timeSlot) != null) {
                if (countRestriction.get(id) == null)
                    countRestriction.put(id, 0);
                if (countRestriction.get(id) >= 3) {
                    System.out.println("You cannot book this room because you have exceeded the maximum number of rooms that you can book per week.");
                } else if (outerMap.get(date).get(roomNo).get(timeSlot).equals("0")) {
                    bookingID = "RR" + rr;
                    components.add(date);
                    components.add(roomNo + "");
                    components.add(timeSlot);
                    components.add(id);
                    bookingIDMap.put(bookingID, components);
                    studentIDMap.put(components, id);
                    rr++;
                    outerMap.get(date).get(roomNo).replace(timeSlot, id);
                    System.out.println("The room was booked by the student with the ID " + id + "and the booking ID is" + bookingID);
                    countRestriction.replace(id, countRestriction.get(id) + 1);
                    return bookingID;

                }
            } else {
                System.out.println("Sorry please try again... Could not book the room for you !!");
                return "";

            }
        }
        else if (campusName.startsWith("KKL", 0)) {
            DatagramSocket aSocket2 = null;
            // this is the part where i am implementing the booking room function in the other campus as well.
            try {

                aSocket2 = new DatagramSocket();
                byte[] m = ("bROOM_" + date + "_" + roomNo + "_" + timeSlot + "_" + id + "_" + campusName).getBytes();
                InetAddress aHost = InetAddress.getByName("localhost");
                int serverPort = 1079;

                DatagramPacket request = new DatagramPacket(m, ("bROOM_" + date + "_" + roomNo + "_" + timeSlot + "_" + id + "_" + campusName).length(), aHost, serverPort);
                aSocket2.send(request);

                byte[] buffer = new byte[1000];
                DatagramPacket reply = new DatagramPacket(buffer, buffer.length);
                aSocket2.receive(reply);
                System.out.println("Reply " + new String(reply.getData()));
                return new String(reply.getData());
            } catch (SocketException e) {
                System.out.println("Socket: " + e.getMessage());
            } catch (IOException e) {
                System.out.println("IO: DVL");
            } finally {
                if (aSocket2 != null) aSocket2.close();
            }
        }
        else if(campusName.startsWith("DVL", 0)) {
            DatagramSocket aSocket3 = null;
            try {

                aSocket3 = new DatagramSocket();
                byte[] m = ("bROOM_" + date + "_" + roomNo + "_" + timeSlot + "_" + id + "_" + campusName).getBytes();
                InetAddress aHost = InetAddress.getByName("localhost");
                int serverPort = 1099;

                DatagramPacket request = new DatagramPacket(m, ("bROOM_" + date + "_" + roomNo + "_" + timeSlot + "_" + id + "_" + campusName).length(), aHost, serverPort);
                aSocket3.send(request);

                byte[] buffer = new byte[1000];
                DatagramPacket reply = new DatagramPacket(buffer, buffer.length);
                aSocket3.receive(reply);
                System.out.println("Reply " + new String(reply.getData()));
                return new String(reply.getData());
            } catch (SocketException e) {
                System.out.println("Socket: " + e.getMessage());
            } catch (IOException e) {
                System.out.println("IO: DVL");
            } finally {
                if (aSocket3 != null) aSocket3.close();
            }
        }
        return "";
    }

    public String getAvailableTimeSlotsWithoutT(String date) {
        int counter = 0;
        if(outerMap.get(date) != null){
            for(int index : outerMap.get(date).keySet())
            {
                for(String timeIndex : outerMap.get(date).get(index).keySet()) {
                    if(outerMap.get(date).get(index).get(timeIndex)==null){
                        System.out.println("There is no value in the timeslot and hence nothing will be processed by WST");
                    } else if (outerMap.get(date).get(index).get(timeIndex).equals("0")){
                        counter++;
                    }
                }
            }
            System.out.println("the number of records available in the WST campus are " + counter);
            return "WST" + counter;
        }
        else {
            System.out.println("there is nothing to show as their is no value for the timelots for those dates in WST campus.");
            return "";
        }


    }

    public void getAvailabilityTimeSlotsWithT(String date){
        DatagramSocket aSocket = null;
        DatagramSocket aSocket1 = null;

        String tempAvail = getAvailableTimeSlotsWithoutT(date);

        try {
            aSocket = new DatagramSocket();
            byte[] m = ("gATSWT_" + date).getBytes();
            InetAddress aHost = InetAddress.getByName("localhost");
            int serverPort = 1079;
            DatagramPacket request = new DatagramPacket(m,("gATSWT_" + date).length(), aHost, serverPort);
            aSocket.send(request);
            byte[] buffer = new byte[1000];
            DatagramPacket reply = new DatagramPacket(buffer, buffer.length);
            aSocket.receive(reply);
            System.out.println("Reply " + new String (reply.getData()));

            aSocket1 = new DatagramSocket();
            byte[] m1 = ("gATSWT_" + date).getBytes();
            InetAddress aHost1 = InetAddress.getByName("localhost");
            int serverPort1 = 1099;
            DatagramPacket request1 = new DatagramPacket(m1,("gATSWT_" + date).length(), aHost1, serverPort1);
            aSocket1.send(request1);
            byte[] buffer1 = new byte[1000];
            DatagramPacket reply1 = new DatagramPacket(buffer1, buffer1.length);
            aSocket1.receive(reply1);
            System.out.println("Reply " + new String (reply1.getData()));


        }
        catch(SocketException e) {
            System.out.println("Socket: " + e.getMessage());
        }
        catch(IOException e) {
            System.out.println("IO: WST");
        }
        finally {
            if(aSocket != null) aSocket.close();
        }
    }


    @Override
    public void run() {
        // TODO Auto-generated method stub

    }
    synchronized public boolean cancelBooking(String bookingID) {
        String datec, roomNoc,timeSlotc;
        String tempStudentID = studentIDMap.get(bookingIDMap.get(bookingID));
        datec =  bookingIDMap.get(bookingID).get(0);
        roomNoc = bookingIDMap.get(bookingID).get(1).trim();
        timeSlotc = bookingIDMap.get(bookingID).get(2);

        outerMap.get(datec).get(roomNoc).replace(timeSlotc, "0");

        // this is to remove the booking ID from the bookingIDMAP HashMap
        bookingIDMap.remove(bookingID);


        return true;
    }
    synchronized public void changeBooking (String newDate, int newRoomNo, String newTimeSlot, String id, String bookingID, String newCampusName )
    {
//        if(bookingIDMap.get(bookingID).get(3).equals("id") && outerMap.get(newDate).get(newRoomNo).get(newTimeSlot).equals("0"))
//        {
        String result =  bookRoom( newDate,  newRoomNo, newTimeSlot, id, newCampusName);
        if(result.equals(""))
        {
            System.out.println("the room could not be booked for some reason so there will be no change made to the previous room booking." + "\n");

        }
        else
        {
            cancelBooking(bookingID);
            System.out.println("your booking with the booking ID " + bookingID + " has been cancelled and the new room with the room no" + newRoomNo + " date " + newDate + " timeSlot " + newTimeSlot  + " has been booked");
        }
        //}

    }
}
包服务器;
导入java.io.File;
导入java.io.FileWriter;
导入java.io.IOException;
导入java.net.DatagramPacket;
导入java.net.DatagramSocket;
导入java.net.InetAddress;
导入java.net.SocketException;
导入java.util.ArrayList;
导入java.util.HashMap;
导入javax.jws.WebMethod;
导入javax.jws.WebService;
导入javax.jws.soap.SOAPBinding;
导入javax.jws.soap.SOAPBinding.Style;
导入javax.xml.ws.Endpoint;
@网络服务
@SOAPBinding(style=style.RPC)
公共类ServerWST实现可运行{
字符串fileName=“log_WST.txt”;
文件=新文件(文件名);
FileWriter=null;
静态HashMap outerMap=newhashmap();
静态ArrayList innerArr=新ArrayList();
静态ArrayList outerArr=新ArrayList();
静态HashMap outerDateIndexMap=新HashMap();
静态HashMap innerRoomIndexMap=新HashMap();
//这用于在预订室和取消房间方法中实现预订ID,以及在即将到来的任务中更改预订
静态ArrayList组件=新建ArrayList();
静态HashMap bookingIDMap=newhashmap();
字符串bookingID=“”;
int rr=1500;
静态HashMap studentIDMap=newhashmap();
//到此为止----------------------------------------------------------------------------------------------
静态HashMap countRestriction=新HashMap();
//主要方法从这里开始
公共静态void main(字符串参数[])
{
UDPWST ut1=新的UDPWST();
螺纹t=新螺纹(ut1);
t、 start();
对象实现者=newserverwst();
字符串地址=”http://localhost:9002/ServerWST";
发布(地址、实现者);
}
public void createRecord(字符串日期、int roomNo、字符串时隙、字符串id)
{
add(newhashmap());
int innerIndex=innerArr.size()-1;
get(innerIndex).put(时隙,id);
add(newhashmap());
int outerIndex=outerArr.size()-1;
get(outerIndex).put(roomNo,innerArr.get(innerIndex));
outerMap.put(日期,outerRarr.get(outerIndex));
innerRoomIndexMap.put(房间号,innerIndex);
outerDateIndexMap.put(日期、outerIndex);
}
私有空间刷新(){
//TODO自动生成的方法存根
}
公共字符串删除房间(字符串日期、int roomNo、字符串时隙){
if(outerMap.get(date).get(roomNo.get(时隙)!=null)
{
outerMap.get(日期).get(房间号).remove(时隙);
System.out.println(“删除成功”);
返回“删除成功”;
}否则{
System.out.println(“未找到所提供条目的此类记录:”);
return“未找到所提供条目的此类记录”:;
}
}
同步公共字符串bookRoom(字符串日期、int roomNo、字符串时隙、字符串id、字符串campusName){
if(campusName.startsWith(“WST”,0)){
if(outerMap.get(date).get(roomNo.get(时隙)!=null){
if(countRestriction.get(id)==null)
countRestriction.put(id,0);
if(countRestriction.get(id)>=3){
System.out.println(“您无法预订此房间,因为您已超过每周可预订的最大房间数。”);
}else if(outerMap.get(date).get(roomNo).get(timeSlot).equals(“0”)){
bookingID=“RR”+RR;
增加(日期);
组件。添加(roomNo+“”);
组件。添加(时隙);
组件。添加(id);
bookingIDMap.put(bookingID,组件);
studentmap.put(组件,id);
rr++;
outerMap.get(日期).get(房间号).replace(时隙,id);
System.out.println(“该房间由ID为“+ID+”的学生预订,预订ID为“+bookingID”);
countRestriction.replace(id,countRestriction.get(id)+1);
返回bookingID;
}
}否则{
System.out.println(“对不起,请再试一次……无法为您预订房间!!”;
返回“”;
}
}
else if(campusName.startsWith(“KKL”,0)){
DatagramSocket aSocket2=null;
//这也是我在其他校区实现预订房间功能的部分。
试一试{
aSocket2=新的DatagramSocket();
字节[]m=(“扫帚+日期+”+房间号+“+时间段+”+id+“+营地名称).getBytes();
InetAddress aHost=InetAddress.getByName(“localhost”);
int serverPort=1079;
DatagramPacket请求=新的DatagramPacket(m,(“扫帚+日期+”房间号+“+时隙+”房间号+id+”房间名+CampuName).length(),aHost,服务器端口);
aSocket2.发送(请求);
字节[]缓冲区=新字节[1000];
DatagramPacket reply=新的DatagramPacket(buffer,buffer.length);
aSocket2.接收(应答);
System.out.println(“回复”+新字符串(回复