teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

情報の追加

2019/03/07 10:23

投稿

makaroni
makaroni

スコア24

title CHANGED
File without changes
body CHANGED
@@ -9,8 +9,26 @@
9
9
  (日本語)
10
10
  ![イメージ説明](cf7530176f58dbaaeafb1f286ac331bf.png)
11
11
 
12
- バッキングビーンの一部です
12
+ **バッキングビーン**
13
13
  ```java
14
+ package beans;
15
+
16
+ import entity.Images_Upimages;
17
+ import java.io.Serializable;
18
+ import java.util.List;
19
+ import db.*;
20
+ import java.io.ByteArrayInputStream;
21
+ import java.nio.file.Path;
22
+ import java.util.Map;
23
+ import javax.ejb.EJB;
24
+ import javax.enterprise.context.SessionScoped;
25
+ import javax.faces.context.ExternalContext;
26
+ import javax.faces.context.FacesContext;
27
+ import javax.faces.event.PhaseId;
28
+ import javax.inject.Named;
29
+ import org.primefaces.model.DefaultStreamedContent;
30
+ import org.primefaces.model.StreamedContent;
31
+
14
32
  @Named
15
33
  @SessionScoped
16
34
  public class Bb implements Serializable{
@@ -27,7 +45,76 @@
27
45
  Images_Upimages entity = new Images_Upimages(text,good);
28
46
  iudb.create(entity);
29
47
  }
48
+
49
+ public List<Images_Upimages> getAll(){
50
+ return iudb.getAll();
51
+ }
52
+
53
+ public StreamedContent getPic() {
54
+ FacesContext context = FacesContext.getCurrentInstance();
55
+ if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
56
+ return new DefaultStreamedContent();
57
+ } else {
58
+ ExternalContext sv = context.getExternalContext();
59
+ Map<String, String> map = sv.getRequestParameterMap();
60
+ String key = map.get("Id");
61
+
62
+ Images_Upimages e = (Images_Upimages)(iudb.find(Integer.valueOf(key)));
63
+
64
+ ByteArrayInputStream in = new ByteArrayInputStream(e.getPicture());
65
+ DefaultStreamedContent ds = new DefaultStreamedContent(in);
66
+ return ds;
67
+ }
68
+ }
69
+
70
+ public String getText() {
71
+ return text;
72
+ }
73
+
74
+ public void setText(String text) {
75
+ this.text = text;
76
+ }
77
+
78
+ public Path getFile() {
79
+ return file;
80
+ }
81
+
82
+ public void setFile(Path file) {
83
+ this.file = file;
84
+ }
85
+
86
+ public Integer getGood() {
87
+ return good;
88
+ }
89
+
90
+ public void setGood(Integer good) {
91
+ this.good = good;
92
+ }
93
+
94
+
95
+
96
+ }
97
+
30
98
  ```
99
+ **Chromeでのconsole**
100
+ ![![イメージ説明](f7f7cc3d75308783035296ba0718794d.png)
101
+
102
+ **スタックトレース(途中)**
103
+ > java.lang.IllegalStateException: Exception attempting to inject Remote ejb-ref name=beans.Bb/upimages,Remote 3.x interface =entity.Images_Upimages,ejb-link=null,lookup=,mappedName=,jndi-name=entity.Images_Upimages,refType=Session into class beans.Bb: Lookup failed for 'java:comp/env/beans.Bb/upimages' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
104
+ at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:175)
105
+ at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)
106
+ at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:65)
107
+ at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:109)
108
+ at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:150)
109
+ at org.jboss.weld.util.bean.IsolatedForwardingBean.create(IsolatedForwardingBean.java:44)
110
+ at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
111
+ at org.jboss.weld.context.PassivatingContextWrapper$AbstractPassivatingContextWrapper.get(PassivatingContextWrapper.java:76)
112
+ at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:740)
113
+ at org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
114
+ at org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)
115
+ at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188)
116
+
117
+
31
118
  バッキングビーン無しでxhtmlを書くと問題なく実行できます。
32
119
 
33
120
  こんなに長いエラーはめったに見ることがないので正直ビビっています(泣)

1

2019/03/07 10:23

投稿

makaroni
makaroni

スコア24

title CHANGED
File without changes
body CHANGED
@@ -32,4 +32,4 @@
32
32
 
33
33
  こんなに長いエラーはめったに見ることがないので正直ビビっています(泣)
34
34
  このエラーでかなり足止めを食らっているのでできれば早急に
35
- 回答ほうよろしくお願いします。
35
+ 回答ほうよろしくお願いします。