天道酬勤,学无止境

javax

TransformerConfigurationException:无法为 Transformer 设置功能(TransformerConfigurationException: Cannot set the feature for Transformer)

问题 我在为 TransformerFactory 设置功能时遇到以下错误。 javax.xml.transform.TransformerConfigurationException: Cannot set the feature 'http://apache.org/xml/features/disallow-doctype-decl' on this TransformerFactory. at org.apache.xalan.processor.TransformerFactoryImpl.setFeature(TransformerFactoryImpl.java:416) 代码片段是:: public static TransformerFactory mytFactory; mytFactory = TransformerFactory.newInstance(); mytFactory.setFeature(“http://apache.org/xml/features/disallow-doctype-decl“, true); 请帮我解决这个问题。 回答1 我也未能调用 TransformerFactoryImpl 的方法“setFeature”。 我找到了使用 XMLReader 设置功能的其他方法,如下所示: XMLReader reader =

2021-10-22 23:37:13    分类:技术分享    security   java-8   saxparser   xalan   javax

javax.validation 来验证值列表?(javax.validation to validate list of values?)

问题 有没有办法使用 javax.validation 来验证名为 color 的字符串类型的变量,该变量只需要使用注释(红色、蓝色、绿色、粉红色)这些值? 我见过@size(min=1, max=25)和@notnull但有没有像这样的东西@In(red, blue, green, pink) 或多或少类似于mysql使用的In-keyword 回答1 在这种情况下,我认为使用 @Pattern 注释会更简单,就像下面的代码片段一样。 如果您想要不区分大小写的评估,只需添加适当的标志: @Pattern(regexp = "red|blue|green|pink", flags = Pattern.Flag.CASE_INSENSITIVE) 回答2 您可以创建自定义验证注释。 我会在这里写(未经测试的代码!): @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @Constraint(validatedBy = InConstraintValidator.class) public @interface In { String message() default "YOURPACKAGE.In.message}"; Class<

2021-10-21 23:28:51    分类:技术分享    java   spring   validation   javax

无法找到内容类型为 text/html 且类型为接口 java.util.List 的 MessageBodyReader(Unable to find a MessageBodyReader of content-type text/html and type interface java.util.List)

问题 请不要将其视为重复请求,因为我已经浏览了 stackoverflow 中的所有帖子,但没有人回答。 我没有找到任何回应。 问题是: 我面临一个非常奇怪的问题,通过独立应用程序(在 main() 内)使用相同的代码段发出 GET 请求。 它的工作原理就像将相同的代码放在 Java EE 应用程序中并部署在 Wildfly 10 服务器上一样,它会给出错误 “无法找到内容类型为 text/html 且类型为接口 java.util.List 的 MessageBodyReader” 代码: ClientConfig configuration = new ClientConfig(); configuration.property(ClientProperties.CONNECT_TIMEOUT, 10000); configuration.property(ClientProperties.READ_TIMEOUT, 10000); Client iexRestClient=ClientBuilder.newClient(configuration); WebTarget webTarget = iexRestClient.target("https://api.iextrading.com/1.0/ref-data/symbols/"); Response response

2021-10-19 21:51:45    分类:技术分享    java   jboss   jax-rs   wildfly-10   javax

TransformerConfigurationException: Cannot set the feature for Transformer

i'm getting below error while setting the feature for TransformerFactory. javax.xml.transform.TransformerConfigurationException: Cannot set the feature 'http://apache.org/xml/features/disallow-doctype-decl' on this TransformerFactory. at org.apache.xalan.processor.TransformerFactoryImpl.setFeature(TransformerFactoryImpl.java:416) Code snippet is:: public static TransformerFactory mytFactory; mytFactory = TransformerFactory.newInstance(); mytFactory.setFeature(“http://apache.org/xml/features/disallow-doctype-decl“, true); please help me to solve this issue.

2021-10-12 11:19:11    分类:问答    security   java-8   saxparser   xalan   javax

使用 Aspectj 调用 joinPoint.getArgs 时如何忽略带有 javax 注释的参数?(How to ignore parameters with javax annotation when calling joinPoint.getArgs using Aspectj?)

问题 我的函数包含不同的 javax 查询注释,例如: @QueryParam 、 @Context 、 @PathParam等。 有没有办法在调用 joinPoint.getArgs() 时排除这些参数? 例子: @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("{pathParam}/v1/{pathParam2}/") @MyAnnotation public Response update(@PathParam("pathParam") String p1, @PathParam("pathParam2") int p2, MyObject x); @Before("@annotation(MyAnnotation)") public void doSomething(JoinPoint joinPoint){ Object[] objects = joinPoint.getArgs(); // HERE - is there a way to get only MyObject and not other params..? } 我想这样做的原因是我有几个 url,同时将 ~10% 标记为持久性。 这意味着我希望将输入数据保存在某个持久服务中。

2021-10-09 18:19:11    分类:技术分享    java   post   annotations   aspectj   javax

在哪里可以找到在项目中使用的 javax.websocket .jars(Where to find javax.websocket .jars for use in project)

问题 我一直在尝试使用 Java 库 jPushbullet2。 它的依赖项之一是“javax.websocket”。 我已经搜索了 websocket API 所在的站点,但找不到要下载和使用的 jar。 这样的事情存在吗? 我也注意到jPushbullet2的作者提到了Tyrus,这是一个“参考实现”,推测是参考了javax.websocket。 这是我需要的吗? 我已经将它与其他依赖项一起添加到我的项目的构建路径中,并尝试运行第一个推送示例: public class FirstPush { public static void main(String[] args) throws PushbulletException { PushbulletClient client = new PushbulletClient( "o.F8y8swnMc4MESY5rE1aUw8cFLloFH2uH" ); String result = client.sendNote(null, "My First Push", "Great library. All my devices can see this!"); System.out.println( "Result: " + result ); } } 但是,不幸的是,这会导致以下错误: Exception in thread

2021-10-09 08:21:13    分类:技术分享    java   websocket   pushbullet   javax

How to ignore parameters with javax annotation when calling joinPoint.getArgs using Aspectj?

I have functions that include different javax Query annotations like : @QueryParam , @Context , @PathParam etc.. is there a way to exclude these parameters when calling joinPoint.getArgs()? Example: @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("{pathParam}/v1/{pathParam2}/") @MyAnnotation public Response update(@PathParam("pathParam") String p1, @PathParam("pathParam2") int p2, MyObject x); @Before("@annotation(MyAnnotation)") public void doSomething(JoinPoint joinPoint){ Object[] objects = joinPoint.getArgs(); // HERE - is there a way to get only

2021-09-07 14:59:57    分类:问答    java   post   annotations   aspectj   javax

Where to find javax.websocket .jars for use in project

I've been attempting to use the Java library, jPushbullet2. One of its dependencies is "javax.websocket". I've searched through the site that the websocket API is located and haven't been able to find a jar to download and use. Does such a thing exist? I also noticed that the author of jPushbullet2 mentioned Tyrus, which is a "reference implementation", presumable in reference to javax.websocket. Is this what I need? I've already added it to my project's build path along with the other dependencies and have tried to run the first push sample: public class FirstPush { public static void main

2021-07-01 21:02:31    分类:问答    java   websocket   pushbullet   javax

Unable to find a MessageBodyReader of content-type text/html and type interface java.util.List

Please do not consider it as duplicate request as i have gone through all the post in stackoverflow, none of them answered. no response i found. Issue is : I am facing a very weird issue making a GET request with same piece of code via standalone application (inside main()). It works where as if the same code is put in Java EE app and deployed on a wildfly 10 server, it gives Error "Unable to find a MessageBodyReader of content-type text/html and type interface java.util.List" Code: ClientConfig configuration = new ClientConfig(); configuration.property(ClientProperties.CONNECT_TIMEOUT, 10000)

2021-06-25 00:13:56    分类:问答    java   jboss   jax-rs   wildfly-10   javax

javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

前言今天一个朋友让我帮他做一下tomcat的https配置,中间遇到了标题中这个错误,因此记录了一下过程,服务器、域名、证书、tomcat都已经准备好,就是需要配置一下即可,用的是阿里云的证书服务,也是通过阿里云的证书服务生成的证书文件。配置步骤通过阿里云控制台下载tomcat的https证书文件,证书文件很多,这里是点击tomcat选项下的下载按钮。把证书文件传到linux服务器,如21xxxxx.zip。进入tomcat安装目录,比如/opt/tomcat-8.0,并创建cert目录(这个目录名可任意设置,用来存放证书),并把证书的压缩包移到此文件夹中,解压。#进入tomcat目录 cd /opt/tomcat-8.0 #创建cert目录 mkdir cert #进入cert目录 cd cert #移动证书文件至当前目录 mv /home/user1/21xxxxx.zip ./ #解压证书文件 unzip 21xxxxx.zip进入tomcat的配置文件目录,修改server.xml配置文件。cd /opt/tomcat-8.0/conf vi server.xml重启tomcat服务器https方式访问tomcat报错初始时的tomcat的配置文件:由于没有配置过tomcat的https目录,因此就直接按照阿里云的帮助文档来配置了,文件如下:https是443端口

2021-06-02 08:30:08    分类:博客    javax