我有一個java bean的項目,我需要使用JAI,所以我添加一個Maven depedendency添加JAI爲wildfly模塊
<dependency>
<groupId>com.github.jai-imageio</groupId>
<artifactId>jai-imageio-core</artifactId>
<version>1.3.1</version>
</dependency>
我嘗試添加新模塊wildfly 9喜歡
模塊。 XML
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.github.jaiimageio">
<resources>
<resource-root path="jai-imageio-core-1.3.1.jar"/>
</resources>
</module>
然後我從mvnrepo 添加一個罐子,罐子放+ module.xml在
wildfly-9.0.2.Final \模塊\ SYSTEM \層\基地\ COM \ github上\ jaiimageio \主
在我的Java項目然後
JBoss的部署,structure.xml
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jboss.ejb3"/>
<module name="org.jboss.ws.api"/>
<module name="org.apache.cxf"/>
<module name="org.jboss.ws.cxf.jbossws-cxf-server"/>
<module name="com.github.jaiimageio"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
但是,當我試圖打電話給我的java bean我有一個例外
Caused by: java.util.NoSuchElementException
at javax.imageio.spi.FilterIterator.next(ServiceRegistry.java:836)
at javax.imageio.ImageIO$ImageWriterIterator.next(ImageIO.java:842)
at javax.imageio.ImageIO$ImageWriterIterator.next(ImageIO.java:827)
at ru.shop.createFile.CreateFileBean.write_tiff(CreateFileBean.java:541)
at ru.shop.createFile.CreateFileBean.testAdd(CreateFileBean.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:73)
at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:59)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)
... 79 more
我的代碼:
private void write_tiff() throws IOException
{
RenderedImage image=javax.imageio.ImageIO.read(new File("C:\\users\\user\\Desktop\\examples\\srts.jpg"));
RenderedImage image1=javax.imageio.ImageIO.read(new File("C:\\users\\user\\Desktop\\examples\\passport.jpg"));
Iterator<ImageWriter> iterator=ImageIO.getImageWritersByFormatName("TIFF");
System.out.println(iterator.hasNext());
ImageWriter writer=iterator.next();
}
ImageIO.getImageWritersByFormatName(「TIFF」)返回null。
但是,如果我從java應用程序調用此方法,而不是在java bean中,一切都可以。
我試圖chande modulename com.github.jai-imageio,但沒有chandes。
任何人都可以幫助我嗎?
可能的重複[發生在Tiff的getImageWritersByFormatName中。獲取圖像作家](http://stackoverflow.com/questions/22523644/issue-in-getimagewritersbyformatname-for-tiff-getting-image-writer)。特別注意第二個答案,關於Tomcat –
謝謝Jon,但我已經試過調用scanForPlugins(),沒有結果。此外,我將我的jar添加到wildfly的ext文件夾中,但不幸的是也沒有提供。 –
您是否已將jai-imageio-core-1.3.1.jar添加到jre的lib/ext目錄中?我認爲這就是第一個答案所表明的。 –