小编Arv*_*ind的帖子

如何使用JAX-WS webfault

我写了一个webservice并试图抛出我的自定义异常,但我收到错误请帮我解决.

import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService(name = "WebService")
public class WebServiceTest {
    public String sayHello(String name) throws InvalidInputException {
        throw new InvalidInputException("I am testing", null);
    }
    public static void main(String[] args) {
        WebServiceTest server = new WebServiceTest();
        Endpoint endpoint = Endpoint.publish(
                "http://localhost:9191/webServiceTest", server);
    }
}


import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;

@XmlType(name = "InputMessageValidationFaultType")
public class FaultBean {

    @XmlAttribute
    protected String msg;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String value) {
        this.msg = value;
    }

}


import javax.xml.ws.WebFault;

@WebFault(faultBean …
Run Code Online (Sandbox Code Playgroud)

java web-services jax-ws

12
推荐指数
2
解决办法
3万
查看次数

JSF 2.0从另一个Bean访问Application Scope bean

我正在使用jsf 2.0,我有两个bean导航(应用程序范围)和模块(请求范围).我想在Module Bean中使用Navigation bean的方法.我在模块Bean中这样做

 @ManagedProperty(value = "#{navigationBean}")
    private NavigationBean navigationBean;
Run Code Online (Sandbox Code Playgroud)

但是当我试图得到navigationBean.SomeMethod它时,它不起作用,因为导航bean是null.这该怎么做?

jsf-2

7
推荐指数
1
解决办法
8829
查看次数

JSF2.0空白输入字段未设置为NULL

我有一个支持Bean其中filelds长,双,整数,字符串当我不指定在输入栏的东西,它以零时间不长,整数和双精度,而不是空.我正在使用tomcat来部署我的应用程序.有什么解决方案吗?我尝试了以下上下文参数,但它不起作用.

<context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)

java jsf jsf-2

6
推荐指数
1
解决办法
3937
查看次数

在Java程序中使用浏览器的证书

我正在尝试使用Java中的HttpURLConnection发出HTTP GET请求。当我开始使用浏览器时,它说我的证书不受信任,您要继续吗?我接受证书,并且GET请求获取数据。但是我在java中获得证书异常(下面给出)

我从该异常中了解到的是,在发出GET请求之前,我需要下载该证书并放置此java系统属性。

我的问题是。

  1. 如何从浏览器下载此证书?
  2. 我可以在我的Java程序中使用浏览器的证书存储,使用它需要知道些什么?
  3. 如果我想在密钥库中安装证书,那该怎么办?

非常感谢 :)

我正在尝试使用keytool命令下载证书。我不知道证书存储在服务器中的位置,但是我给出了我在浏览器中使用的服务器的路径,浏览器说证书不受信任。

在此处输入图片说明

URL gatewayServiceUrl = new URL("http://192.168.55.179:56400/nwa");
        HttpURLConnection connection = (HttpURLConnection) gatewayServiceUrl.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Authorization", getExample.getBasicAuth());
        connection.connect();
        if (HttpURLConnection.HTTP_OK == connection.getResponseCode()) {
            System.out.println("success");
            System.out.println(getExample.getDataFromStream(connection.getInputStream()));
        } else {
            System.out.println("success");
            System.out.println(getExample.getDataFromStream(connection.getErrorStream()));
        }
        System.out.println(connection.getResponseCode());






Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
    at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
    at sun.security.ssl.Handshaker.processLoop(Unknown Source)
    at …
Run Code Online (Sandbox Code Playgroud)

java ssl google-chrome httpurlconnection ssl-certificate

5
推荐指数
1
解决办法
1万
查看次数

JSP 中 List 中的 ${employee.id} 抛出 java.lang.NumberFormatException:对于输入字符串:“id”

我有一个 JSP 页面,List<Employee><c:forEach>.

@RequestMapping(value = { "getAllEmployees", "/" })
public ModelAndView getAllEmployees() {
    // logger.info("Getting the all Employees.");
    List<Employee> employeeList = employeeService.getAllEmployees();
    return new ModelAndView("employeeList", "employeeList", employeeList);
}
Run Code Online (Sandbox Code Playgroud)

List<Employee>从下面的方法显示时,相同的 JSP 会引发异常。

@RequestMapping("searchEmployee")
public ModelAndView searchEmployee(@RequestParam("searchName") String searchName) {
    // logger.info("Searching the Employee. Employee Names: " + searchName);
    List<Employee> employeeList = employeeService.getAllEmployees(searchName);
    System.err.println("Employee count = "+employeeList.size());
    return new ModelAndView("employeeList", "employeeList", employeeList);
}
Run Code Online (Sandbox Code Playgroud)

这是堆栈跟踪:

java.lang.NumberFormatException: For input string: "id"
    java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    java.lang.Integer.parseInt(Integer.java:492)
    java.lang.Integer.parseInt(Integer.java:527)
    javax.el.ArrayELResolver.coerce(ArrayELResolver.java:151)
    javax.el.ArrayELResolver.getValue(ArrayELResolver.java:64)
    org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)
    org.apache.el.parser.AstValue.getValue(AstValue.java:169) …
Run Code Online (Sandbox Code Playgroud)

spring jsp hibernate el spring-mvc

4
推荐指数
1
解决办法
1533
查看次数

Ajax支持在h:selectOneMenu中

一旦从下拉列表中选择了一个值,我就必须调用后端代码.我正在使用JSF 2.0.在JSF 1.2中我是通过使用<a4j:support>in来实现的<h:selectOneMenu>,但我并没有考虑如何在JSF 2.0中实现它.

ajax jsf jsf-2

3
推荐指数
1
解决办法
1万
查看次数

Java:在控制台泰语文本打印为一些奇怪的字符

当我在控制台中打印泰国字符时,它显示出一些奇怪的特征.

public static void main(String[] args) throws Exception{
        byte[] bytes = "???????".getBytes("TIS-620");
        String str =  new  String(bytes);
        System.out.println(str);
}
Run Code Online (Sandbox Code Playgroud)

它打印 ¢

java eclipse utf-8 character-encoding thai

3
推荐指数
1
解决办法
5205
查看次数

使用 JPA 插入数据后应用程序不会终止

我需要使用 Hibernate 创建表并将数据插入到 mysql 中。

我能够创建数据并插入到表中,但我的问题是,main 方法在执行后没有终止。Service 方法在打印“========DONE=======”后继续执行

请让我知道如何解决此问题

MySql 版本 在此处输入图片说明 休眠版 在此处输入图片说明 持久化xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="MyPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.inc.Greeting</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/maersk"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value="root"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.hbm2ddl.auto"  value="update"/>
</properties>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)

服务类

public class Test {
     EntityManager em = null;
    void initEntityManager() {
         EntityManagerFactory emf = Persistence.createEntityManagerFactory("MyPU");
         em = emf.createEntityManager();
    }
    void create() {
         em.getTransaction().begin();
         Greeting g_en = new Greeting("hel", "en");
         Greeting[] greetings = new Greeting[]{g_en};
         for(Greeting g …
Run Code Online (Sandbox Code Playgroud)

java mysql hibernate jpa

1
推荐指数
1
解决办法
652
查看次数

为什么 bean 没有被注入到测试类中

我有一个 jar 将包含在 spring boot 应用程序中,我正在尝试在此进行集成测试,该项目具有用于创建数据源和 JDBC 模板的配置类,我正在使用测试,

当这个jar包含在另一个项目中时,该项目中没有应用程序类,该项目可以很好地获取数据但不在同一个项目中

spring-boot-starter-test 作为依赖添加

配置

@Configuration
    public class DatabaseAccesManagementConfig {

        @Bean(name = "accessmngmtDataSource")
        @Qualifier("accessmngmtDataSource")
        @ConfigurationProperties(prefix = "accessmngmt.datasource")
        public DataSource accessmngmtDataSource() {
            return DataSourceBuilder.create().build();
        }

        @Bean(name = "accessmngmtJdbcTemplate")
        @Qualifier("accessmngmtJdbcTemplate")
        public JdbcTemplate accessmngmtJdbcTemplate(@Qualifier("accessmngmtDataSource") DataSource accessmngmtDataSource) {
            return new JdbcTemplate(accessmngmtDataSource);
        }
    }
Run Code Online (Sandbox Code Playgroud)

道类

 @Repository
    public class ResourcePrivilegesDao {
        static final  Logger log = LoggerFactory.getLogger(ResourcePrivilegesDao.class);
        @Autowired
        @Qualifier("accessmngmtJdbcTemplate")
        private JdbcTemplate jdbcTemplate;

        public List<RP> getAll() {
            log.debug("entering getAll()");
            String sql = "SELECT * FROM rp";
            RowMapper<RP> rowMapper = new …
Run Code Online (Sandbox Code Playgroud)

java testng spring spring-boot spring-boot-test

1
推荐指数
1
解决办法
4323
查看次数

Swing应用程序的分布

我想向我的客户分发一个swing应用程序.在那个应用程序中有两个属性文件,它们应该对客户端可见,以便它们可以编辑,我不能将它作为runnable jar.此外,我想是这样的apache-tomcat的zip文件,它一旦你提取它会安排文件夹结构也将给予属性文件进行编辑,并在下次运行它读取性能.另外apache-tomcat以startup.bat或startup.sh开头,就像我想要的那样.

java deployment installation swing

0
推荐指数
1
解决办法
1451
查看次数