jakarta-ee

Publishing EJB's local interface in weblogic

旧城冷巷雨未停 提交于 2020-01-13 06:11:29
问题 is there a way to lookup an EJB in weblogic if it implements only local interface? If I use this @Remote public interface TestSessionRemote { public void businessMethod(); } @Stateless(mappedName = "A") public class TestSessionBean implements TestSessionRemote { public void businessMethod() { } } the EJB can be looked up using this name: "A#" + TestSessionRemote.class.getName() If I change the annotation for TestSessionRemote from @Remote to @Local the EJB disappears from JNDI. Is there a way

struts2 junit 2.3.12 plugin - unable to write successful test in struts2 junit4

非 Y 不嫁゛ 提交于 2020-01-13 05:53:31
问题 I'm using struts2 junit 2.3.12 plugin. If I run test directly, then I get : java.lang.NoClassDefFoundError: javax/servlet/ServletContext so I include <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> in my POM, after which I get : java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException so, I remove the above dependency and add

struts2 junit 2.3.12 plugin - unable to write successful test in struts2 junit4

假如想象 提交于 2020-01-13 05:53:30
问题 I'm using struts2 junit 2.3.12 plugin. If I run test directly, then I get : java.lang.NoClassDefFoundError: javax/servlet/ServletContext so I include <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> in my POM, after which I get : java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException so, I remove the above dependency and add

Need to upload file on S3 in Java

一个人想着一个人 提交于 2020-01-13 05:39:31
问题 I have started working on AWS recently. I am currently working on developing upload functionality to S3 storage. As per my understanding there could be 2 ways to upload a file to S3:- Client's file gets uploaded to my server and i upload this file to S3 server using my credentials. [i will also able to hide this from client as i will not be showing the upload details.] Upload directly to S3 I was able to implement the first approach using simple upload api , but i want to skip the " write

Add CORS headers to response of j_security_check

眉间皱痕 提交于 2020-01-13 05:01:07
问题 I'm building a REST API with jax-rs and WildFly 10 . Some of the endpoints are secured. I'm using FORM based authentication. In my javascript code, I check the response of the AJAX request, and if it is set to 401 Unauthorized , I then present a login form to the user. When he fills it in, I POST the details to j_security_check . Running on localhost this all works fine, but when the webserver and the REST server are on different machines, the browser denies the AJAX request due to cross

How to get bytes/contents of each ZipFile entry from ZipInputStream without writing to outputstream?

对着背影说爱祢 提交于 2020-01-13 03:38:06
问题 I am trying to get the bytes of a particular file from the zipped file input stream. I have the input stream data of the Zipped file. From this I am getting the ZipEntry and writing the contents of each ZipEntry to a output stream and returning the byte buffer. This will return the buffer size output stream, but not the contents of each particular file. Is there a way I can convert the FileOutputStream to bytes or directly read the bytes of each ZipEntry? I need to return the ZipEntry

How to get bytes/contents of each ZipFile entry from ZipInputStream without writing to outputstream?

拥有回忆 提交于 2020-01-13 03:37:09
问题 I am trying to get the bytes of a particular file from the zipped file input stream. I have the input stream data of the Zipped file. From this I am getting the ZipEntry and writing the contents of each ZipEntry to a output stream and returning the byte buffer. This will return the buffer size output stream, but not the contents of each particular file. Is there a way I can convert the FileOutputStream to bytes or directly read the bytes of each ZipEntry? I need to return the ZipEntry

How to get Column names of JPA entity

自闭症网瘾萝莉.ら 提交于 2020-01-13 02:42:20
问题 All my JPA entity classes implement an interface called Entity which is defined like this: public interface Entity extends Serializable { // some methods } Some of the fields of my JPA entity have @Column annotation on top of them and some don't. MyEntity class is defined like below: @Entity public class MyEntity implements Entity { @Id private Long id; // Assume that it is auto-generated using a sequence. @Column(name="field1") private String field1; private SecureString field2; /

SecurityContext doesn't work with @RolesAllowed

匆匆过客 提交于 2020-01-12 19:13:09
问题 I'm currently creating a backend server using Jersey 2.5.1 in a Tomcat 7. For the security I'm using the @RolesAllowed , @PermitAll etc. annotations, and I have created my custom ContainerRequestFilter and SecurityContext . My problem is that when my @RolesAllowed annotated resource is requested it always denies permission, even if I force my isUserInRole(role) method to return true . However, my filter method gets called. Do you have any suggestions? I'll paste some relevant code below. My

Calling a CDI session scoped producer method from an EJB stateless session bean

本小妞迷上赌 提交于 2020-01-12 18:22:51
问题 I want to inject the current user using @Inject @Current User across all layers (i.e. web layer, EJB layer). In order to do this, I have the following CDI Producer method: @Named @SessionScoped public class UserController { @Resource SessionContext sessionContext; @EJB UserDao userDao; @Produces @Current public User getCurrentUser() { String username = sessionContext.getCallerPrincipal().getName(); User user = userDao.findByUsername(username); } } @Qualifier @Target({TYPE, METHOD, PARAMETER,